Transactions

無法使用 Etherscan ABI 解碼輸入

  • March 10, 2022

我正在查看呼叫智能合約的交易的輸入,但我無法理解它。這個特定的樣本在 FTM 上,但我假設 ETH 的行為沒有區別?

考慮這個交易:https ://ftmscan.com/tx/0x6f9df515d75e9f0444ec2388d4c880b668d71c37ddd673a82941cdae39cac0a9

輸入0x42d8669300000000000000000000000088367cd6c890fc38ee3ec5a7b9baf71ef8ab6972意味著方法簽名是0x42d86693.

現在,查看 ftmscan 上已發布的 ABI 以了解與此交易互動的智能合約,我可以看到其原始碼標記為已驗證,它提供了 ABI,複製如下

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum Tangle.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"indexed":false,"internalType":"struct Tangle.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"_init","type":"address"},{"indexed":false,"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"DiamondCut","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum Tangle.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"internalType":"struct Tangle.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"internalType":"address","name":"_init","type":"address"},{"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"diamondCut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_functionSelector","type":"bytes4"}],"name":"facetAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"facetAddresses","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_facet","type":"address"}],"name":"facetFunctionSelectors","outputs":[{"internalType":"bytes4[]","name":"","type":"bytes4[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"facets","outputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"internalType":"struct Tangle.Facet[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

奇怪的是 (?) ABI 中的所有函式都與輸入欄位 ( 0x42d86693) 中的簽名不匹配。

實際上,如果我使用https://lab.miguelmota.com/ethereum-input-data-decoder/example/通過 ABI 對輸入進行解碼,則無法對其進行解碼。根據https://4byte.directory這個方法是withdrawRewards(address),而且似乎是有道理的,但契約中沒有這樣的功能?

我還使用 獲取了字節碼的副本web3.eth.getCode,並使用 對其進行了反編譯https://ethervm.io/,看起來 ftmscan 上發布的 ABI 確實與字節碼匹配。

任何人都可以幫助闡明這裡發生的事情嗎?如何在0x42d86693看似沒有具有所述簽名的功能的契約上呼叫具有簽名的功能?

謝謝!

在您的契約中沒有任何withdrawRewards(地址)函式,但您正在呼叫不存在的函式,然後將執行回退函式。在此契約回退函式中,委託呼叫其他契約,這就是您無法解碼輸入的原因,因為輸入解碼器可以’不知道其他合約 ABI。

引用自:https://ethereum.stackexchange.com/questions/123489