错误:无法使用getReverReason()解码还原原因



我试图理解为什么通过使用eth-revert-reason的getReverReason()来恢复以太坊交易。我第一次尝试用他们的例子是:

console.log(await getRevertReason('0x6ea1798a2d0d21db18d6e45ca00f230160b05f172f6022aa138a0b605831d740'))

但是我得到了错误&;await只在async函数&;中有效。当我尝试在async函数中运行它时,如下所示:

const Web3 = require("web3");
const ethers = require('ethers');
const getRevertReason = require('eth-revert-reason');
const txHash = '0x6ea1798a2d0d21db18d6e45ca00f230160b05f172f6022aa138a0b605831d740'
// Failed with revert reason "Failed test"
async function reason() {
await getRevertReason(txHash)
}
console.log(reason())

我总是得到相同的结果,不管事务哈希:

Error: Unable to decode revert reason.

你能帮帮我吗?

作者已经两年没有更新了。我已经在这个项目的基础上更新了,但是我没有考虑其他的网络。如果您有任何问题,请告诉我,我会及时更新。(请原谅我做得不好,这是第一次尝试做包)详细信息请参见https://www.npmjs.com/package/revert-reason或https://github.com/LAMOUR0913/revert-reason.git;

最新更新