繁体   English   中英

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

[英]web3.eth.getTransaction with ganache-cli gives chainId error

当 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.” 其他 web3 调用工作正常。 这就是我调用 web3 函数来获取交易的方式

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

这就是我运行 ganache 的方式

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

我见过其他人有这个问题,这是一个 ganache 问题,但没有一个解决方案对我有用,我还没有看到 eth_getTransactionByHash 的问题。 我试过传递一个链 id 但是也没有做任何事情。 谢谢!

将“gasPrice”:w3.eth.gas_price 添加到 buildTransaction 函数并在 ganache 服务器设置中更改为 1337 chainID。

交易 = 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