{"id":26179429,"url":"https://github.com/jmcph4/solc-metadata-indexer","last_synced_at":"2025-07-26T21:33:18.094Z","repository":{"id":281284703,"uuid":"944810810","full_name":"jmcph4/solc-metadata-indexer","owner":"jmcph4","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-08T03:13:30.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T03:24:17.675Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmcph4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["jmcph4"]}},"created_at":"2025-03-08T02:30:42.000Z","updated_at":"2025-03-08T03:13:34.000Z","dependencies_parsed_at":"2025-03-08T03:24:29.992Z","dependency_job_id":"3bcc87d6-1514-4966-8a28-80cf52e24df1","html_url":"https://github.com/jmcph4/solc-metadata-indexer","commit_stats":null,"previous_names":["jmcph4/solc-metadata-indexer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jmcph4/solc-metadata-indexer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcph4%2Fsolc-metadata-indexer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcph4%2Fsolc-metadata-indexer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcph4%2Fsolc-metadata-indexer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcph4%2Fsolc-metadata-indexer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmcph4","download_url":"https://codeload.github.com/jmcph4/solc-metadata-indexer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcph4%2Fsolc-metadata-indexer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267243614,"owners_count":24058948,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-11T21:49:54.043Z","updated_at":"2025-07-26T21:33:18.087Z","avatar_url":"https://github.com/jmcph4.png","language":"Rust","funding_links":["https://github.com/sponsors/jmcph4"],"categories":[],"sub_categories":[],"readme":"# solc-metadata-indexer #\n\nAn [ExEx](https://www.paradigm.xyz/2024/05/reth-exex) that indexes smart contract [metadata](https://docs.soliditylang.org/en/latest/metadata.html) produced by the Solidity compiler, `solc`.\n\n**[Follow me on X, the everything app](https://x.com/secjack_) or even [read my blog](https://jmcph4.dev/posts/decoding-solidity-metadata.html)**.\n\n## Background ##\n\nBy default, the [Solidity reference implementation](https://github.com/ethereum/solidity) (affectionately known as `solc`) [appends certain metadata](https://docs.soliditylang.org/en/latest/metadata.html) about compilation to its output bytecode. Specifically, this metadata is a CBOR-encoded dictionary which contains various fields -- although this is almost always just a reference to some out-of-band solution for a much larger metadata file. Interestingly, this \"reference\" is, [since 0.6.0](https://github.com/ethereum/solidity/blob/develop/Changelog.md#060-2019-12-17), a [CIDv0](https://github.com/multiformats/cid/blob/master/README.md#cidv0) (or an \"IPFS hash\", colloquially). Even *more* interestingly, this used to be a hash that uniquely identified an object on the [Swarm network](https://www.ethswarm.org/swarm-whitepaper.pdf) - a relatively esoteric (and long since forgotten) distributed filesystem. For the keenly interested reader, there's a [fairly useful hosted tool](https://playground.sourcify.dev) by [Sourcify](https://sourcify.dev).\n\nThe actual encoding itself is somewhat ad hoc. The length of the CBOR bytes is encoded in the *final two octets* of the entire bytecode sequence.\n\n```\n0                        N-m                     N-2                                      N\n+~~~~~~~~~~~~~~~~~~~~~~~~~+-----------------------+---------------------------------------+\n|                         |                       |                                       |\n| rest of the bytecode... | CBOR-encoded metadata | Length of CBOR-encoded data (2 bytes) |\n|                         |                       |                                       |\n+~~~~~~~~~~~~~~~~~~~~~~~~~+-----------------------+---------------------------------------+\n```\n\nSuppose that the entire bytecode sequence is $N\u003e2$ bytes long and that the final two bytes in the sequence (i.e., the length of the CBOR data) encode the number $m$. In order to retrieve the CBOR data we need to walk backwards from the end of the entire bytecode sequence by $m-2$ bytes and then read the following $m$ bytes.\n\n## Usage ##\n\n```\nExtracts Solidity metadata from contract bytecode\n\nUsage: solc-metadata-indexer [OPTIONS]\n\nOptions:\n  -l, --live                 Activates and installs the ExEx into a running Reth instance\n  -r, --raw                  Interpret input from standard input as literal bytes\n  -m, --metadata             Print metadata representation to standard output\n  -b, --bytecode \u003cBYTECODE\u003e  Provide file path to a file containing bytecode (interpretation depends on `--raw`)\n  -h, --help                 Print help\n  -V, --version              Print version\n```\n\n## Resources ##\n\n - The [Jetkit](https://github.com/jmcph4/jetkit) implementation (called [`sme`](https://github.com/jmcph4/jetkit/blob/master/src/sme/README.md))\n - The [docs](https://docs.soliditylang.org/en/v0.8.28/metadata.html) for Solidity that describe contract metadata\n - The [code](https://github.com/ethereum/solidity/blob/7893614a31fbeacd1966994e310ed4f760772658/libsolutil/IpfsHash.cpp) in `solc` that handles the metadata hashing for IPFS\n - The [code](https://github.com/ipfs/kubo/blob/ad1868a424dd7a564ab3c023f4d35a2e6fd696aa/core/commands/add.go) for the `ipfs add` command (now a part of [Kubo](https://docs.ipfs.tech/install/command-line))\n - The aformentioned [tool](https://playground.sourcify.dev) by Sourcify for exploring contract metadata\n - The [CBOR playground](https://cbor.me)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcph4%2Fsolc-metadata-indexer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmcph4%2Fsolc-metadata-indexer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcph4%2Fsolc-metadata-indexer/lists"}