Skip to content

Read a proxy ​

Call a contract whose functions live in another contract, and see which ABI answered.

cql
let stETH = ethereum:0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84;

from stETH as s
| project {
    block:        $block,
    ethPerShare:  format(s.getPooledEthByShares(1e18), 18),
    pooledEther:  format(s.getTotalPooledEther(), 18),
    totalShares:  format(s.getTotalShares(), 18)
  }

Open in workbench →

blockethPerSharepooledEthertotalShares
260427071.2447109157008669029761717.1353650365619361337842557.667190094063001578

One row: the share rate, the pooled ether and the total shares, decoded by an ABI the address itself does not declare.

How it reads ​

stETH is an Aragon app proxy. Its own verified source declares five functions — implementation, kernel, appId, proxyType and isDepositable. It declares no getPooledEthByShares. It forwards every other call to an implementation. Etherscan names that implementation, and CQL follows it to ethereum:0x028271e30a695c0527a0c50ca30603fed004cdb0. Then it decodes your calls with the implementation's ABI. You write the query as if the proxy were the token, because to a caller it is.

Press the ⓘ beside the address in the grid, and the Contract tab shows what happened. A registry line names where the ABI came from, and a borrowed from line names the implementation. The five functions the proxy declares describe its upgrade machinery, not the token. implementation among them returns the address the tab names.

Over a range ​

stETH has been upgraded more than once since it launched. CQL still decodes every row of a range with one ABI, the ABI that the Contract tab shows. Each call runs at its own block, so the proxy forwards it to the implementation that was live at that block. On an older row, the result depends on that implementation:

  • It has the function with the same outputs. The value is correct.
  • It has the function with other outputs. CQL decodes the result with the outputs in the tab's ABI, so the value can be wrong or null.
  • It does not have the function. The call usually reverts, and the value is null.

A call to a function that is not in the tab's ABI ends in CQL3013. CQL refuses the whole query, even if an older implementation had that function. The tab shows the ABI that CQL found when it last asked about the proxy. CQL asks again after seven days. Until then, a function that only a newer implementation has also ends in CQL3013.

When it goes wrong ​

Two things can look like a proxy and not resolve:

  • CQL finds no implementation for the proxy. It keeps the proxy's own ABI, and a call to a function of the implementation ends in CQL3013. A proxy that nobody initialised has no implementation. For stETH, only Etherscan names the implementation, so without Etherscan's answer CQL refuses this query. To read the proxy anyway, give the implementation's ABI with with { abi: … }.
  • CQL finds the implementation, but no service verified it. CQL keeps the proxy's own ABI, so a call to a function of the implementation ends in CQL3013. The Diagnostics tab has no check again button for this code. Give the implementation's ABI from your library with with { abi: … }, or use .call(). Go to step 2 of Read a contract nobody has verified, which shows both ways.

CQL asks about a proxy again after seven days. If a service names the implementation by then, and the implementation is verified, the next run uses its ABI. If no service answers during that run, CQL keeps the functions the proxy had and asks again in the run after it.

In the workbench ​

  1. Add contract: s.$address to the project.
  2. Run the query.
  3. Click the ⓘ beside the address in the grid.

The Contract tab shows borrowed from with the implementation whose ABI decoded the calls. Its list of functions shows the proxy's own functions and the implementation's functions together. It does not show which contract each function came from. See Contract.

See also ​