我在估计天然气时遇到了麻烦,用我在kaleido部署的合同中的一种方法。
我已经通过Remix成功地部署了合同。此外,从Remix,我可以调用我的所有方法,他们的工作正常。在web3js中,我实例化了它,我可以从web3js (1.0.0-beta.47)中检查我的帐户的余额,但是当估计调用契约方法之一的气体时,我得到的错误是“方法eth_chainId不存在/不可用”。
守则:
const provider = new Web3.providers.HttpProvider("https://<USER>:<PASS>@<NODE RPC ENDPOINT>");
const web3 = new Web3(provider);
const deploy = web3.eth.accounts.privateKeyToAccount(<ACCOUNT PRIVATE KEY>);
const contract = new web3.eth.Contract(contractAbi, contractAddress, { gasPrice: 1, gas: 4500000 });
var estimatedGas = await contract.methods.myMethod().estimateGas({ from: deploy.address });
错误:
Error: Node error: {"code":-32601,"message":"The method eth_chainId does not exist/is not available"}
知道是怎么回事吗?
发布于 2019-03-06 08:34:34
我已经检查了kaleido支持,似乎您必须使用web3js 1.0.0-beta.38才能使它工作。
发布于 2019-04-11 10:29:24
这是在Ganache中的一个bug (或者一个缺失的特性,我不确定)。这个问题在这里被跟踪:https://github.com/trufflesuite/ganache-core/issues/339
在这一问题得到解决之前,您需要一直降级到beta.38
发布于 2019-06-19 07:24:24
我使用web3js 1.0.0-beta.36来解决这个错误。
https://ethereum.stackexchange.com/questions/67952
复制相似问题