Proxy contracts
For a step-by-step guide on shadowing a contract that uses a proxy pattern, see our how-to on modifying proxy contracts.
What is a proxy contract?
A proxy contract in Ethereum is a smart contract that acts as an intermediary or wrapper for another contract, enabling features like upgradeability and interaction redirection.
Proxy contracts make delegate calls to a designated implementation contract, which contains the actual smart contract logic. This setup allows the logic (implementation contract) to be updated without changing the proxy contract's address, preserving the contract's state and address on the blockchain. Proxy contracts are a core component in creating upgradeable smart contracts.
Do I write shadow events on the proxy or implementation?
If you want to get custom data for a contract that uses a proxy pattern, you'll need to modify the code of the implementation contract, because that's where the actual contract logic resides.
When transactions happen, events will get emitted by the proxy contract, while the event declarations and event emit logic reside in the code of the implementation contract. This is the same way other platforms that index smart contract data handle proxy patterns.
Tips
Add both the proxy and implementation contracts in Shadow
You will want to add both the proxy contract and implementation contract to your Shadow Catalog, because you will need to:
Edit the logic and add shadow events to the implementation contract
View the event emits on the proxy contract
How do I tell if a contract is a proxy contract?
On the Etherscan contract page, click on the Contract
subtab. If you see the Read as Proxy
tab, that means that this contract is a proxy contract.
Here's the Aave V3 Pool contract, which uses a proxy pattern, as an example.
How do I find a proxy contract's implementation contract?
Click on the Read as Proxy
subtab. The current implementation contract address will be listed.
What do I do if a proxy has multiple past implementation contracts?
If you want to get shadow event data across a time period where the proxy contract has changed the implementation contract that it delegates its logic to, you will need to write separate shadow event logic on each implementation contract that was used during that time period.
This is because the logic across the previous implementation contracts could be different. Shadow will show your custom data from all implementation contracts on the proxy contract.
Last updated