[英]web3.eth.getTransaction with ganache-cli gives chainId error
當 ganache 調用 eth_getTransactionByHash 時,我收到此錯誤 - “UnhandledPromiseRejectionWarning: Error: 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.