texts: failure to verify truffle compiled contract on ropsten.etherscan.io

texts:
Recently just pushed my first smart contract from truffle to the ropsten testnet.

As you can see from my terminal output below it compiles and was migrated with no problem:

Was broadcast to the network by my running geth node:

The contract can be found on my GitHub here, it looks like this:

pragma solidity ^0.4.13;

// This contract demonstrates a simple non-constant (transactional) function you can call from geth.
// increment() takes no parameters and merely increments the "iteration" value.

contract Incrementer {
    uint iteration;

    function Incrementer() {
        iteration = 0;
    }

    function increment(uint count) {
        iteration += count;
    }

    function getIteration() constant returns (uint) {
        return iteration;
    }

}

This is the representation of the transaction on ropsten.etherscan.io:

You can see that the ByteCode on the Blockchain (what we are looking for) and the Your Compiled Bytecode (what you provided) are the same in the beginning- I don't know if that means anything or not- but anyhow:

I know that in the past there were some problems with trying to verify contracts compiled with truffle with respect to the Runs (Optimizer), but so far as I could tell this has been fixed, anyway for good measure I've tried to verify with this value set to 0 and also to 200, neither have worked...

Here's what I've been entering:

Is it correct what I've been doing?

Why is this contract not verifying?


texts: On Eth 2.0 how will smart contracts and other applications assigned to a shard? Will they stay on that shard permanently?

texts: Trying to learn more about eth 2.0 here.


texts: Solidity How to pre-populate an Array with default values

texts:
My smart-contract has a mapping for Token-ID’s and their Prices, declared as follows:
   mapping (uint256 => uint256) public tokenIdAndItsPriceMapping;

-I intend to have only 5,000 tokens in total, and I want to pre-set their prices during the Contract’s deployment, but do so in ranges.
Here’s what I mean:
-Tokens 0 through 49 are going to be 0.1 ETH
-Tokens 50 through 99 are going to be 0.2 ETH
-Tokens 100 through 149 are going to be 0.3 ETH
etc.
I can obviously do this in the Constructor using FOR loops, as follows:
//  0 -- 49
for(uint i = 0; i <= 49; i++) {
     tokenIdAndItsPriceDictionary[i] = 1000000000000000000 wei; // 0.1 ETH
}

// 50 -- 99
for(uint i = 50; i <= 99; i++) {
     tokenIdAndItsPriceDictionary[i] = 2000000000000000000 wei; // 0.2 ETH
}

// etc.

But with there being 5,000 values to fill, that’s still going to require quite a lot of FOR loops - such that I might reach the Block’s Gas Limit during the contract’s deployment - causing it to fail.
And if the project’s requirements were to change such that 10,000 Tokens will be needed instead of 5,000, what then?
Ordinarily - meaning in other languages, we can easily create a fixed-length Array and pre-populate it with default values - which would come in very handily for this.
But it doesn't look like Solidity lets you do this.
Another approach would be to create a function that’ll return any particular Token’s price using it’s ID - and a big long IF statement:
function getTokenPrice(uint256 tokenID) returns (uint 256) {
    if(tokenID >= 0 && tokenID <= 49) {
     tokenIdAndItsPriceDictionary[tokenID] = 1000000000000000000 wei; // 0.1 ETH
  }
  else if(tokenID >= 50 && tokenID <= 99) {
     tokenIdAndItsPriceDictionary[tokenID] = 2000000000000000000 wei; // 0.2 ETH
  }
  else if(tokenID >= 100 && tokenID <= 149) {
     tokenIdAndItsPriceDictionary[tokenID] = 3000000000000000000 wei; // 0.3 ETH
  }
  // etc.

  return tokenIdAndItsPriceDictionary[tokenID]
}

This could work - but for only one Token at a time.
What if I wanted to have a function that returns ALL the prices of all the Tokens all at once, in one big Array?
Like what if my front-end web3 App needed to get all those prices from the smart-contract as it loaded into the browser?


texts: Checking the length of bytes32[] in Contract constructor throws with Invalid Opcode

texts:
This is my Contract constructor:

function MyContract(address _owner, bytes32[] _array) {
        owner = _owner;
        require(_array.length > 1);
    }

The require(_array.length > 1) causes the contract to fail with:

Error: VM Exception while processing transaction: invalid opcode
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:37295:16)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:224765:36
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:66971:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:208348:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:209773:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67130:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67420:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67575:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67535:24)
    at emitNone (events.js:110:20)

Why does this throw an exception? And how do I solve this?

EDIT

contract('MyContract', function(accounts) {
    const testParams = {
        _owner: accounts[0],
        _array: ["first", "second", "third"],
    };

    let testMyContract;

    describe("New MyContract:", async function() {
        before(async function() {
            testMyContract = await MyContract.new(...Object.values(testParams));
        });

        it("sets the first account as the contract creator", async function() {
            let owner = await testMyContract.owner.call();
            assert.equal(owner, accounts[0], "Owner does not match.");
        });

        it("sets the topic result names correctly", async function() {
            let resultName1 = await testMyContract.getResultName(0);
            assert.equal(web3.toUtf8(resultName1), testParams._resultNames[0], "Result name 1 does not match.");

            let resultName2 = await testMyContract.getResultName(1);
            assert.equal(web3.toUtf8(resultName2), testParams._resultNames[1], "Result name 2 does not match.");

            let resultName3 = await testMyContract.getResultName(2);
            assert.equal(web3.toUtf8(resultName3), testParams._resultNames[2], "Result name 3 does not match.");
        });
        });
    });
}

Migration Script

var SafeMath = artifacts.require("./SafeMath.sol");
var MyContract = artifacts.require("./MyContract.sol");
var MyContractCreator = artifacts.require("./MyContractCreator.sol");

module.exports = function(deployer) {
    deployer.deploy(SafeMath);
    deployer.link(SafeMath, MyContract);
    deployer.deploy(MyContract);
    deployer.link(MyContract, MyContractCreator);
    deployer.deploy(MyContractCreator);
};


texts: Python 3 How to make Event Filter via createFilter web3.py v4.2.1

texts:
According to the Web3.py Documentation: http://web3py.readthedocs.io/en/latest/filters.html

Quote "event_filter = contract.events.myEvent.createFilter(fromBlock='latest', {'filter': {'arg1':10}})"

                                                              ^

Then I got: "SyntaxError: positional argument follows keyword argument"

Then I removed "fromBlock='lastest',"

event_filter = contract.events.myEvent.createFilter({'filter': {'arg1':10}})

Then I got: "TypeError: createFilter() takes 1 positional argument but 2 were given"

Ok... then I Googled that...
https://stackoverflow.com/questions/23944657/typeerror-method-takes-1-positional-argument-but-2-were-given

let's try: my_new_object = cInst.events()

Then I got "TypeError: 'ContractEvents' object is not callable"

Does this web3.py Documentation work at all??? I am so disappointed... :(

Please help. Thank you


texts:
Suppose, I have the following bytecode (0x610101610102016000526001601ff3) that pushes two numbers to the stack, adds them and returns the value.

Now I want to write a function in Solidity that will take this bytecode as input and return the final result (i.e., the final stack, memory, and storage contents after the execution inside EVM). How can I write this function? Is it possible to do so (for example - using the solidity assembly)? Please suggest. Thanks in advance.


texts:
I'm reading truffles's docs and am trying to build a custom project with a contract and a few test cases (written in a js file). I need to do this because testrpc is (considerably) faster than geth. My setup is as follows:

I have a directory for the project with the following layout:

drwxr-xr-x 5 user user 4096 Aug  4 10:55 app
drwxr-xr-x 4 user user 4096 Aug  4 11:35 build
drwxr-xr-x 2 user user 4096 Aug  4 11:06 contracts
drwxr-xr-x 2 user user 4096 Aug  4 10:55 migrations
drwxr-xr-x 2 user user 4096 Aug  4 11:24 test
-rw-r--r-- 1 user user  248 Aug  4 10:55 truffle.js

The files were created using truffle init. I've cleared the contracts in the contracts directory and the js files in the test directory.

I have a contract:

C.sol

contract C {

    string words = "Bla bla bla";

    uint256 lastVal;

    function math(uint256 a, uint256 b) returns (uint256) {
        lastVal = a + b;
        return lastVal;
    }

    function getWords() constant returns (string) {
        return words;
    }
}

in the contracts directory and a test file:

c.js

contract('C', function(accounts) {
  it("Getting the words string from the contract", function() {
    var c = C.deployed();

    return c.getWords.call(accounts[0]).then(function(words) {
      assert.equal(words, "Bla bla bla", "[E] The contract should have said \"Bla bla bla\"");
    });
  });

  it(" 2 + 2 = 4 ", function(){
    var c = C.deployed();

    return c.math(2, 2).then(function(additionResult){
        assert.equal(additionResult, 4, "[E] 2 + 2 = 4 even in eth. contracts.");
    });
  });
});

in the tests directory. I have manually cleared the build directory and ran

truffle build

int the base directory. Nothing (no artifacts) gets built in the build directory. Why?

Does anybody have a minimal setup that does not involve developing a web app? only the contract .sol files and js test files.


texts: Transaction not mined error when deploying to quorum maker server

texts:
I get the following error when attempting to deploy my zeppelin erc20 token to a quorum server(used quorum maker).

    (master) $ node migrations/2_proj.js
``````` transactionHash 0xcd2c34e35564a3a50557563a8ff512ea55fda9cefbf5ef927678d2e7dbb3b9ee
``````` Error: Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!
    at /Users/.../code/proj/node_modules/web3-core-method/src/index.js:390:42
    at <anonymous>
(node:49162) UnhandledPromiseRejectionWarning: Error: Transaction was not mined within750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!
    at /Users/.../code/proj/node_modules/web3-core-method/src/index.js:390:42
    at <anonymous>
(node:49162) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:49162) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is the code used to deploy:

var Web3 = require('web3')
var TruffleConfig = require('../truffle')

let deployToken = async function() {
const config = TruffleConfig.networks['ma1Staging']
const web3 = new Web3(new Web3.providers.HttpProvider('http://' + config.host + ':' + config.port))

let contractJson = require('../build/contracts/' + 'token.sol'.replace('.sol', '.json'))
const contract = new web3.eth.Contract(contractJson.abi)
await contract.deploy({
    data: contractJson.bytecode,
}).send({
    from: config.from,
    gas: 3000000,
    gasPrice: '0',
}).on('error', (error) => {
    console.log('````````error', error)
}).on('transactionHash', (transactionHash) => {
    console.log('````````transactionHash', transactionHash)
}).on('receipt', (receipt) => {
    console.log('````````receipt', receipt) // contains the new contract address
}).on('confirmation', (confirmationNumber, receipt) => {
    console.log('````````confirmationNumber, receipt', confirmationNumber, receipt)
})
console.log('`````````migration done')
}
deployToken()
module.exports = deployToken

To run it I use node from the command line.

This is my sol file:

pragma solidity ^0.4.23;

import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol";
import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol";

/**
@title token
*/
contract tokenName is ERC20Mintable, ERC20Burnable {
    string public name = "tokenName";
    string public symbol = "tokenName";
    uint public decimals = 18;
}

I used truffle to build my contract.


texts: How is a post-transaction state calculated?

texts:
A receipt from rpc returns a root which I believe is the "post-transaction state" from the yellow paper. The internet seems to say this is the same thing as the full stateRoot at the exact moment after the transaction.

However. I tested these assumptions by picking a transaction which threw an error, and looking at the receipt roots immediately before and after. When a transaction throws an error the state should not be updated, so I expected the roots to be equal. They are not.

What in the state would change after an error transaction?

Am I misunderstanding which value is which?


texts: Can I use chainlink on a private blockchain？

texts:
Can I use chainlink on a private blockchain built with Geth? I found that the online tutorials are basically about how to use chainlink on the Kovan test chain. I want to know whether chainlink can be used on a private blockchain?
Hope you can help me?


texts: When sending transactions with JSON-RPC: Integer type must have numerical suffix?

texts:
As the picture shows, when sending transactions with jsonrpc, I use the call_with_transaction function. But it tells me that there is something wrong with my way of asserting the arguments (that "1")

AssertionError: Integer type must have numerical suffix

What does that mean?


texts: How to change the nonce between transactions in web3j?

texts:
I have this line of code where it registers a transaction in blockchain. And I wanted to know how I can make the nonce different between the transactions?

txhash = careercertificate
            .createCertificate(id, fecha, nombre, rutalumno, instituto, rutinstituto, titulo, totalhash, fechatitulacion, registronumber, codigoV)
            .send().getTransactionHash();


texts: user api to exchange eth token and wallet address creating using code

texts:
Is there any API to help exchange ether or tokens online which will help in coding an exchange.
For bitcoin one can generate a wallet address, is it possible to generate a wallet address for Ethereum with the help of api?


texts: How to scan all token transfers on both ethereum and matic?

texts:
I have the following code that uses the etherscan API to read for the most recent transfers for a particular contract-address on the Ethereum chain. I need to do the same, but on the Matic chain. From what I can see the etherscan API would not support this.
import etherscan.accounts as accounts

""" The following is an example code that continuously checks the transactions for the Tether token and prints
the most recent 3. """

key = ''  # Insert your own Etherscan API_KEY

address = '0xdac...'  # Address of coin we want to read
api = accounts.Account(address=address, api_key=key)

while(True):  # For now loop infinitely
    page = api.get_transaction_page(page=1, offset=3, sort='desc')  # Get the latest 3 transactions

    # Print them
    print(page[0])
    print(page[1])
    print(page[2])
    print('=============')

Is there an API or way to scan both Ethereum and Matic chains?


texts: Parity: if I don't include --no-ancient-blocks will it download blocks all the way back to genesis (after the initial sync)?

texts: In other words, if I have less than 1.5TB to play with, is  --no-ancient-blocks essential?


texts: Can't connect Android app to Ganache using retrofit

texts:
I'm have deployed contracts on ethereum blockchain. I have ganache running on server

I'm tring to connect to it from android with this code:

private BlockChainService() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://127.0.0.1:8545/")
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
        blockChainApi = retrofit.create(BlockChainApi.class);
    }

But it's raising exception with the message - "failed to connect to /127.0.0.1:8545".
I've tried opening the app from genymotion emulator and from the actual device also but the problem is still the same.

I also have spring boot application which is successfully connecting with ganache using exactly the same code.
So my guess is that it's related to network.

So my question is how can I connect from android app to ganache? Is it a problem with the network?


texts: Does reverted transactions considered as mined transactions?

texts:
I want to know if a reverted transaction is considered as mined one ?

this is mean nonce should be incremented


texts: What else could cause geth node loosing peers over time?

texts:
Im running a geth (1.3.5) node on a Windows 8 mining rig.
Doing that for some month now, i couldnt solve the following problem/behavior:
- After starting the node i get connected to 10-15 peers
- the connection seems stable for like +- one day
- after that day the peer number starts dropping slowly
- 2-3 days after starting the node the peer count is zero
- i restart the node and the same behavior starts from the beginning

i tried
- to have my time syncronised --> should be correct (tried different time servers but samesame)
- disabling my firewall/antivirus... everything --> did not change anything
- to add nodes manually --> admin.addNode

nothing helped..
what else could cause this or what am i not thinking of?


texts:
What is the has() function in Solidity?

  struct Role {
    mapping (address => bool) bearer;
  }

  function add(Role storage role, address account) internal {
    require(account != address(0), "The account cannot be an uninitialized address");
    require(!has(role, account)); // right here

    role.bearer[account] = true;
  }

Intuitively, I think it's determining whether the account exists in role or not and returning a boolean value, but can't seem to find the documentation.


texts: Why ETH Transfer from Nethereum taking longer time then transfering from metamask wallet?

texts:
I am sorry for nubby question.
Today i made a ETH transfer of 0.00001 ETH 2 times. One programmatically with Netherium SDK and another directly through metamask wallet to another metamask wallet.
Here are the transaction hash.
https://etherscan.io/tx/0xb3fcd0c1466ad9dbb660b6c81812d82709acbbaaf08845995a6b2f42cea1f81d (With Netherium)
https://etherscan.io/tx/0xc1c47dfedfbec85c4c97518ec0e3e3fbb8b78959de38cb9544c9fb9b9a5e4d70 (With Metamask Wallet Transfer)
However the first transaction is taking almost 2 hours and still is in pending while the second transfer was within 30secs. Although Both have similar gas values and transaction fee.
Is there any specific reason for this?
Thanks!


texts: Is there any kind of locking protocol in Ethereum?

texts:
Is there any kind of locking protocol in ethereum, like can two transaction update the state variable same time ?, If yes then how would you avoid that ?

Smart Contract XYZ is deployed and two people want to update an variable in the XYZ, so they push transaction into the transaction pool. Now what if both transaction is executed at the same time. lets say if Transaction one wants to add 5 to the variable and transaction 2 wants to add 10 to the variable, in happy path the value in the xyz state variable must be 15(Trx 1 + trx 2), but what if both read the value same time and one of them add a block then either 5(Trx 1) is added or 10(Trx 2) is added.


texts: What is the value meaning transferred while minting bep721 tokens on bsc

texts:
I am trying to find exact gas fees for each minting of BEP721 on binance smart chain. I see that the transaction fee is very minimum with compare to etheruem. But I am confused about the value in BNB which is transferred to the receiver?
Is this value is included in minting fees? or what is this value? I checked the Eth transactions as well but there is no value transferred when minting tokens.

Here is the link to transaction.
https://bscscan.com/tx/0xc3edcb792a236b6d9aba402e618caf3b43e6bfbde0aa5deda5e9b8c254624aea


texts: Is it possible to find a specific statistic for each token?

texts:
I'm trying to create some sort of statistic generator related to ERC20s. Let's assume you have 10,000 Token A. I would like to tell users something like: "better than 0.5% of the accounts". Basically it would compare against the other holders of the specific token. I know this would be massive in terms of computer resources.

Is there a solution to that already ?

I can see on Etherscan that we can already see addresses by "holders" here


texts:
As per documentation we have import features, but do we have any export to file feature in Solidity that I can use inside my smart contract.

Got a similar thread at How to export transactions into a CSV file
but it discusses only about exporting transactions, rather than intermediate or final results of a smart contract operation.


texts: How can I debug the interaction between two contracts?

texts:
I have a solidity file that has:

pragma solidity ^0.4.18;

contract World {
    mapping (address => bool) players;
    mapping (address => ResourceBank) resourceBanks;
    function giveZero() public {
        if (!players[msg.sender]) {
            resourceBanks[msg.sender] = new ResourceBank();
            players[msg.sender] = true;
        }
        ResourceBank bank = resourceBanks[msg.sender];
        bank.add(0);
    }
}

contract ResourceBank {
    uint[] resources;
    function add(uint resource) public {
        resources.push(resource);
    }
}

When I deploy and run giveZero the first time, it is fine. On the second invocation of giveZero on the same contract, the transaction is failing and getting reverted but I do not know why.

I am using remix.ethereum.org. I debug the transaction and am taken to the bank.add(rewardType) line. I've read lots of documentation but still do not know how to investigate this. I have tried sending gas along with the add call but it is not helping. The add method can be called many times without an issue when I deploy a separate ResourceBank.

What is going wrong here and how can I debug the issue?


texts: Suppose in blockchain network we have 5 nodes and we have new transaction done by first node of network, so now rest of 4 node will mine the transaction to commit it in blockchain network, will the nonce be same for all node mining the same transaction?


texts: Etherscan shows my contract has RPC errors

texts:
I deployed my token contract using Remix. I tested it in Ropsten several times and all was well. When I finally went to deploy it on the mainnet it deployed fine so it seemed. But in etherscan it doesn't show my token name or anything. It just has the contract address and when you hover over it it says, "There were RPC errors" and that it is, "Unable to determine if contract"

What's going on?


texts: Rejected/Removed Transactions how and when can they happen?

texts:
Background:
I am writing a blockchain viewer/exporter that requests, via Parity JSONRPC, blockchain information and then stores this info off chain.

Currently I am trying to accumulate all pending transactions.  I want to get them as soon as they come in and they will be removed when they are mined in to a block (essentially removed from pending by having a block id assigned).  IIf every transaction ever seen was mined in to a block this would be fine, however, in my experience Parity will report transactions then later on fail to give any information when that transaction hash is queried again.  Further more the transaction may again show up at a later time.

I was originally using eth_newPendingTransactionFilter this generally worked ok but Parity always failed to return any "pending" transactions out of band of the current block being reported.  I.e. I could query the filter over and over but until the next block was posted Parity did not return new transactions so I switched to parity_pendingTransactions.  This returns all pending transactions currently in the queue, however the situation will occur where a transaction will no longer be reported in the queue, not mined in to a block, yet re-appear at a later time.

Question: What is the logic for pending transactions?

While Paritys' RPC documentation is good on how to call it, is there any documentation anywhere (either Parity or Ethereum) that describes these scenarios and how to detect them?  I.e. is the information that it is being removed in the log or somewhere else?


texts:
we have a JSON RPC method eth_sendRawTransaction as specified here.

how is the raw transaction data formatted? I can't seem to find this anywhere.

I'm guessing it consists of a signed transaction struct serialized and encoded in some way, but it doesn't explicitly say.


texts: See how long a transaction took to confirm

texts:
Given a finalized transaction, is there a way to see how long it took? Perhaps using blocks to calculate an estimate?

Take this one for instance.

I have been trying to calculate transaction times of existing ones but I feel I'm missing some info and I dont know whether these sites are showing the most relevant information or that is all there is to a transaction.

Thanks.


texts:
Okay, so I went into cryptomoonshot.net and voted for a coin. But to get in there, I had to "Sign" my wallet to log in.
What is this feature in metamask? Does it give the webpage access to my wallet, or is it a beneign way of actually proving you own this wallet?
(Also cryptomoonshot.net is BSC i think and not ETH, but don't really know where else i should ask this question)


texts: Html interaction with smart contract via web3.js

texts:
I have a html code interacting with my smart contract via a local test rpc local host.

I was just wondering if I deploy this contract to the main network instead of using test rpc, what should be the http provider I specify in my html code?

As well as would the user whom will interact with the html page need to have a test rpc running as well.

   <script>
   if (typeof web3 !== 'undefined' && typeof window.web3.currentProvider !== "undefined")
   {
     console.log(typeof web3)
     web3 = new Web3(web3.currentProvider );
   } else {
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
   }


texts: Chainlink node not connecting to External Adapter

texts: I'm trying to use the Chainlink External Adapter to connect my contract to Twitter but my node I'm running is seemingly not able to connect to the adapter at localhost:8080 even though the adapter says that's the port it's listening on. Specifically I'm getting the error, ExternalBridge post to external adapter: connection refused. Thoughts?


texts: Creating address and getting public address from private

texts:
Just for learning I am trying, using javascript & ethereum, to create an address and get public key from private key without using a library like web3.

Anyone has tried to do this? any resources you can point me out?


texts: get pending transactions in `txpool` via web3

texts:
I want to monitor the mempool for my pending transactions. I understand one can monitor pending transactions by eth_subscribe (e.g. answered here). But some of my transactions have been stuck in the txpool, and they don't seem to show up in the result ofeth_subscribe`.

I'm confused by the difference between mempool, txpool, and pending transactions returned from eth_subscribe.

how to retrieve transactions that are already in txpool?
eth_subscribe only returns txid. Some of them can't be found by eth.getTransaction. What does that mean?
Transactions returned from eth_subscribe are different from what are in txpool. It's unclear whether they form a superset of txpool or not.


texts: Struct variable of type enum not getting updated

texts:
I am trying to update a struct variable of type enum

contract BookStore {

enum BookStatus { Open, Sold, Unsold }

mapping(uint => Book) stores;
uint public count;

struct Book{
uint bookId;
string name;
BookStatus status;
}

function BookStore() {
count = 0;
}

function addP(string _name) {
count += 1;
Book memory b1= Book(count,_name,BookStatus.Open);
stores[count] = b1;
}

function updateStatus (uint _bookId) public {
Book storage b1= stores[_bookId];
b1.status = BookStatus.Sold;
}

function getStatus(uint _bookId) public returns (BookStatus) {
Book storage b1= stores[_bookId];
return b1.status;
}

}

I am running my project on testrpc. When I try to call the function from truffle console

  BookStore.deployed().then(function(i) {i.updateStatus(7, {from:
  web3.eth.accounts[3], gas: 1000000}).then(function(f)
  {console.log(f)})});

I get the following error :

  (node:2584) UnhandledPromiseRejectionWarning: Unhandled promise
  rejection (rejection id: 4): Error : VM Exception while processing
  transaction: invalid opcode


texts: transactions are performed sequentially by the blockchain, but how are the waiting times managed?

texts: I have a booking dapp where you can make reservations and call the bookRequest method. If many users call this method, it is not possible to know the order in which they will be performed and therefore it is not possible to know the order of confera. But how is it possible to manage this mechanism? A user cannot wait too long to receive the booking confirmation. How can I avoid pending transactions?


texts:
It's known that IPFS can use 2 types of CID, v0 and v1. In my contract, I let users store bytes data parameter. They can store some simple text on it or even pass the ipfs hash. This question is about passing ipfs hash.
As known, they can't pass ipfs hash, because it starts with Qm(v0) or baxy(v1) or whatever. So what they can do is whatever encoding IPFS use, they can first decode it in the client in order to get hex representation.  for the version v0 CiD, it will start like this 0x1220..... . for v1, it's gonna be different for sure.
Now, contract emits this event and I catch this bytes value in my other client.
How do I figure out what the CiD is from the hex ? doing this in the client seems to be very wrong in my opinion.
if(value.startsWith(`0x1220`)) {
   let cid = bs58.decode(value);
}
else if(value.startsWith(`xxx`){

}

The problem is in the second else if. it could be anything, because who knows what the base is.. as known, for CiD v1, IPFS appends base which means which base encoding it uses so that we can decode it.
Any good ideas ?


texts:
Which of the following sentences is correct:

Doing X using ether
Doing X using ethers

Thank you.


texts: Call state modifying function in view function

texts:
Is it somehow possible to do something like this?
contract Test {
    function test (bool isTransaction) public view {
        if (isTransaction) {
          foo();
        }

        ...
    }

    function foo () public {
        ...
    }
}

In the best case I would be able to call test() like an usual view/pure function without the need of making a transaction but if isTransaction is true test() requires me to make a transaction in order to call it. Maybe I can throw an exception or something similar to be able to compile and run this code?
EDIT: bool transaction got bool isTransaction


texts: Ethereum Solidity (smart contract) blockchain implementation for selecting a node as a miner to add the block

texts:
If I use a proof-of-work (PoW) algorithm in the Ethereum blockchain, the node selects to mine a new block is totally random as per my local implementation using Go-Ethereum and inter-process communication (IPC).
However, I am trying to develop a mechanism that is similar to the proof-of-stake (PoS) protocol. For example, what we see in the proof-of-stake (PoS). If a node provides more stakes, it is more likely to be selected as a miner/validator.
I find an example that provides the node's ability to give a vote which I believe is related to PoA and somehow related to my problem, but to be frank, I do not understand what the system will do by getting those votes. The example is here, https://docs.soliditylang.org/en/develop/solidity-by-example.html
I am exploring whether the problem could be solved by smart contract coding. For example, a smart contract that keeps track of the votes for different nodes, and the node that has the highest vote is allowed to add the block in the blockchain.
Advance thanks for your time and helping me out from this situation.


texts: What is 2^187 target in the Ethereum white paper wrt PoW in Bitcoin?

texts:
The paper says that

  The precise condition is that the double-SHA256 hash of every block,
  treated as a 256-bit number, must be less than a dynamically adjusted
  target, which as of the time of this writing is approximately 2^187

I was under the impression that PoW involves getting some number of leading zeroes in a hash.

Can someone please explain?


texts:
I am looking for how to decode the input data of a transaction and what I have obtained up to now is in utf-8 and it gives me this data:
"Ã;` Q Ã² Â Ã Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1 juan 12.456.123-9 Inacap 45.566 963-8
dentist 0xasdasetcdasdaetc 12092019 823 2358."

Then I wanted to see if anyone knows how to decode it and get it in a structured way.


texts:
Which firewall settings should I use for Geth as a non-miner using Linux Ubuntu 15.10?

Is there a way to check that the firewall settings are correct? If so, how do I check and set the firewall settings in the Terminal?

Should I use ufw and iptables and if so, how?

If someone has a one-liner CLI command for iptables that would be great.

Any official recommendations from core devs or other skilled coders with  expertise regarding recommended firewall settings?

These are my current iptables settings. Output from sudo iptables -L

http://pasted.co/288f28f6

Vesa


texts:
I am trying to send ETH from MEW but nothing showing even in etherscan. I submitted three times now. I assume the network somehow is overloaded.

What should I do in terms of gas limits etc?

I sent from an exchange without issues. So I guess ETH is working OK.


texts: I'm building a smart contract to learn solidity and I'm wondering how I can distinguish buy and sell functionalities. I want the contract to do different functionalities on a buy and other functionalities on a sell. I'm using uniswap/pancakeswap as the exchange. Right now I'm using the Transfer method, but it seems like this is triggerd on a buy and a sell.


texts: Recursive call ends with `VM Exception: invalid opcode`

texts:
I am running f:

contract Test {
    function f() {
        f();
    }
}

which produces VM Exception: invalid opcode in browser-solidity. Is that a bug or expected behavior?


texts: Quorum Smart Contract Performance Azure Blockchain Serivce

texts:
I wonder that how I can improve smart contract performance in Quorum.

Right now I have a smart contract which save supply chain information and we are using Azure Blockchain Service for Quorum. We have four validaor node for that.

Rigth now our TPS avarage is 1, yes we just send 50 transaction per minute and this is very slow against high performance which is written in offical document.

By the way I don't sure that how smart contract performance affect TPS.

If you have any information, it can be helpfull really to me.

Thanks.


texts: How should I handle blockchain forks in my DApp?

texts: In the user interface of my DApp, how can I detect that a blockchain reorganization happened and what should I do to update the UI state once the fork is resolved?


texts:
I am trying to connect a geth node to the network for several days with light sync, and I have encountered a lot of problems.
The last to date is there are a lot (like > 100) of error messages that look like:
Section processing failed type=bloombits error="cannonical block #4227072 unknown"
What does it mean? And what can I do?


texts: How many variables/ rows can contracts handle?

texts:
From the article: Are there well-solved and simple storage patterns for Solidity?

Ignoring costs, does anyone know how many variables/rows a solidity contract using each of the types can handle?  Or is this limited by transaction size more than anything?

More specifically, when will my contract crap out?

  struct DocumentStruct{
bytes32 name;
uint value;
}

 mapping(bytes32 => DocumentStruct) public documentStructs;

 function StoreDocument(bytes32 key, bytes32 name, uint value) returns (bool success) {
  documentStructs[key].name  = name;
 documentStructs[key].value = value;
 return true;
}


texts: How to get rid of inactive nodes in Geth

texts:
I am setting up a quorum network with Quorum-maker, which uses Geth.
It is running at the moment, with three alive nodes. However, earlier I had attempted to create two other nodes, which failed. I have since killed them off.

Now, the master node is still trying to connect to them multiple times per second. This creates a lot of logs. These logs are in the gethLogs directory, which is why I believe this is a geth issue rather than quorum specific.

INFO [06-20|04:45:34.146] peer is currently unreachable peer id=4
2019-06-20 04:45:34.146757 I | rafthttp: peer 5 became active
2019-06-20 04:45:34.170051 E | rafthttp: failed to find member 1 in cluster 1000
2019-06-20 04:45:34.170210 E | rafthttp: failed to dial 5 on stream MsgApp v2 (peer 5 failed to find local node 1)
2019-06-20 04:45:34.170227 I | rafthttp: peer 5 became inactive
2019-06-20 04:45:34.170770 E | rafthttp: failed to find member 1 in cluster 1000
INFO [06-20|04:45:34.246] peer is currently unreachable            peer id=4
2019-06-20 04:45:34.246934 I | rafthttp: peer 5 became active
2019-06-20 04:45:34.270846 E | rafthttp: failed to find member 1 in cluster 1000
2019-06-20 04:45:34.271017 E | rafthttp: failed to dial 5 on stream MsgApp v2 (peer 5 failed to find local node 1)
2019-06-20 04:45:34.271034 I | rafthttp: peer 5 became inactive
2019-06-20 04:45:34.271437 E | rafthttp: failed to find member 1 in cluster 1000
INFO [06-20|04:45:34.346] peer is currently unreachable            peer id=4
2019-06-20 04:45:34.347058 I | rafthttp: peer 5 became active
2019-06-20 04:45:34.371589 E | rafthttp: failed to find member 1 in cluster 1000
2019-06-20 04:45:34.371746 E | rafthttp: failed to dial 5 on stream MsgApp v2 (peer 5 failed to find local node 1)
2019-06-20 04:45:34.371763 I | rafthttp: peer 5 became inactive
2019-06-20 04:45:34.372624 E | rafthttp: failed to find member 1 in cluster 1000
INFO [06-20|04:45:34.446] peer is currently unreachable            peer id=4
2019-06-20 04:45:34.447434 I | rafthttp: peer 5 became active
2019-06-20 04:45:34.472487 E | rafthttp: failed to find member 1 in cluster 1000
2019-06-20 04:45:34.472664 E | rafthttp: failed to dial 5 on stream MsgApp v2 (peer 5 failed to find local node 1)
2019-06-20 04:45:34.472680 I | rafthttp: peer 5 became inactive
2019-06-20 04:45:34.473471 E | rafthttp: failed to find member 1 in cluster 1000

The message itself makes perfect sense, these two nodes (4 & 5) don't exist anymore, hence it makes sense that geth can't connect. What I am looking for is a way to get Geth to stop trying to connect to these nodes. Ideally I want to delete them from the master node entirely. At the very least I want geth to stop logging about it.


texts: What is the 'root' of a transaction receipt?

texts:
web3.eth.getTransactionReceipt returns an object with a root property and is currently undocumented in the wiki.

Result: {
    ...
      "root": "7583254379574ee8eb2943c3ee41582a0041156215e2c7d82e363098c89fe21b",
      "to": "0x91067b439e1be22196a5f64ee61e803670ba5be9",
      "transactionHash": "0xad62c939b2e865f13c61eebcb221d2c9737955e506b69fb624210d3fd4e0035b",
      "transactionIndex": 0
    }

What is this root?  It is not the same as the receiptRoot from web3.eth.getBlock.
What is the relationship between these roots?


texts: Latest Parity asking to create account everytime

texts:
I have downloaded the latest version of Parity. Installed it. It started by default and asked to create an account. I created the same and got some ethers from the parity faucet site by requesting manually. Although etherscan site showed that I have 5 ethers but in my parity UI interface it showed 0. Then realized that it default started in Homestead mode. So I closed parity process manually and then started with parity ui --chain=kovan parameters.

This time it did open in kovan mode but again it asked to create a new account and there was no way to skip it. I killed parity process. Copied the json key file from C:\Users\...\AppData\Roaming\Parity\Ethereum\keys\ethereum to C:\Users\...\AppData\Roaming\Parity\Ethereum\keys\kovan folder again restarted parity with same parameters.

But unfortunately it didn't help and still asked for creating a new account. So need a way to start parity by providing my account details so that it loads the same and doesn't ask to create a new one.


texts: If one gains 51% of network resources can he force drain the biggest wallet?

texts: If one gains 51% of the network compute resources can he force drain the biggest wallet? How could he do it if he can keep that 51% advantage?


texts:
var endval = this.balance / 2;
  counterparty1.send(endval);
  counterparty2.send(endval);
  selfdestruct(creator);

Is there anyway to selfdestruct to two parties?  I have the code above, but now you have to do the whole jazz to make sure it doesn't run out of gas in the middle of a send.  Can one end a contract and split the value a better way?


texts:
I am new to infura and was wondering how people interact with other smart chains.
Is there an equivalent service like infura for the Binance Smart Chain? Or can you still use infura for BSC?


texts: Is 21,000 Gas Limit Fixed Only for Ethereum?

texts:
I was reading a comment on another post on Ethereum SE and found the following statement:

21,000 is for sending Ether, not anything else.

The user suggested to "just set it to a large enough value (which you are willing to pay in the worst case)"
I'm perplexed. When sending ECR20 tokens (such as USDC and USDT) is the gas limit arbitrary? Or is it fixed? Setting it to an arbitrarily large number and hoping it will get accepted by the network might work but it doesn't address the fundamental question of how gas fees are calculated when sending ECR20 based tokens?
Another user suggested in a different thread that the gas fee is in fact fixed by the creator of the token:

You will have control over the gasPrice however a standard ERC20 token
transfer's gasUsed will be "fixed" (or at least out of your control).

What is the right answer? How should I calculate the gas fee when sending USDT and USDC?


texts: What is the general cause for out-of-gas with MetaMask?

texts:
This seems like a trivial question, but I can't find an answer.

When you try to send a transaction with MetaMask, it calculates the amount of gas needed.
Most of the time if there's an error in your function (an unsatisfied revert test for example), it will notice it when calculating gas price and set it to 0. If you try to send the transaction anyway, you'll get the error. So it can predict some of the errors.
But sometimes, MetaMask calculates and finds an incorrect amount of gas. Most of the times if I set it higher manually I can send the transaction.

That means that it's an error that couldn't be foreseen, and the actual gas needed is higher than expected. How does that happen? Shouldn't MetaMask be able to see what is about to happen?

Why is there a difference between errors Metamask can predict and the others?


texts:
I am trying to run two blockchains for experiments, trying geth with different ports, network IDs and folders for chain data directories does not work. How can I do this?

All help is appreciated!


texts: Would a fork occur if a half of entire nodes use different block validation algorithm?

texts:
Let's assume, a half of entire nodes use different block validation algorithm against the other half. So, for a particular type of block, one accepts it, and another one does not.

Then would the blockchain be forked?


texts: Mist Wallet Sync, Only New state entries are imported!

texts:
This may seem like a duplicate question, but I couldn't find answers to the previous ones.

I have installed Mist Wallet and started syncing for more than 4 days (For some reason I have to shutdown the system everyday though, and the process begins from where it left off but never gets completed). The final few hundreds of blocks are not getting synced, the console line says just "Imported new state entries". As of writing this, the wallet says 101 blocks left, and 78% synced. Its just the percentage seems to get vary but the sync never gets 100%.

I use windows 10 64 bit OS with latest Mist Wallet as of now. I know there is a fast mode and light mode but I don't want them as of now.


texts: Is there a way to get the lowest and average price miners are asking for gas? Some statistics sites seem to have prices but they are outdated.


texts: How to get private key from account address and password?

texts:
What I have
 1. I am able to create new account with personal.newAccount() method of web3 api.
 2. I am working on my private blockchain.
 3. geth node start with following command:-
geth --datadir ~/privateBlockChain1 --networkid 1300 --rpcport 8002  --port 30301 --rpcapi="db,eth,net,web3,personal,admin,txpool,debug" --rpc --maxpeers 0 --nodiscover --targetgaslimit 110000000000 --dev --rpccorsdomain "*" --rpcaddr "127.0.0.1" console
 4. I am using web3 api and ethereumjs-wallet npm api.
 5. Keystore file is successfully store in private blockchain directory.

What I want
 1. I want to get private key of respective account.
 2. actually, i want to get all data of keystore file of respective account from my nodejs side and will be able to save in my regular database.

Case 1:
 1. when i create account with personal.newAccount() method with password, how to get private key, if i got private key, then i will be use that key to get all keystore data by following code:---

   var Wallet = require('ethereumjs-wallet');
    var Key=Buffer.from('account_privatekey','hex');
    var wallet = Wallet.fromPrivateKey(Key);
    var json=wallet.toV3String(user_define_password);  // it will return keystore object data.

but i am unable to get actual private key from account address and password.
`
 Case 2:
   1. suppose i create private key by following code:-

     var Wallet = require('ethereumjs-wallet');
        var privateKey=Wallet.generate(password)._privKey;
        var wallet = Wallet.fromPrivateKey(privateKey);
        var json=wallet.toV3String(password); // it will get keystore data      `
  2. account creation on my private blockchain this way
           `  personal.importRawKey(key,password)
          but error showing like , importRawKey not a function `

How to fix these


texts: Import errors when compiling contracts using truffle

texts:
Please help me understand this error

`**enter code here**`No build configuration found. Preparing to compile contracts.

Compiling your contracts...
===========================
Error: Could not find
import  from any sources; imported from /home/a/Documents/sos/contracts/crowdsale.sol
    at Resolver.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:53:1)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:5:42)
    at <anonymous>
Truffle v5.1.28 (core: 5.1.28)
Node v8.10.0

This is the error I get when I compile my contracts. this is the start of my crontracts.sol

pragma solidity >=0.4.21 <0.7.0;
import "../../node_modules/openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol";
import "../../node_modules/openzeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "../../node_modules/openzeppelin/contracts/crowdsale/validation/PausableCrowdsale.sol"
import "./token.sol"

npm installed openzeppelin modules as 0.6.0 sol and the truffle version is using 0.5.16 solc


texts: Issues distributing Tokens and Ether simultaneously

texts:
I'm writing a smart contract that has a functionality of distributing ethers (for gas money) and tokens. The function looks like this

function distribute(address to, uint256 token, uint256 gasMoney) payable onlyAuthorized returns (bool sucess) {
    createToken(to, token);
    to.transfer(gasMoney);
    currentContractBalance -= gasMoney;
    return true;
}

However, whenever I call the function through web3 py as

mycontract.transact().distribute(myAddress, numberOfTokens, gasMoney)

it returns an error saying

ValueError: Contract does not appear to be deployable within the current network gas limits.  Estimated: 4704624. Current gas limit: 4700036

I haven't been able to figure out the error from my side. I've made the default account the address that was used to deploy the contract.


texts: How to access testRPC which is on a server

texts:
all! I build a dAPP for a competition and only used to test it on testRPC. Now when I had submitted the app, the organisers wanted a running version for them to test. I tried deploying it on a server which had testRPC running, but when I did a transaction, it didn't work. I created the front end in ReactJS and contracts in Solidity. Deployed the contracts on testRPC and then was trying to do implement the transactions.

But our dAPP:

This is an information broadcasting app with four entities. It works like; a user signs up using conventional method (using MongoDB). We have four testRPC accounts through which we do all the transaction. In this way, the user doesn't need to have blockchain on his desktop. But transaction never happens. Suggestion is welcome.

This is very important to me, and I would be grateful if someone can help me in this regard.


texts: rinkeby balance says 0 after syncing even though transaction shows ether was sent

texts:
I'm using truffle to deploy a contract on the rinkeby testnet

Here is transaction info saying that my address received ether however as shown below, the balance still shows as 0.

    truffle(rinkeby)> web3.eth.getTransaction("0x4979d45cb9cf0959a9f2a139eb7adc6a231b866cc52289287bb2dd5b125b0635")
{ blockHash: '0xdf597f365e50a92bf3edbd37fc293f40d174b1c0a9b6d7a2cfb4df8c785126cb',
  blockNumber: 1759853,
  from: '0x31b98d14007bdee637298086988a0bbd31184523',
  gas: 21000,
  gasPrice: BigNumber { s: 1, e: 9, c: [ 1000008601 ] },
  hash: '0x4979d45cb9cf0959a9f2a139eb7adc6a231b866cc52289287bb2dd5b125b0635',
  input: '0x',
  nonce: 56835,
  to: '0x9c1a6ce6a1a5f6c80390977c9c9f653ff49a8729',
  transactionIndex: 2,
  value: BigNumber { s: 1, e: 19, c: [ 187500 ] },
  v: '0x2b',
  r: '0xbffa1a59cd0622b265d656bd9aad9a83bdc536ce1ba8b85af5d194ba93c56905',
  s: '0x43ef0187a715be575081e6a96c860b264cfb0a0007645b7267d5bca6535f213c' }

When seeing balance, it shows as 0:

truffle(rinkeby)> web3.eth.getBalance("0x9c1a6ce6a1a5f6c80390977c9c9f653ff49a8729")
BigNumber { s: 1, e: 0, c: [ 0 ] }

In etherscan it shows that there is a balance of 18 ether for the account:
https://www.rinkeby.io/#explorer

This is the geth command I'm using:

geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --rpcaddr 172.17.0.2 --unlock 9c1a6ce6a1a5f6c80390977c9c9f653ff49a8729

And it's synced to the newest block.

When I try and deploy the contract with the following command, it says:

    root@b91a643434cf:/voteApp# truffle migrate --network rinkeby
Using network 'rinkeby'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: insufficient funds for gas * price + value


texts:
I have been looking through that web3.eth.filter function, and ran into a bit of a wall:

var options = {
  fromBlock: "pending",
  toBlock: "latest",
  address: "0xab1323fe3234234234fa34324324234af3423432",
};
var filter = web3.eth.filter(options);

in regards to the "pending" and "latest" strings, this is the definition I got from github:

  latest may be given to mean the most recent and pending currently
  mining, block

source: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethfilter

QUESTION:

What does that actually mean? If I run geth for instance and there are a bunch of blocks pending to be added to the blockchain, lets imagine each "-" represents 1 block in the following example:

- - - - - - - - -

If I had fromBlock: "pending" to toBlock: "latest", would that mean the following:

(start here) - - - - - - - - - (end here)

But if that were the case, there would be more blocks added by the time the end is reached:

(start here) - - - - - - - - - (end here) - -

So would latest mean continue forever or stop on the one that was the latest when the filter was actually created ?


texts: txHash in ethereumjs-testrpc is incorrect

texts:
the txHash of a transaction should be the sha3(raw_transaction_string

this is the case on any ethereum node, except testrpc

I created a sample. in this example, testrpc has been launched with

testrpc --port 8544 --network-id 256 --gasLimit 0x5F5E100 --account="0x29469148b567bb0142b4e33c518d833c77ef36b3894b56c7291bed448c943a03,100000000000000000000000000"

on http://54.148.24.3:10001/ there is a testnet which runs geth

when executed this code yields to rows on the console, the first one says that the hashes are NOT equal while the second confirms that they are

let Web3 = require('web3')
let EthereumTx = require('ethereumjs-tx')

let txObj = {
  from: "0x855e89aee346d780aa5912838d0fd16b4fcf12a3",
  to: "0x3532727c1126ddad9a6e9f935b74e41e7b1d4025"
}

let web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8544/'))
submitTx().then(() => {
  web3 = new Web3(new Web3.providers.HttpProvider('http://54.148.24.3:10001/'))
  return submitTx()
})

function submitTx() {
  return web3.eth.getTransactionCount(txObj.from, 'pending')
    .then(nonce => {
      txObj.nonce = nonce
      txObj.gasLimit = web3.utils.toHex(22000)
      txObj.gasPrice = web3.utils.toHex(2)
      txObj.value = web3.utils.toHex(1e18)
      const tx = new EthereumTx(txObj)
      tx.sign(Buffer.from("29469148b567bb0142b4e33c518d833c77ef36b3894b56c7291bed448c943a03", 'hex'))
      let signedTxHexString = tx.serialize().toString('hex')
      txObj.txHash = "0x" + tx.hash().toString('hex')
      return web3.eth.sendSignedTransaction("0x" + signedTxHexString, (err, txHash) => {
        if(txHash === txObj.txHash) {
          console.log("computed and returned are the same", txHash, txObj.txHash)
        } else {
          console.log("computed and returned are NOT the same", txHash, txObj.txHash)
        }
      })
    })
}

is this normal behaviour for testrpc?

For more info on the state of this issue have a look at the github https://github.com/trufflesuite/ganache-cli/issues/387


texts: how to solve solidity asynchronous Problem

texts: How to deal with asynchronous operation because of the delay blockchain ? How does the blockchain perform under high concurrency? how to deal with the mutually exclusive variable?


texts: If a transaction ends up in an orphaned/forked block, what happens to subsequent transactions?

texts:
Suppose I sign and send several transactions using the following function:

async function send(web3, account, transaction) {
    const options = {
        to  : transaction._parent._address,
        data: transaction.encodeABI(),
        gas : await transaction.estimateGas({from: account.address})
    };
    const signed  = await web3.eth.accounts.signTransaction(options, account.privateKey);
    const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);
    return receipt;
}

As you can see, I leave the nonce configuration to the node.

After signing and sending all transactions, I iterate the receipts in order to determine that all transactions have been added to the blockchain:

for (let i = 0; i < receipts.length; i++) {
    while (receipts[i].blockNumber + 12 > await web3.eth.getBlockNumber()) {
        web3.currentProvider.send({method: "evm_mine"}, () => {}); // if running on ganache
    }
    if (await web3.eth.getTransactionReceipt(receipts[i].transactionHash)) {
        console.log(`transaction ${i} confirmed`);
    }
    else {
        console.log(`transaction ${i} cancelled`);
    }
}

It is crucial to me that the transactions will be added to the blockchain by order of submission.

I know that the nonce ensures this, but I am wondering, in case a transaction ends up in an orphaned/forked block, what happens to all remaining transactions, and how can I still ensure that they will be executed by order?

It would be very easy for me if I knew that all remaining transactions were subsequently removed from the pool, in which case, I could simply resubmit all of them without setting the nonce to any specific value.

Can I count on it, or should I take the "orphaned" transaction and resubmit it with the exact same nonce? And how should I handle the remaining transactions?

Thank you!


texts: What does all those transactions with 0 mining fee corresponds to?

texts:
There have been many transactions with apparently 0 mining fees (gas price set to 0) lately. Including from F2Pool BabelPool and SparkPool.
While miners had always been free to include any transactions, they did it only for their own transactions, and in that case, they are cases where such transactions come from the same person and get mined by 2 different miners which means it’s not linked.
It’s also not related to flashbots since those transactions are sent to the mempool. And with the behavior of those senders (only minting gas tokens), it definitely looks like they don’t pay the transaction fees or that if they do, it’s a very low price compared to regular mining.
Is there an eip recently added for allowing this? If not, how such transactions are achieved? Is there a new service that launched for doing this with several miners lately?


texts: Does LemonEmail Support Perfect Forward Secrecy

texts:
LemonEmail looks like a very interesting implementation of 100% decentralized messaging system with end-to-end encryption.  From what I understand from the information available, it uses the Ethereum blockchain to transport the ‘metadata’ of messages sent through the system, and it uses IPFS to transport the encrypted messages.

But, does LemonEmail support Perfect Forward Secrecy? In other words, if a user's private key is compromised, can an attacker use it to go back and decrypt ALL of the messages that were EVER sent to that user, that were encrypted using the corresponding public key (being that the metadata and the encrypted messages could easily be accessed by the attacker, as they are presumably stored indefinitely in the Ethereum blockchain and IPFS)?

Reading LemonEmail's blog post, 'Behind-the-scenes look at Lemon Email', after 'What happens behind the scenes when you click send', it reads, 'The email is encrypted locally. This ensures we can never read your data. If the recipient is a Lemon Email user, the email is encrypted using their public key'. However, there is no mention here of any sort of ephemeral key exchange, as necessary for Perfect Forward Secrecy.

Does anyone know of anything to the contrary, that LemonEmail does in fact support Perfect Forward Secrecy?


texts:
This is a follow-up to this question. The accepted answer says:

  Yes, contracts have nonces. A nonce of a contract is only incremented
  when that contract creates another contract [...].
  When a contract invokes a function on another contract, a so called
  "internal transaction" (in http://live.ether.camp), the nonce is not
  incremented.

  The nonce can be obtained by using web3.eth.getTransactionCount.

So far, so good. But when I use web3.eth.getTransactionCount with a recently deployed contract, the value is 1, not 0, despite that contract not having created any other contract.

Why is that happening?


texts: Error while installing truffle framework

texts:
I've received the following error message while installing truffle framework on my windows 10 device.

  "Keccak bindings compilation fail. Pure JS implementation will be
  used."

Can somebody please tell what it means and if there is any way to rectify this error.


texts: Is it possible to use EVM with input data not stored on the blockchain?

texts:
I am interested in computing medical data in a decentralized way where none of the computing resources nor the requester can fully access the data for the sake of privacy concerns.

In this schema, elected servants (decentralized computers) compute parts of the raw input data using a public algorithm. The computed data is eventually transmitted to the requester.

From my understanding of EVM, both the input data and the algorithm is stored on the blockchain which greatly limits the available computational resources and extends the blockchain size unnecessarily.

Shortly after that I discovered Ethereum Computation Market which looks more interesting for my application.

As I am still confused about what EVM really is, I would like to know if I can use it to:

Compute encrypted data issued from a data lake cloud
Encrypt the result using a GPG-like method
Send the result on a cloud server.


texts: How Do i Create a New Instance of a Contract

texts:
i am trying to figure out how i can deploy a new instance of a contract and setting some values by calling some of its methods.

i am trying to follow the example on the official docs website: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#

const comment = new web3.eth.Contract(Comment.abi, { from: coinbase });

// comment object is available here. all properties at this point seem to be defined. the value is not null here.
console.log('comment:', comment);

comment.deploy()
    .send({ from: coinbase })
    .then(console.log);

but i get the error:

TypeError: Cannot read property 'send' of null


texts: Can somebody explain me following solidity code?

texts:
I was going through fixed supply token 's solidity code from wiki and I have confusion regarding ApproveAndCallFallBack contract's receiveApproval functions, it is as under

// Token owner can approve for spender to transferFrom(...)   tokens
  // from the token owner's account. The spender contract function
  // receiveApproval(...) is then executed

 function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
    allowed[msg.sender][spender] = tokens;
    Approval(msg.sender, spender, tokens);
    ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
    return true;
}

Understanding so far, this function is allowing spender contract to spend passed count of the token to be spent from msg.sender account, but I do not understand the use of the 3rd and 4th parameter in ApproveAndCallFallBack function.

This is some vague understanding can someone explain what is exactly going on here.

Here is the link source code of contract which contains  these functions

https://theethereum.wiki/w/index.php/ERC20_Token_Standard


texts: Web3js works in my localhost NODE server but return an error in my remote webserver

texts:
All Web3js functions works correctly in my NODE (10.7.0) localhost server but the same configuration return the next error in my remote NODE webserver (same configuration and versions).
Any idea? Thnks
Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/home/nodejs/node_modules/web3-core-helpers/lib/errors.js:43:16)
    at XMLHttpRequest.request.onreadystatechange (/home/nodejs/node_modules/web3-providers-http/lib/index.js:95:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/nodejs/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/nodejs/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpRequestError (/home/nodejs/node_modules/xhr2-cookies/dist/xml-http-request.js:349:14)
    at ClientRequest.<anonymous> (/home/nodejs/node_modules/xhr2-cookies/dist/xml-http-request.js:252:61)
    at ClientRequest.emit (events.js:182:13)
    at TLSSocket.socketErrorListener (_http_client.js:382:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)


texts: Solidity compile Error: Expected primary expression. }

texts:
I'm trying to compile a contract in the solidity browser compiler
and get this error:

  Untitled:19:9: Error: Expected primary expression.
          }
          ^

Is this due to the throw; statement?

contract user {

    address public owner;

    function user(){
        owner = msg.sender;
        }

    function kill(){
        suicide(owner);
    }

    modifier onlyOwner{
        if (msg.sender != owner){
            throw;
        }else{
            -
        }
    }
}


texts: My purpose is to analyze some Ethereum transactions. Which is the best way to download the full blockchain on my machine, and which libraries do you recommend for interacting with it using Python? Thanks in advance.


texts:
I am trying to choose between Chainlink vs Oraclize. Can anyone advise the difference between both solution?

Nathan Aw


texts: How can I send ether or erc20 tokens right after incoming ether transaction?

texts:
maybe also how to develop a small application with the wanted functionality.....

I hope someone give me useful answer. Thanks


texts:
How to install remix-ide npm module? I follow the instructions, but it does not install.

npm install remix-ide -g
...

make: *** [Release/obj.target/scrypt/src/node-boilerplate/scrypt_params_async.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:200:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/remix-ide/node_modules/scrypt
gyp ERR! node -v v12.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1


texts: Geth private chain hashrate lower on higher versions


texts:
What is the best way to deal with decimals as I create a currency?

Let's use an example. I have KARLCOIN (KARL), and I have 1,000,000 of them, and the token has 6 decimals places. This token will also have a crowdfund where 100 KARL = 1 ETH ( 0.01 ETH / KARL).

When I create this contract, I should do something like:

// Constructor
 function token() {
    owner = msg.sender;
   totalSupply = 1000000;
  balances[owner] = totalSupply;
  decimals = 6;
  symbol = "KARL";
  }

And then that token also has a function to transfer.

Now, how am I calculating, transferring, and displaying these amounts?
For instance, 1,000,000 KARL is 1,000,000,000,000 of the smallest unit of my coin. Let's call it microKarl, or mk.

Does that mean the totalSupply in my constructor should actually be 1,000,000,000,000? When I transfer amounts to people, am I transferring it in mK? Basically the the amount of Karl * 1,000,000 to get it in to it's microKarl form? How will MyEtherWallet and MetMask and such know how to display the correct amount?

If I was using web3 to display it, I could just do the math and display it myself. Get the amount in mK, times it by 0.000001, and then be on my way. Right? Or am I off track here?

I made a token and did something like this (it's been a long night) and sent myself the tokens and in MetaMask it says the correct amount. On Etherscan it does not, it shows a much smaller amount, and also says the decimals are "18" when MetaMask grabbed them as 6 just by pasting the contract address in.

I'm just a bit confused on the decimalization of tokens and feel like I don't have the foundation of what I'm doing to debug this. Any clarity would be appreciated.


texts:
I used geth for windows and ran it as a desktop app. Not sure if I am connected to public blockchain or testnet. How do I check which network is getting synced. ?

(I want to download ropsten testnet blockchain in windows machine.  I clicked on geth exec file and geth started to download blocks. I am a beginner. Please help me with this)


texts: What does this mean: "It is not possible to enumerate storage from within a contract" (Solidity doc)?

texts:
In the Solidity docs section on memory, you find this paragraph (emphasis added):

  Each account has a data area called storage, which is persistent
  between function calls and transactions. Storage is a key-value store
  that maps 256-bit words to 256-bit words. It is not possible to
  enumerate storage from within a contract and it is comparatively
  costly to read, and even more to modify storage. A contract can
  neither read nor write to any storage apart from its own.

What is meant by the part in bold?


texts:
I am trying to get last synced block but it always 0.
So I have run
geth --syncmode fast -cache 4096 --rpc
Here is a logs

INFO [12-19|09:47:50.058] Imported new state entries               count=1920 elapsed=10.233ms  processed=95992059 pending=96261  retry=0   duplicate=1395 unexpected=4791
INFO [12-19|09:47:50.640] Imported new state entries               count=2303 elapsed=18.171ms  processed=95994362 pending=94952  retry=0   duplicate=1395 unexpected=4791
INFO [12-19|09:47:51.438] Imported new state entries               count=2303 elapsed=18.671ms  processed=95996665 pending=93400  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:52.352] Imported new state entries               count=2303 elapsed=13.482ms  processed=95998968 pending=91851  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:53.115] Imported new state entries               count=2304 elapsed=13.784ms  processed=96001272 pending=90126  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:53.828] Imported new state entries               count=2303 elapsed=20.514ms  processed=96003575 pending=88368  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:54.691] Imported new state entries               count=1535 elapsed=13.454ms  processed=96005110 pending=89066  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:55.340] Imported new state entries               count=768  elapsed=4.045ms   processed=96005878 pending=92124  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:55.796] Imported new state entries               count=768  elapsed=4.450ms   processed=96006646 pending=94755  retry=0   duplicate=1395 unexpected=4791
INFO [12-19|09:47:56.194] Imported new state entries               count=1150 elapsed=7.060ms   processed=96007796 pending=95778  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:56.935] Imported new state entries               count=2302 elapsed=15.676ms  processed=96010098 pending=94875  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:57.621] Imported new state entries               count=2304 elapsed=13.806ms  processed=96012402 pending=93302  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:47:58.482] Imported new state entries               count=2302 elapsed=18.590ms  processed=96014704 pending=91620  retry=0   duplicate=1395 unexpected=4791
INFO [12-19|09:47:58.980] Imported new state entries               count=2302 elapsed=15.170ms  processed=96017006 pending=89935  retry=0   duplicate=1395 unexpected=4791
INFO [12-19|09:47:59.764] Imported new state entries               count=1536 elapsed=12.661ms  processed=96018542 pending=89838  retry=0   duplicate=1395 unexpected=4791
INFO [12-19|09:47:59.810] Imported new block headers               count=1    elapsed=11.783ms  number=6914226 hash=854d8d…fab48e age=1m3s
INFO [12-19|09:48:00.193] Imported new state entries               count=1534 elapsed=9.662ms   processed=96020076 pending=89973  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:48:00.827] Imported new state entries               count=1536 elapsed=9.830ms   processed=96021612 pending=90680  retry=2   duplicate=1395 unexpected=4791
INFO [12-19|09:48:01.498] Imported new state entries               count=1918 elapsed=13.084ms  processed=96023530 pending=88465  retry=0   duplicate=1395 unexpected=4791

The logs says that the last block 6914226 is already synced. But when I trying to get last synced block via rpc I am getting 0

How can I solve this issue ?


texts: Getting error : Error encoding arguments: SyntaxError: Unexpected number in JSON at position 47

texts:
While developing a Smart Contract with Solidity on Remix, after creating the contract I'm trying to calling function setGrantAddress:

mapping (address => uint256) public balanceOf;
but when I call setGrantAddress for address ["0x14723a09acff6d2a60dcdf7aa4aff308fddc160c,"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"]

error as ---> transact to PublicAddress.setGrantAddress errored: Error encoding arguments: SyntaxError: Unexpected number in JSON at position 47.

Any idea how can I properly call setGrantAddress?

program code link:-Unable to input address[] parameter in remix


texts:
Hello Eth Stack Exchange,

I am practicing Solidity on Remix. This is actually the first language I have ever learned. In the contract below, I created a program to allow users to create dinosaurs and then fight them against one another.

I wanted to make the results of the fights (semi)random and in favor of the attacker, I tried to do that via this line of code in the fightDino function:  if (uint((keccak256(now)) % 100) > 40) {

Why is the compiler telling me "Operator % not compatible with types bytes32 and int_const 100"

Here is a copy of the whole contract.

pragma solidity ^0.4.25;

contract DinoFighter {

uint cooldownTime = 30 seconds;

struct Dino {
    string name;
    string color;
    uint readyTime;
    uint level;
    string status;
}

Dino[] public dinos;
mapping (uint => address) public dinoToOwner;

 modifier onlyOwner(uint _dinoId) {
     require(dinoToOwner[_dinoId] == msg.sender);
     _;
 }

function createDino(string _name, string _color) public {
    uint id = dinos.push(Dino("Velonica", "Brown", (now + cooldownTime), 0, "none")) - 1;
    dinoToOwner[id] = msg.sender;
}

function fightDino(uint _dinoId, uint _targetId) public onlyOwner(_dinoId) returns (string) {
    Dino storage myDino = dinos[_dinoId];
    Dino storage tDino = dinos[_targetId];
    if (uint((keccak256(now)) % 100) > 40) {
        myDino.level++;
        myDino.status = "king";
        tDino.readyTime = now + cooldownTime;
        tDino.status = "loser";
        return "Winner";
    }
    else {
        tDino.level++;
        tDino.status = "king";
        myDino.readyTime = now + cooldownTime;
        myDino.status = "loser";
        return "Loser";
    }

}
}


texts:
The voter can be registered only once but the code below registers more than one voter with same address
struct Voter {
       string name;
       uint8 age;
       bool voted;
       address voterID;
       bool voterRStatus;
    }
    Voter[] public voters;

    mapping(address => Voter) voter;

    function voterRegistration(string memory _name,uint8 _age) public {
        require(voter[msg.sender].voterRStatus == false);
        voters.push(Voter(_name,_age,false,msg.sender,true));
    }


texts: Is it possible to call the constructor function of an existing contract?

texts:
In theory, a constructor is just a function like any other function, but only gets called once at construction time. Because the EVM doesn't know the notion of a constructor, in theory, a constructor can be called multiple times in EVM Opcode terms. This could be a security leak as developers do not think that constructors are called multiple times. For example, the contract owner address could be overwritten then.

Is this possibility prevented and if so how?


texts:
I'm writing a smart contract (in solidity) that has to handle a function that creates arrays of x elements based on one array with n elements.

For the purposes of this example, I've experimented with arrays of 10 elements (uints) that I am looking for combinations that contain 8 elements. I would expect there to be 45 permutations.

The code (that works for 9 elements), generating 9 unique combinations of 8 elements, is utilising a fairly standard recursive algorithm, below:

function combinations(uint[] memory arr, uint len, uint8 startPosition, uint[8] memory result,address addressFrom) private {

 if (len == 0) {
     entry[addressFrom].push(result);
     return;
 }
 for (uint8 i = startPosition; i <= arr.length-len; i++){
     result[result.length - len] = arr[i];
     combinations(arr, len-1, i+1, result, addressFrom);
 }
}

The function populates a storage mapping entry. I assume I run out of stack space or run into gas limit issues with arrays of 10 or more (always looking for perms of 8 elements).

Is there a more efficient way of doing this or am I running up against computational limits in smart contracts?


texts:
I have this simple code:

function restart() public returns (uint256[] ) {
    uint256[] memory result = new uint256[](5);
    result[0] = 10;
    uint256[] memory result1 = new uint256[](5);
    result1 = result;
    result1[1] = 20;
    return result;
}

The result final value is : {10,20}. But I wanted for it to just be {10}. Is there a way to copy an array without being a pointer? I basically just want to create a "local" copy of result.
thank you


texts: Check if a mapped value for a struct exists

texts:
I have the following in my contract:
struct familyMember {
        bool isParent;
        string name;
        uint balance;
        bool active;
        uint spendLimit;
        address accountNumber;
    }

    mapping (address => familyMember) familyMembers;
    address[] public familyMemberAccounts;

I have the following function I want to use to check if a mapping exists for a given struct:
function checkFamilyMember(address _address) private view returns (bool) {
        bool familyMemberExists = false;
        if (bytes(familyMembers[_address].name).length != 0) {
            familyMemberExists = true;
        }
        return familyMemberExists;
    }

I don't think this is working as intended but am not sure how I can debug. I would normally use a console.log() but I dont think I can do this in Remix.
Is this a correct way to check if mapped struct exists or is there a better way? I did not see any recent answers (I am using version 0.8.0). This answer is 4 years old, so I wanted to know if there might be a new way.


texts: react-box call of create data function returns invalid address

texts:
error image indicates invalid address.  this is on the call of the function.  Ideas on why it fails?  i suspect i'm missing something simple.

Function:

createCredentialOrg(event){
    alert("Attempting Create");
    const credentialOrgFactoryContract = this.state.credentialOrgFactoryContract
    var checkBool = this.state.web3.isAddress(this.state.createCredentialOrgSchoolAddress)
    var a,b,c;

    if (checkBool){
      a = this.state.createCredentialOrgShortName;
      b = this.state.createCredentialOrgOfficialSchoolName;
      c = this.state.createCredentialOrgSchoolAddress

      alert(a);
      alert(b);
      alert(c);
      return credentialOrgFactoryContract.createCredentialOrg(a, b, c)
     .then(result => {
        alert(result);
        return credentialOrgFactoryContract.selectOrgCount()
     }).then ((result) => {
        alert(result)
        this.setState({credentialOrgCount: result.c[0]})

     })
   } else {
      alert("invalid address");
      alert(a);
      alert(b);
      alert(c);
   }
}


texts: How I add Security to the smart contract?

texts:
I deployed this contract and also interacted with it using ganache.

     pragma solidity ^0.4.0;
    contract Counter {
     int private count = 0;
     function incrementCounter() public {
      count += 1;
      }
      function decrementCounter() public {
    count -= 1;
      }
      function getCount() public constant returns (int) {
    return count;
      }
    }

However, when interacting with the contract, any account on Ganache can interact with it and use the function increment. How can I define only one account from Ganache to be able to change this function ?? I just wanna to add some security to the contract?

This is link for the smartcontract I follow: https://medium.com/crypto-currently/build-your-first-smart-contract-fc36a8ff50ca


texts: Compile error when trying to import web3.swift

texts:
I am trying to import web3swift into one of my Swift files, but get the compiler error "No such module 'web3swift'". The import statements look like this:

"Import Geth"
"Import web3swift"

In my pod file, I have:

pod 'web3swift', :git => 'https://github.com/MercuryProtocol/web3.swift.git', :branch => 'master'

I have also tried the following fix which hasn't worked:
=> In case you get no such module web3swift error
Go to “Build Settings”
Search “Framework Search Paths” (case sensitive)
Double click on
Click the “+”
Add $(SRCROOT) and set it to recursive


texts: Is there a performance penalty towards creating the maximum number of tokens with ERC-20 etc?

texts:
I saw this link:
Max possible ERC20 Tokens allowed with 18 decimals?

Is there a performance penalty for creating so many tokens? Obviously the number of storage capacity needed for mining will be intense the more tokens are mined? Anyone knows the answer?


texts:
I'm running the go-ethereum node with geth on my server. It sync the blocks in the beginning smoothly but after some time it stuck on a block from last two days. Any help will be appreciated.

eth.blockNumber:

{"jsonrpc":"2.0","id":83,"result":"0x424686"}

eth.syncing:

 {"jsonrpc":"2.0","id":83,"result":{"currentBlock":"0x424686","highestBlock":"0x4417ca","knownStates":"0x23c865","pulledStates":"0x23c865","startingBlock":"0x424686"}}


texts: Soldity RNG threat comparison between Tron and Ethereum

texts:
Would a function such as the following:

function random(bytes32 seed) internal returns (uint) {
  nonce++;
  return uint(keccak256(abi.encodePacked(now, msg.sender.balance, nonce, block.coinbase, gasleft(), blockhash(block.number - 1), seed))) % 99; }

would such a function be vulnerable to RNG attacks on a DPoS network such as Tron? if so how?


texts: Someone Can Help Me With This Warning Error! It Stuck My code

texts:
I'm trying to create an ERC20 token and if someone sends ether to this contract, contract will send equivalent tokens to the calling address.

Code:::

pragma solidity ^0.6.6;

import "./new1ERC20.sol";

  contract ConfigureERC20 is new1ERC20 {

     uint256 tokenPrice = 500000000000000 wei;
     uint256 public tokensToGet = 0;

     fallback() external payable {
        require(msg.value > 0);
     //   require(tokensRemaining > 0);
        tokensToGet = msg.value / tokenPrice;

        //_balances[] = balances[fundsWallet] - amount;
        //_balances[msg.sender] = _balances[msg.sender].add(balance);
        emit Transfer(address(this), msg.sender, tokensToGet);
        msg.sender.transfer(tokensToGet);
    }
}

Thanks!


texts: Ethereum and child chains like NXT/Ardor?

texts:
Doing some research on how we can implement this type of system with ethereum smart contracts.

Currently the upcoming Nxt/Ardor system implements a child chain system where the main chain deals with finding of the blocks while the child chain does the collection of the transactions and paying for the fees by the child chain genesis account.

Take for example if we were to create a blockchain just to sell concert tickets, each user would currently need to pay "ether" to send these concert tickets to another user. But how would one create a similar system to Ardor where there is a parent and child chain?


texts:
a bit of overview:

I'm in the process of learning ethereum, and am using geth (1.4.10). following some examples, I am able to launch a web page using web3. my directives in geth was to start it with rpc command.

some issues I'm running into

1. the web app states that my account is locked
2. when I launch geth with the rpc directive, even if I provided the console directive it does not give me an interactive console to perform this unlock
3. neither does a new console (using geth attach) allow me to unlock it
4. I can't perform truffle migrate as well due to the same issue

hopefully someone here can help me to resolve this.

as mentioned in some of my comments, it's not necessarily a duplicate since there was no mention of a specific version, although there was a tip which I'll follow up on later.


texts: How to fix Data location must be "memory" for return parameter in function, but none was given.?

texts:
pragma solidity >= 0.5.0 < 0.7.0;

contract Adoption {
  address[16] public adopters;
 function getAdopters() public view returns(address[16]) {
   return adopters;

 }
 function adopt(uint petId) public returns(uint) {
   require(petId>=0 && petId<=15,"oops");
   adopters[petId] = msg.sender;
   return petId;

 }

}

The above script is showing me the below errors.

1.address[16] used in line 5 shows

Data location must be "memory" for return parameter in function, but none was given.

What is the fix?


texts: What is the difference between Denial of Service (DoS) and mishandled Exception?

texts: As per my understanding both the DoS DoS Example and Mishandled exceptions occur when the receving contract uses revoke. In case of mishandled exception we don't handle the exception by checking the return values. In case of DoS also we don't handle the exception using the return values, then what is the difference between DoS and unhandled or mishandled exception? If we don't handle the recepient's exception by checking the return values, and instead we use try-catch block what is effect on mishandled exception and DoS in case of 'call', 'send' and 'transfer'?


texts: Truffle Console: Estimate Gas Cost of a function

texts:
I checked the following link:
how to estimate gas cost?
My contract is:
pragma solidity ^0.5.1;
contract TransferGC{
   uint public testVal = 97 ether;
   function testFunc(address payable addr) public returns (uint) {
      addr.transfer(testVal);
      return testVal;
   }
   function deposit() payable public{}
}

I did the following:
TGC = await TransferGC.at('0xE4F90Ef2e5815cf24eea956b1f5781601859cb90')
truffle(development)> await web3.eth.getGasPrice()
'20000000000'
await TGC.testFunc('0x3e1D6ef576d19A6D28f3755acDb754E37aFe6E4A').estimateGas(1)

I am getting the following error:

Thrown: TypeError: TGC.testFunc(...).estimateGas is not a function

Somebody please guide me.
Zulfi.


texts: Convert an hexadecimal string to bytes in pure Solidity

texts:
I am using Oraclize to recover a signature from a website. When I have it, I have to check if the address who signed it is correct. To do that, I would use ECRecovery from Zeppelin.

The signature returned by Oraclize is a hexadecimal string like this

0xaca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf200

Though, recover expects the signature being a 65-bytes long bytes.

Is there any way to do the conversion in Solidity?

Thanks so much in advance.


texts: ERR_CONNECTION_REFUSED when connecting to remote node

texts:
I'm getting a ERR_CONNECTION_REFUSED error when connecting to my remote geth node with

web3 = new Web3(new Web3.providers.HttpProvider("http://"+RPCIP+":"+RPCPort));

and  web3.min.js which is included via:

<script src="./source/js/web3.min.js"></script>

the node is running with:

./root/go-ethereum/build/bin/geth --light --cache 4096 --rpc --rpcaddr "XXX.XXX.XXX.XXX" --rpcport XXXX --rpccorsdomain "*" --rpcapi "eth,web3,net"

it works when working with node.js but doesn't with the js file. How can I fix that?


texts: I am trying to launch GETH with --verbosity 4, however it says that it is not a valid argument. geth help shows that the --verbosity option is there, but when I try to run it, it does not work. It returns error of "flag provided but not defined -verbosity"


texts: ethereum on Amazon AWS - how to connect two mining peers?

texts:
I'm currently trying to setup an ethereum private chain on AWS EC2 instances. Unfortunately, the nodes in this network fail to connect to each other over the ethereum P2P protocol.

My question is: what am I missing?

Here is a list of configuration patterns, which I tried and which did not work. Any hint what else I could try or how to fix one of these patterns?

basic structure of the network

three EC2 instances, each with a private and a public ip address
one instance (the bootnode) running the RCP server on port 8000, mining disabled, private --networkid, --nat "none", --port 30304
two instances (the mining nodes) with mining enabled, private --networkid, --nat "none", --port 30304
the three nodes belong to the same security group, traffic (tcp and udp) between nodes in this security group is unrestricted

doesn't work: use --bootnodes with private ip address of  the bootnode

start the mining nodes with --bootnodes "enode://enode-of-bootnode@private-ip-of-bootnode:30304"
admin.peers replies [] on both mining nodes

doesn't work: use --bootnodes with public ip address of  the bootnode

start the mining nodes with --bootnodes "enode://enode-of-bootnode@public-ip-of-bootnode:30304"
admin.peers replies [] on both mining nodes

doesn't work: addPeer() with private ip address of  the bootnode

start the mining nodes without --bootnodes
admin.addPeer("enode://enode-of-bootnode@private-ip-of-bootnode:30304") on both mining nodes
admin.peers replies [] on both mining nodes

doesn't work: addPeer() with public ip address of  the bootnode

start the mining nodes without --bootnodes
admin.addPeer("enode://enode-of-bootnode@public-ip-of-bootnode:30304") on both mining nodes
admin.peers replies [] on both mining nodes

doesn't work: explicitly add mining peers

start the mining nodes without --bootnodes and with --nodiscover
admin.addPeer("enode://enode-of-mining-0@private-ip-of-mining-0:30304") on mining 1
admin.addPeer("enode://enode-of-mining-1@private-ip-of-mining-1:30304") on mining 0
admin.peers replies [] on both mining nodes

Dito, if private-ip-of-mining-{0,1} is replaced wit public-ip-of-mining-{0,1}


texts: How does a wallet make sure that it restores all the keys from mnemonic phrases?

texts:
I am building a wallet that complies with BIP32, BIP39, BIP44, and EIP55.

It should be easy to restore keys if a wallet owner generates keys in sequence, but in my understanding, they can create a parent key and then derive a child key of it from anywhere in the tree structure.

Then how do we make sure that we restore all the keys?

Should we traverse the tree, check the balance of each address and then generate keys for the ones with some ETH(or tokens) in them?

My concern is that some people might own an address with zero balance after some transactions though. In this case, should we check transactions for all the addresses and then generate keys accordingly?

This process doesn’t seem to be beautiful and I might have some wrong assumptions here. I’d appreciate it if you could let me know the best practice. If there were any library that can help me to implement this, that even better.


texts: Can an ERC20 Smart Contract prevent a wallet from holding more than a certain amount?

texts:
I'm looking into a bit of functionality for an ERC20 smart contract token that would prevent any one wallet to hold more than X percent of the token.  Couple of questions:

Is it possible?
Is it technically advisable?
Any gotchas or considerations?
What would the API look like?


texts: Is it possible to execute a smart-contract function at the next (or other block) number?

texts:
I simply need a function to be executed not at the block number when the function is initiated but to wait for any of the next block numbers.
I can do this with a require, where person executes the function twice. First time it records the current block number, second time it confirms that it is the next block number. However, this is confusing, annoying, and takes extra gas money.
What I want to accomplish is a pause, which (unless I am wrong) does not exist with solidity.
However, if pause does exist, I do not need seconds, just the block number instead.


texts:
I have this contract:
pragma experimental ABIEncoderV2;

contract Ballot {
    constructor(string[] memory proposalNames) public {...}
}

I tried:
pragma solidity >=0.4.25 <0.6.0;
pragma experimental ABIEncoderV2;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/voting.sol";

contract TestVoting {
    function testCounter() public {
        Ballot myContract = new Ballot(["foo", "bar"]);
    }
}

I got an error:
TypeError: Invalid type for argument in function call. Invalid implicit conversion from string memory[2] memory to string memory[] memory requested.
        Ballot myContract = new Ballot(["foo", "bar"]);

How do I fix it?


texts: Android Geth failed to connect to main net

texts:
Following the Android sample code from Mobile Client, along with latest geth.aar fetched from Go Ethereum Downloads (stable release 1.7.3 and development release 1.8.0). I am not able to connect to main net with either of the release. On Android display all I see is:

My name: GethDroid/v1.8.0-unstable/android-arm64/go1.9.2
My address: [::]:40039
My protocols: [les]

Latest block: 0, syncing...

Tested on Nexus 5X (Android 8.1.0, API 27).

Did I miss something?


texts:
I have seen a lot of discussions about presale wallets, but have no idea what it means.

What do the terms "presale" and "presale wallet" mean in Ethereum?


texts: Peer Discovery in PoA with Containers with dynamic IPs

texts:
I have a small PoA network setup in Docker containers locally and, for the most part, have the bootnode and peer discovery pieces working. I'm running into trouble when my mining containers reload (for whatever reason) and subsequently come up on a new IP.
On launch, the containers lookup the bootnode IP and then start geth, but the miners fail to find any peers. Looking at verbose logs, it seems like the nodes are trying to re-connect to the peers that they were originally connected to, but fail because those IPs are no longer listening.
It seems like the miners try to drop the connections, but they never establish peer relationships with the newly rolled miners.
Any ideas? I've trolled through documentation and nothing has stood out so far.
From continued reading, I think I can draw conclusions from this line in go-ethereum's nodedb library https://github.com/ethereum/go-ethereum/blob/f79cce5de98332e6d54eb298fce85c69d1082ee2/p2p/enode/nodedb.go#L59.
I'll try turning that value way down (to like 10 minutes) and seeing if that helps me.


texts:
When the sendTransaction is executed , it returns insufficient funds at Object.n [as throwError] (ethers.min.js:1)
    at ethers.min.js:1
    at tryCallOne (core.js:37)

import { Wallet, providers, getDefaultProvider } from "ethers";

transactionData={ to: "0xdfa7E6962d65870F34388E12fF1380e66c1F8c47"
 value: 1000000000000
 gasLimit: 21000
 gasPrice: 8000000000
 data: ""}

let wallet = new Wallet(privateKey, getDefaultProvider('mainnet'));
 wallet.sendTransaction(transactionData);


texts: Does receiving a transaction receipt guarantee the transaction will be executed?

texts:
As the question says -
Does receiving a transaction receipt guarantee the transaction will be executed, assuming the transaction has a reasonable gas price, there are few enough transactions with a low enough gas price ahead that the transaction isn't forgotten, and the miners don't conspire not to mine said transaction?


texts: Why is the code on a contract address different from the compiled code?

texts:
There seem to be clear differences between the hex that the solidity compiler spits out and the hex that is displayed by eth.getCode() after you have published the contract.

for example the original output starts with ('|' used do delineate the differences)

60606040523|4610000575b61116b806100196000396000f30060606040523|61561006b576000357c010

whereas the submitted contract starts with a shortened

6060604052361561006b576000357c010

Does anyone know what causes this discrepancy?


texts: Web3 Eth SendTransaction without fixed value

texts:
I'm trying to make a button on my website which allows people to send Ethereum to a specified address. Once clicked, it should for example pop up a MetaMask window where the user can enter the amount of Eth (and optionally fees) and only needs to click send to make the transaction.
However, as far as I understand the function web3.eth.sendTransaction needs to have already a specified amount of Eth in the value field, or otherwise the amount will simply be 0 and you can't change it anymore. Is there a solution to this?

I already managed to create a button with fixed amounts of Eth, however I'm struggling with a solution where the amount is variable and the user can decide how much he wants to send.

Another idea that I had would be to add a textbox/number box where the user can enter his desired amount of Eth that he wants to send, and to use that in the value field. However, that is above my current knowledge, if anyone would be willing to help me to find a solution, I would be very happy.

Thank you


texts: can we create our own cryptography system and use it with ethereum or hyperledger fabric frameworks?

texts: i have a project where we have to build a fuzzy encryption for biomedical data like DNA and use it on blockchain for storage. So is it possible to create our own cryptography scheme on Ethereum and hyperledger ? if it's possible can you give me somewhere to start from. I'm totally new with blockchain implementations, i have just some knowledge in the theorical part. Thank you