2

I am using this code below and I got an error:

await web3.eth.getTransactionReceipt(this.state.transactionHash, (err, txReceipt)=>{
          console.log(err,txReceipt);
          this.setState({txReceipt})
        }); //await for getTransactionReceipt

        await this.setState({transactionHash: this.state.txReceipt.transactionHash});
        await this.setState({blockNumber: this.state.txReceipt.blockNumber});
        await this.setState({gasUsed: this.state.txReceipt.gasUsed});    

The error is:

MetaMask - RPC Error: invalid argument 0: json: cannot unmarshal non-string into Go value of type common.Hash

Can you please tell me how to solve this error?

  • Which version of web3 are you using? What is the value of transactionHash? – Ismael Mar 18 at 22:53
  • I am using web3@1.2.6 and the value of transaction hash is '0x29c680fb90517d2611eb8856b8ce6f645574a9dad77584c21b76a052a2d6e1d8' – Ahmed Mar 19 at 5:19
  • I'd suggest trying different versions of web3, like 1.2.5, 1.2.4 or similar. And create an issue for web3 developers with a reproducible case. – Ismael Mar 19 at 12:55
  • @Ismael I have tried 1.2.4 and 1.2.5 versions , still give me same error. – Ahmed Mar 21 at 5:41
  • Sorry but I'm not able to test because the hash doesn't exist in a public blockchain. Similar error happened to me and it was a bug inside web3, so it doesn't have a workaround. Create a reproducible test and report as an issue or debug it and report your findings – Ismael Mar 21 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.