web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Invalid bytes string given: 0x when using self hosted geth node

Open joeneldeasis opened this issue 7 years ago • 4 comments

Description

We always encounter this error Invalid bytes string given: 0x when performing using our self hosted geth node, but this error is not present when we are using Infura.

Expected behavior

Using Infura the value of bytes on web3-eth-abi.cjs.js line 66 is 0x000000000000000000000000000000000000000000000000006a94d74f430000 and we're able to get the current balance of the erc20 token

Actual behavior

With our self hosted geth, the value of bytes we get is: 0x which causes this error Invalid bytes string given: 0x

Steps to reproduce the behavior

Use this gist which performs balance checking of the erc20 token https://gist.github.com/joeneldeasis/4b72f1923e3a4bdfc356148a79257ede then change the provider to your own Geth node which the error occurs, this code only works when you are using Infura.

Error Logs

Error: Invalid bytes string given: 0x
    at AbiCoder.decodeParameters (Z:\xxxxxx\node_modules\web3-eth-abi\dist\web3-eth-abi.cjs.js:66:15)
    at AbiCoder.decodeParameter (Z:\xxxxxx\node_modules\web3-eth-abi\dist\web3-eth-abi.cjs.js:55:19)
    at CallContractMethod.afterExecution (Z:\xxxxxx\node_modules\web3-eth-contract\dist\web3-eth-contract.cjs.js:743:28)
    at CallContractMethod._callee$ (Z:\xxxxxx\node_modules\web3-core-method\dist\web3-core-method.cjs.js:354:35)
    at tryCatch (Z:\xxxxxx\node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:40)
    at Generator.invoke [as _invoke] (Z:\xxxxxx\node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as next] (Z:\xxxxxx\node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:114:21)
    at asyncGeneratorStep (Z:\xxxxxx\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)
    at _next (Z:\xxxxxx\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Gists

Versions

  • web3.js: 1.0.0-beta.48
  • nodejs: v10.15.3
  • browser: Brave Version 0.61.51 Chromium: 73.0.3683.75 (Official Build) (64-bit)
  • ethereum node: 1.8.23-stable-c9427004

joeneldeasis avatar Mar 15 '19 10:03 joeneldeasis

May be the two issue linked #2499 ? @nivida

russanto avatar Mar 15 '19 20:03 russanto

I've tested it on different nodes with calling the balanceOf directly after the deployment and with a already deployed contract and couldn't reproduce this behavior. There is already an open issue in the infura repository (https://github.com/INFURA/infura/issues/157) about this. I'will close this issue and will watch the issue of infura.

@russanto I will test your issue asap.

nivida avatar Mar 18 '19 11:03 nivida

I've tested it on different nodes with calling the balanceOf directly after the deployment and with a already deployed contract and couldn't reproduce this behavior. There is already an open issue in the infura repository (INFURA/infura#157) about this. I'will close this issue and will watch the issue of infura.

@russanto I will test your issue asap.

Hi @nivida this issue only occurs on GETH nodes and it is working fine with INFURA. By the way, have you tried the gist that I've provided? Upon testing the issue still persist on beta 50. Thanks

joeneldeasis avatar Mar 22 '19 07:03 joeneldeasis

I'm having this issue too.

UnhandledPromiseRejectionWarning: Error: Invalid bytes string given: 0x at AbiCoder.decodeParameters (/home/api/src/node_modules/web3-eth-abi/dist/web3-eth-abi.cjs.js:64:15) at AbiCoder.decodeParameter (/home/api/src/node_modules/web3-eth-abi/dist/web3-eth-abi.cjs.js:55:19) at CallContractMethod.afterExecution (/home/api/src/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:727:28) at CallContractMethod._callee$ (/home/api/src/node_modules/web3-core-method/dist/web3-core-method.cjs.js:101:35) at tryCatch (/home/api/src/node_modules/regenerator-runtime/runtime.js:45:40) at Generator.invoke [as _invoke] (/home/api/src/node_modules/regenerator-runtime/runtime.js:271:22) at Generator.prototype.(anonymous function) [as next] (/home/api/src/node_modules/regenerator-runtime/runtime.js:97:21) at asyncGeneratorStep (/home/api/src/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24) at _next (/home/api/src/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9) at process._tickCallback (internal/process/next_tick.js:68:7) (node:9990) 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:9990) [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.

tgreco avatar Mar 26 '19 01:03 tgreco