https://github.com/poanetwork/blockscout/pull/1059 added a beautiful feature that allows the decoding of the transaction input given a verified smart contract. We would love to use that feature as well, however most of our contracts are using the proxy pattern:
https://blog.zeppelinos.org/proxy-patterns/
Thus we would like to either get guidance on how we could implement this or feature request something along those lines. Unfortunately, it is not clear to me that there is a way to actually do that easily. The only way I could see this work is for Blockscout to somehow understand that at address X, there is a proxy contract, get the logic contract address Y by querying the proxy and then use the logic contracts ABI to decode the transaction input.
Hey Blockscout Team, thank you for considering this issue. We were just wondering if you had any information on whether we could possibly expect this anytime soon. Not that we expect you to do it, just to give ourselves some planning certainty
Hey Blockscout Team, thank you for considering this issue. We were just wondering if you had any information on whether we could possibly expect this anytime soon. Not that we expect you to do it, just to give ourselves some planning certainty
Sure, we'll take care of it. Thanks for pinging.
@nambrot there is no standard way to define proxy contracts (naming etc). so I don't think that we can create a common way to decode proxy contracts
btw you can use verified implementation contract address to read the contract. For example, here is a proxy contract - https://blockscout.com/poa/dai/address/0x7301cfa0e1756b71869e93d4e4dca5c7d0eb0aa6/read_contract
its implementation - https://blockscout.com/poa/dai/address/0xcc74f1ffafb9e8cb55076c21be9af6cb0ccfc6d7/read_contract
I agree there is no way to define a proxy, but it would be great if it could be a configuration option. I.e. if you look at the proxy contract, none of the transactions are properly decoded. If we could do a heuristic like 1. ends in Proxy, has a variable named "imeplementation" that one could enable, that would be amazing!
I agree that the field implementation and the address stored there could be used to decode the input of the transaction. For example, NiftyWallet is doing similar to identify the proxy contract:
https://github.com/poanetwork/nifty-wallet/blob/06c8f041b621311172faad2c89d231cca05da347/old-ui/app/accounts/import/helpers.js#L89
Another approach is to keep a hasmap with all methods descriptors which ABIs have been added ever in Blockscout for. And as soon as you cannot decode the input with the particular contract ABI, look for the descriptor in the hashmap and use the corresponding ABI if the correspondence was found.
My assumption is that Etherescan is doing something similar. For example, take a look at https://etherscan.io/address/0xd819E948b14cA6AAD2b7Ffd333cCDf732b129EeD. There is no method deposit there. But if you look at the transaction sent to this contract: https://etherscan.io/tx/0x7cddc28eeaaa1b01861d2386829ae97906b2b4b609d2b06345d77397b2667242, it is decoded as the call of deposit and the arguments parsed correspondingly.
Another approach is to keep a hasmap with all methods descriptors which ABIs have been added ever in Blockscout for. And as soon as you cannot decode the input with the particular contract ABI, look for the descriptor in the hashmap and use the corresponding ABI if the correspondence was found.
And I see that something similar is already working on the mainnet: https://blockscout.com/eth/mainnet/tx/0xff2c0097f2912fea84425e2004e432427d3cbd71ac33beb9bf26e869846b0f1e/internal_transactions
whereas it does not applicable to the xDai chain: https://blockscout.com/poa/dai/address/0x7301cfa0e1756b71869e93d4e4dca5c7d0eb0aa6/transactions
This looks to be the relevant PR https://github.com/poanetwork/blockscout/pull/1466
It would be amazing if in the transaction list view, it could display the decoded info if there is only one matching ABI, would that work?
There's now a proposed standard for this: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1967.md
Used for example in https://github.com/poanetwork/posdao-contracts
would love to see this feature!
if there is a public function called implementation and the refernced contract address has been verified, then allow the option to display all interfaces for that contract but pointing to the memory of the proxy. (Could really use it while parsing logs from the proxy right now)
@nambrot decoding of method calls of implementation contract called on proxy contract is covered by this PR https://github.com/poanetwork/blockscout/pull/3153. Decoding of logs also is added. It is a part of 3.2.0 release and currently available live on xDai, POA and Sokol instance s of Blockscout.