简体   繁体   中英

web3.eth.getTransaction with ganache-cli gives chainId error

When ganache calls eth_getTransactionByHash I get this error - "UnhandledPromiseRejectionWarning: Error: Incompatible EIP155-based V 1 and chain id 1. See the second parameter of the Transaction constructor to set the chain id." Other web3 calls are working fine. This is how I'm calling the web3 function to get a transaction

web3.eth.getTransaction('<txn-hash>')
  .then(result => {
    console.log('result: ', result);
  }).catch(err => {
    console.log('error: ', err);
  })

and this is how I'm running ganache

ganache-cli --fork https://mainnet.infura.io/v3/<project-id>

I've seen other people having this issue and it's a ganache issue but none of the solutions worked for me and I haven't seen it for eth_getTransactionByHash. I've tried passing a chain id however that hasn't done anything either. Thanks!

add "gasPrice": w3.eth.gas_price, to the buildTransaction function and change to 1337 chainID in ganache server settings.

transaction = SimpleStorage.constructor().buildTransaction( { "chainId": chain_ID, "from": my_address, "nonce": nonce, "gasPrice": w3.eth.gas_price, } )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM