You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to obtain estimate gas for an erc20 token contract deployed over kovan network, just like this:
var getCode = web3.eth.getCode(tokenAddress)
var transactionObject = {
from: address,
to: tokenAddress,
value: web3.utils.toWei(data.value.toString()),
data: getCode
}
web3.eth.estimateGas(transactionObject)
The response:
Unhandled rejection Error: Returned error: Transaction execution error. at Object.ErrorResponse (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-core-helpers/src/errors.js:29:16) at /Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-core-requestmanager/src/index.js:137:36 at XMLHttpRequest.request.onreadystatechange (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/src/index.js:64:13) at XMLHttpRequestEventTarget.dispatchEvent (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:64:18) at XMLHttpRequest._setReadyState (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:354:12) at XMLHttpRequest._onHttpResponseEnd (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:509:12) at IncomingMessage.<anonymous> (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:469:24) at emitNone (events.js:110:20) at IncomingMessage.emit (events.js:207:7) at endReadableNT (_stream_readable.js:1059:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickDomainCallback (internal/process/next_tick.js:218:9)
The text was updated successfully, but these errors were encountered:
I think the error might have more to do with your transaction object specifically the value: web3.utils.toWei(data.value.toString())
the toWei function is to convert any number in ether to wei. But the data.value.toString() returns a string type which will cause an error in your transaction object , try to return a number instead of a string.
I'm trying to obtain estimate gas for an erc20 token contract deployed over kovan network, just like this:
The response:
Unhandled rejection Error: Returned error: Transaction execution error. at Object.ErrorResponse (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-core-helpers/src/errors.js:29:16) at /Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-core-requestmanager/src/index.js:137:36 at XMLHttpRequest.request.onreadystatechange (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/src/index.js:64:13) at XMLHttpRequestEventTarget.dispatchEvent (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:64:18) at XMLHttpRequest._setReadyState (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:354:12) at XMLHttpRequest._onHttpResponseEnd (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:509:12) at IncomingMessage.<anonymous> (/Users/rstorm/repos/audity/checkBalances/node_modules/web3/packages/web3-providers-http/node_modules/xhr2/lib/xhr2.js:469:24) at emitNone (events.js:110:20) at IncomingMessage.emit (events.js:207:7) at endReadableNT (_stream_readable.js:1059:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickDomainCallback (internal/process/next_tick.js:218:9)
The text was updated successfully, but these errors were encountered: