Introducing *.getcode.eth: ENS based onchain metadata resolver

What is *.GetCode.eth?

Solidity compiler by default appends CBOR-encoded metadata to contract’s bytecode. *.getcode.eth is an ERC-3668 wildcard ENS resolver that extracts metadata hash from contract’s bytecode and resolves that as ENS contenthash.

Examples :

a) zAMM contracts: 0x00000000008892d085e0611eb8C8BDc9FD856fD3.getcode.eth
b) Safe Proxy: 0xA23dfEA786465E0Ef51eD6C288c9f0070d047ef7.proxy.getcode.eth

Basic UI with Metadata parsing & download features

Resolver source code :

0x7661a4705F10d828B7d9FAB680c6E9559faEABB0 (verified on etherscan)

3 modes of operation

Direct mode :
0x<addr>.getcode.eth -> IPFS contenthash (0xe3010170...) of metadata.json

CBOR mode :
0x<addr>.cbor.getcode.eth -> Returns Raw dag-cbor CID of metadata

Proxy Mode :
0x<addr>.proxy.getcode.eth -> Tries to detect proxy & resolve metadata.json

Limitations :

a) old contracts don’t have embedded metadata in contract bytecode
b) all most all contracts with swarm metadata are fail to resolve as they’re not pinned in swarm storage
c) bad proxies like USDC return blank implementation() address
d) lots of contracts don’t have their IPFS metadata pinned in IPFS network

You can read more about this in https://playground.sourcify.dev/, *.getcode.eth is same as sourcify playground but 100% onchain using contract’s bytecode & ENS wildcard resolver.

8 Likes

Very cool!
I actually suggested something similar to the Sourcify team recently: sourcify.eth-subdomains.md · GitHub

2 Likes

Sourcify developer here, very cool! Thanks for shipping this. Is it open source somewhere?

3 Likes

:pray: I see you’ve cidv1.eth ref in gist… :blush: Hello from Namesys.eth team here. I only published this resolver coz of recent etherscan API drama.:stuck_out_tongue_closed_eyes:

There’s new 128 bytes limit for inlined CIDs in IPIP-0512
I’m asking around to increase that limit to at least 256 bytes… https://discuss.ipfs.tech/t/cidv1-eth-onchain-raw-cidv1-library/19444/11?u=0xc0de4c0ffee

Another possible issue, there’s no index and ipfs _redirect supported in dag-cbor, and it was was even failing over cidv1.eth’s raw dag-pb/unixfs too. I have to recheck that.

Multichain support with CCIP is cool feature, sourcify team have to run their own signed web2 gateway+fallback servers to handle that.

Resolver is verified on both sourcify & etherscan… UI is basic Helia+CAR builder parsing metadata.json. I even pinged @ligi over twitter to take a look. I’ll be waiting to review & test sourcify’s resolver… ++ I can transfer this getcode.eth domain to sourcify team. Just ack and it’ll be yours to deploy v2 with l2 support.


Link to ens forum : Introducing *.getcode.eth: onchain wildcard contract metadata resolver - Integrations - ENS DAO Governance Forum
we even got new feature request to support sub-domain-eth.getcode.eth… I prev removed sub.domain.eth support to save wildcard ssl certs over ethlimo side.

2 Likes

In the case I outlined this isn’t an issue because we wouldn’t be using inline CIDs. Instead, we would calculate the actual CID on-chain, then we’d need to precompute the folder off-chain as well.

Oh, I thought your dag-pb/unixfs was compatible with the kubo one?

That’d be last option to go for extra headache managing offchain pinning…

I was checking how much we could squeeze in 128 bytes of dagpb inlined.
max 2 inlined files only, metadata.json comes from contract & static offchain pinned index.html is total 115 bytes using CIDv1 OR 111 bytes using CIDv0… we’ve to use CDN/add js scripts in index.html.

link tested :white_check_mark: : :blush:https://ipfs.io/ipfs/f0170006b12330a221220f4cc38c6dd6d2b1c3d4f9081c017f99d119ca28e22eb7d515a2c6deb25349ebd120d6d657461646174612e6a736f6e12300a22122003d76bfe86d06e9a7a6b044b8979d7961078bef8b1673b6205a7da071ede6b51120a696e6465782e68746d6c0a020801/

I’ve to recheck to find how much of dag-pb/unixfs extra data we can skip in this without breaking… but for your use case of 2 files that should work within 128 bytes.

// cidv0, = NO hex"0170" prefix 
bytes internal index_html_cid = hex"122003d76bfe86d06e9a7a6b044b8979d7961078bef8b1673b6205a7da071ede6b51";
bytes internal metadata_json_cid = hex"1220f4cc38c6dd6d2b1c3d4f9081c017f99d119ca28e22eb7d515a2c6deb25349ebd";

// ready to concat format using cidv0
//0170006b12330a22___CIDv0(metadata.json)___120d6d657461646174612e6a736f6e12300a22___CIDv0(index.html)__120a696e6465782e68746d6c0a020801

it is compatible & tested with kubo/helia js data. I mean there’s no index file supported with dag-cbor (index works for dag-pb only, eg link above) & _redirects isn’t working if it’s raw dag-pb/dag-cbor 0x00.

Wow, that’s pretty cool! Your index.html isn’t resolving though :slight_smile:

Using CIDv1? https://ipfs.io/ipfs/f0170122003d76bfe86d06e9a7a6b044b8979d7961078bef8b1673b6205a7da071ede6b51

CIDv0 only supports base58, for CIDv1/base16 f in gateway we’ve to add version 01 + dag-pb 70 prefix.

I get a 504 on this link.

could be coz my local pinning server was down.. :joy:


with full js reading ./metadata.json

/merry xmas & happy new year :vulcan_salute: