ERC-7512 · Draft · ERC · 2023-09-05
ERC-7512: Onchain Representation for Audits
A draft format for auditors to sign an EIP-712 summary of an audit, so contracts can check on-chain that a specific deployment was audited by a trusted party and which ERCs it implements.
What problem does it solve?
Audit reports today are PDFs on a website. A contract that wants to accept only audited code, such as a bridge registering new tokens or a smart account installing modules, has no machine-readable way to check that a given deployment was reviewed, by whom, and against which standards.
ERC-7512 defines a compact, signed audit summary that contracts can verify. A bridge operator can, for example, list the auditor keys it trusts, and let anyone register a token by supplying a summary signed by one of those keys for that exact contract address and chain.
How it works
The summary is a typed structure:
- Auditor:
name,uri, and a list ofauthors. - Contract:
chainId(the EIP-155 chain ID asbytes32) anddeploymentaddress. One summary covers one contract instance. - AuditSummary: auditor,
issuedAt,ercs(a list of ERC numbers the contract fully implements, possibly empty), the audited contract,auditHash(hash of the original report) andauditUri.
The auditor signs the AuditSummary with EIP-712 typed data and attaches the result as a SignedAuditSummary with signedAt and a Signature { type, data }. Supported signature types are SECP256K1, SECP256R1, ERC1271 (smart-contract signers, see ERC-1271) and BLS (encoding still TBD).
Findings and severities are deliberately not included; the summary only says "this instance was audited" and "it implements these ERCs".
Sample code
Signing a summary with ethers v6 (types follow the spec's structs):
import { Wallet, keccak256, toUtf8Bytes, zeroPadValue, toBeHex } from "ethers";
const domain = { name: "ERC-7652: Onchain Audit Representation", version: "1.0" }; // as written in the spec
const types = {
Auditor: [{ name: "name", type: "string" }, { name: "uri", type: "string" }, { name: "authors", type: "string[]" }],
Contract: [{ name: "chainId", type: "bytes32" }, { name: "deployment", type: "address" }],
AuditSummary: [
{ name: "auditor", type: "Auditor" },
{ name: "issuedAt", type: "uint256" },
{ name: "ercs", type: "uint256[]" },
{ name: "auditedContract", type: "Contract" },
{ name: "auditHash", type: "bytes32" },
{ name: "auditUri", type: "string" },
],
};
const summary = {
auditor: { name: "Example Audits", uri: "https://example.com", authors: ["Alice"] },
issuedAt: 1700000000,
ercs: [20],
auditedContract: { chainId: zeroPadValue(toBeHex(1), 32), deployment: tokenAddress },
auditHash: keccak256(toUtf8Bytes(reportPdfContents)),
auditUri: "https://example.com/reports/token.pdf",
};
const sig = await auditorWallet.signTypedData(domain, types, summary);
Things to know
- Status is Draft, and the reference implementation is marked TBD.
- The domain name in the spec text reads "ERC-7652" although the proposal is ERC-7512; implementations should follow whatever the final spec settles on.
- A signed summary is not a guarantee of security. The spec says integrators must judge the auditor and the coverage themselves.
- Everything rests on auditor key management. There is no standard registry of auditor keys or revocation mechanism yet; auditors are expected to publish their keys themselves.
- Proxies and upgradeable contracts are not addressed: the summary binds to an address, not to the code behind it.