一直在努力寻找一种方法来估计气体的调用函数。我得到了错误-- Error: VM Exception while processing transaction: revert在ganache上本地,Error: The execution failed due to an exception.在Kovan上。
下面是一个示例可靠性函数:

这就是我的代码的样子:
sig := []byte("withdraw(address)")
methodID := crypto.Keccak256(sig)[:4]
toAddress := common.HexToAddress(myAddr)
paddedAddress := common.LeftPadBytes(toAddress.Bytes(), 32)
var data []byte
data = append(data, methodID...)
data = append(data, paddedAddress...)
sendTo := common.HexToAddress(myAddress)
callMsg := ethereum.CallMsg{
From: Wallet.Address,
To: &sendTo,
Gas: 0,
GasPrice: big.NewInt(0),
Value: big.NewInt(0),
Data: data,
}
gasAmount, err := eth.EthClient.EstimateGas(context.Background(), callMsg)为什么我在处理事务时得到抱怨错误: VM异常:还原
发布于 2020-08-14 05:46:06
下面是我如何解决这个问题的方法:
var iargs []interface{}
iargs = append(iargs, "0x...") //fill out your arguments
input, err := Abi.Pack("withdraw", iargs...)
sendTo := common.HexToAddress(myAddress)
callMsg := ethereum.CallMsg{
From: Wallet.Address,
To: &sendTo,
Gas: 0,
GasPrice: big.NewInt(0),
Value: big.NewInt(0),
Data: input,
}
gasLimit, err := eth.EthClient.EstimateGas(context.Background(), callMsg)https://ethereum.stackexchange.com/questions/86646
复制相似问题