简体   繁体   English

带有 ganache-cli 的 web3.eth.getTransaction 给出了 chainId 错误

[英]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."当 ganache 调用 eth_getTransactionByHash 时,我收到此错误 - “UnhandledPromiseRejectionWarning: E​​rror: 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.其他 web3 调用工作正常。 This is how I'm calling the web3 function to get a transaction这就是我调用 web3 函数来获取交易的方式

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 的方式

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.我见过其他人有这个问题,这是一个 ganache 问题,但没有一个解决方案对我有用,我还没有看到 eth_getTransactionByHash 的问题。 I've tried passing a chain id however that hasn't done anything either.我试过传递一个链 id 但是也没有做任何事情。 Thanks!谢谢!

add "gasPrice": w3.eth.gas_price, to the buildTransaction function and change to 1337 chainID in ganache server settings.将“gasPrice”:w3.eth.gas_price 添加到 buildTransaction 函数并在 ganache 服务器设置中更改为 1337 chainID。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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