获取从以太坊交易中调用的 `functionName`

Get the `functionName` called from an ethereum transaction

我想显示以太坊交易并包括调用的 methodName。例如,此交易的方法是 mint。在 etherscan 或 alchemy 或 infura 中是否有 API 端点 returns 此信息?

Etherscan documentation for transactions doesn't include it. Neither does alchemy's getTransactionReceipt (docs).

Etherscan 和其他区块链浏览器使用他们自己的自定义 key-value 函数选择器数据库到他们的名字,不可用 通过网站 API,也不JSON RPC API(或其包装器,例如 web3ethers.js)。

他们收集了来自验证过程的合同源代码和 ABI,允许他们翻译一个 函数选择器,可通过 RPC 方法 getTransaction 字段 data(例如0xa0712d68)到函数定义(例如mint(uint256)),然后简单地将其转换为human-readable格式:Mint.

如果您想将函数选择器翻译成函数名称,您需要构建自己的字典,或者使用少数几个具有已填充数据库的可用在线工具之一,例如 this one.