erc6551 / reference

ERC-6551 reference implementation
152 stars 50 forks source link

Make ERC6551AccountProxy Etherscan friendly #26

Closed Vectorized closed 11 months ago

Vectorized commented 11 months ago

If the ERC1967 implementation slot of the minimal proxy is not initialized, the "Is this a Proxy?" detector will suggest the address of the ERC6551AccountProxy instead of the actual ERC6551Account implementation.

Example ERC6551 minimal proxy: https://sepolia.etherscan.io/address/0x90f7d9ae452ad84f1225cdc725ea001575e1b305

This PR allows a user to initialize the slot on the minimal proxy by sending 0 ETH (or any transaction with empty calldata) to it.

I think it can be good to write some Natspec or comments to explain the ERC6551 upgradeable pattern, as it is a bit tricky.

Feel free to copy and paste anything from https://github.com/Vectorized/solady/blob/main/src/accounts/ERC6551Proxy.sol and https://github.com/Vectorized/solady/blob/main/src/accounts/ERC6551.sol.

jaydenwindle commented 11 months ago

@Vectorized awesome, thanks for this! Is there a reason for doing a 0 ETH transfer vs doing a regular call (beyond gas savings)? As far as I know, Etherscan can verify a nested proxy as long as at least one transaction has been executed that hits the implementation.

Vectorized commented 11 months ago

I can't seem to make Etherscan detect the correct proxy, even after making a transaction. https://sepolia.etherscan.io/address/0x33749fa496b276ccf858a3c5f1551ba0c455789b

Any transfer with msg.data.length == 0 will do. The choice of empty calldata is so that one doesn't need an ABI to initialize the slot.

jaydenwindle commented 11 months ago

Got it, good with me