Hot answers tagged

2

Regarding how you can wait until the tx receipt is ready bellow I wrote an example of how: const balance = contractInstance.methods.balanceOf(walletAddress).call(function(err, result) { ... web3.eth.getTransactionCount(fromAddress) .then((count) => { let rawTransaction = { 'from': fromAddress, 'gasPrice': web3.utils.toHex(10 * 1e9), ...


2

With web3.js v1.2.x, you can use function web3.eth.abi.encodeFunctionSignature: const selector = web3.eth.abi.encodeFunctionSignature({ type: "function", name: yourObj.funcName, inputs: yourObj.params.map(param => ({type: param})) }); Or simply: const selector = web3.eth.abi.encodeFunctionSignature("getSupplyRate(address,uint256,uint256)"); ...


1

Change this: let transaction = new Tx(rawTransaction) transaction.sign(keys[k]) web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex')) ... To this: web3.eth.accounts.signTransaction(rawTransaction, privateKey).then(signedTx => { web3.eth.sendSignedTransaction(signedTx); ... })


1

Transaction was failing because of fixed gasLimit : 37000. Gas depends on what the function is doing. For example, it is more expensive to set a zero-value storage value to non-zero, than it is to set a non-zero storage value to another non-zero storage value. In my case it was because of SSTORE opcode as it takes 20000 when storage value is set to non-...


Only top voted, non community-wiki answers of a minimum length are eligible