Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Human-readable context for smart contracts.

Contract Metadata is a JSON standard that layers human-readable context on top of onchain data. It enriches smart contracts at every level -- contract descriptions, function titles and warnings, semantic type annotations, input guidance, and event/error enrichment -- giving wallets, explorers, and dApps the information they need to present contract interactions in terms users understand.
Contract Metadata is a JSON standard that layers human-readable context on top of onchain data. It enriches smart contracts at every level -- contract descriptions, action titles and warnings, semantic type annotations, input guidance, and event/error enrichment -- giving wallets, explorers, and dApps the information they need to present contract interactions in terms users understand.

**[Read the full specification](./eip-draft.md)**

Expand All @@ -19,7 +19,7 @@ offerPunkForSaleToAddress(uint256, uint256, address)
"$schema": "https://1001-digital.github.io/contract-metadata/v1/schema.json",
"chainId": 1,
"address": "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb",
"functions": {
"actions": {
"offerPunkForSaleToAddress": {
"title": "List Punk for Sale (Private)",
"description": "List a punk for sale to a specific address only.",
Expand All @@ -35,6 +35,8 @@ offerPunkForSaleToAddress(uint256, uint256, address)
}
```

Actions decouple the user-facing UX surface from the ABI. One ABI function can back multiple actions (variants). For example, a single `approve` function can surface as `approve` (normal), `approve-max` (unlimited, amount locked), and `revoke` (amount locked to 0) — each with its own title, intent, and warning.

## Repository Structure

```
Expand Down
2 changes: 1 addition & 1 deletion contracts/0x036721e5a769cc48b3189efbb9cce4471e8a48b1.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"compositing": { "label": "Compositing", "order": 3 },
"info": { "label": "Token Info", "order": 4 }
},
"functions": {
"actions": {
"mint": {
"title": "Mint Original",
"description": "Mint Checks Originals by burning the corresponding Edition tokens. Each Original is created fully onchain with the same token ID as the burned Edition. This is the only way new Originals enter existence.",
Expand Down
2 changes: 1 addition & 1 deletion contracts/0x59e16fccd424cc24e280be16e11bcd56fb0ce547.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"info": { "label": "Info", "order": 3 },
"admin": { "label": "Admin", "order": 4 }
},
"functions": {
"actions": {
"available": {
"title": "Check Availability",
"description": "Check whether a .eth name is available for registration. Returns false if the name is currently registered or in its 90-day grace period.",
Expand Down
2 changes: 1 addition & 1 deletion contracts/0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"marketplace": { "label": "Marketplace", "order": 3 },
"genesis": { "label": "Original Assignment", "order": 4 }
},
"functions": {
"actions": {
"name": {
"order": 0,
"title": "Name",
Expand Down
2 changes: 1 addition & 1 deletion contracts/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"groups": {
"wrap": { "label": "Wrap / Unwrap", "order": 1 }
},
"functions": {
"actions": {
"deposit": {
"title": "Wrap ETH",
"description": "Wrap ETH into WETH. Send ETH with this transaction to receive the same amount in WETH.",
Expand Down
2 changes: 1 addition & 1 deletion contracts/0xedcbf19024e928c9d903fcf4785e42ad7c271193.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"info": { "label": "Info", "order": 2 },
"admin": { "label": "Admin", "order": 3 }
},
"functions": {
"actions": {
"support": {
"title": "Support",
"description": "Subscribe or extend a subscription at a given tier. Pays in ETH (converted from USD via Chainlink). Third parties can gift or extend subscriptions, but only the recipient or owner can change tiers. Excess ETH is refunded.",
Expand Down
2 changes: 1 addition & 1 deletion contracts/0xf3e732194ba87d68fd6ec3d5b1bf813599c8406a.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"marketplace": { "label": "Marketplace", "order": 2 },
"admin": { "label": "Admin", "order": 3 }
},
"functions": {
"actions": {
"name": {
"order": 0,
"title": "Name",
Expand Down
130 changes: 101 additions & 29 deletions eip-draft.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions extensions/_component.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `_component` Extension

Register a custom UI component on any extensible metadata object (functions, events, errors, messages, parameters, or contract metadata).
Register a custom UI component on any extensible metadata object (actions, events, errors, messages, parameters, or contract metadata).

## Shape

Expand Down Expand Up @@ -32,7 +32,7 @@ When no configuration is needed, use the string form:

```json
{
"functions": {
"actions": {
"composite": {
"title": "Composite",
"description": "Burn two Checks of the same tier to create one of the next tier.",
Expand All @@ -48,7 +48,7 @@ A content prover component that verifies a hash stored onchain against a known s

```json
{
"functions": {
"actions": {
"imageHash": {
"title": "Image Hash",
"description": "SHA-256 hash of the composite image containing all 10,000 punks.",
Expand All @@ -74,7 +74,7 @@ A content prover component that verifies a hash stored onchain against a known s

```json
{
"functions": {
"actions": {
"setColor": {
"title": "Set Color",
"params": {
Expand Down
43 changes: 29 additions & 14 deletions schema/contract-metadata.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,14 @@
"$ref": "#/$defs/Group"
}
},
"functions": {
"actions": {
"type": "object",
"description": "Per-function metadata. Keys can be a bare ABI name (e.g. \"transfer\"), a full Solidity signature for overloaded functions (e.g. \"safeTransferFrom(address,address,uint256,bytes)\"), or a 4-byte selector for unverified contracts (e.g. \"0xa9059cbb\").",
"description": "User-facing actions, keyed by free-form identifier (e.g. \"approve\", \"revoke\", \"my-balance\"). Each action references an ABI function via its `function` field and may preset or lock parameters. Multiple actions may target the same function to provide UX variants.",
"propertyNames": {
"pattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$"
},
"additionalProperties": {
"$ref": "#/$defs/FunctionMeta"
"$ref": "#/$defs/ActionMeta"
}
},
"events": {
Expand Down Expand Up @@ -267,7 +270,7 @@
}
}
},
"FunctionMeta": {
"ActionMeta": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
Expand All @@ -276,18 +279,22 @@
}
},
"properties": {
"function": {
"type": "string",
"description": "Reference to the ABI function this action invokes. Accepts a bare name (e.g. \"approve\"), a full Solidity signature (e.g. \"approve(address,uint256)\") for overloaded functions, or a 4-byte selector (e.g. \"0x095ea7b3\") for unverified contracts. OPTIONAL: when omitted, the action's id (its key in the `actions` object) is used as the reference — so `\"approve\": { ... }` is equivalent to `\"approve\": { \"function\": \"approve\", ... }`. Variant actions whose id differs from the underlying function (e.g. `\"revoke\": { \"function\": \"approve\", ... }`) MUST set this field explicitly."
},
"order": {
"type": "integer",
"minimum": 0,
"description": "Display order within the function's group (lower numbers appear first). Functions without an order are sorted after ordered ones."
"description": "Display order within the action's group (lower numbers appear first). Actions without an order are sorted after ordered ones."
},
"title": {
"type": "string",
"description": "Human-readable function name."
"description": "Human-readable action name."
},
"description": {
"type": "string",
"description": "What the function does, explained for end users."
"description": "What the action does, explained for end users."
},
"intent": {
"type": "string",
Expand All @@ -303,11 +310,11 @@
},
"featured": {
"type": "boolean",
"description": "Mark as a primary/featured function. Featured functions are highlighted in the UI (e.g. the main mint, swap, or stake action)."
"description": "Mark as a primary/featured action. Featured actions are highlighted in the UI (e.g. the main mint, swap, or stake action)."
},
"hidden": {
"type": "boolean",
"description": "Hide this function from the default UI. Use for internal or admin-only functions that clutter the interface."
"description": "Hide this action from the default UI. Use for internal or admin-only actions that clutter the interface, or to suppress the ABI-synthesized default when only variants should render."
},
"stateMutability": {
"type": "string",
Expand All @@ -331,18 +338,18 @@
"examples": {
"type": "array",
"items": {
"$ref": "#/$defs/FunctionExample"
"$ref": "#/$defs/ActionExample"
},
"description": "Preset examples for quick interaction."
},
"related": {
"type": "array",
"items": { "type": "string" },
"description": "ABI names of related functions for navigation."
"description": "Action identifiers (keys in the top-level actions object) of related actions for navigation."
},
"deprecated": {
"type": "string",
"description": "Deprecation notice. If set, the function should be de-emphasized in the UI."
"description": "Deprecation notice. If set, the action should be de-emphasized in the UI."
}
}
},
Expand Down Expand Up @@ -467,7 +474,7 @@
},
"type": {
"$ref": "#/$defs/Type",
"description": "Semantic type annotation. Tells consumers what a value represents (for display) and how it should be collected (for input)."
"description": "Semantic type annotation. Tells consumers what a value represents (for display) and how it should be collected (for input). Note: `type: \"hidden\"` is a display-side hint (don't render the value in read contexts) and is orthogonal to the input-side `hidden` flag below."
},
"autofill": {
"$ref": "#/$defs/Autofill",
Expand All @@ -478,6 +485,14 @@
},
"preview": {
"$ref": "#/$defs/ParamPreview"
},
"hidden": {
"type": "boolean",
"description": "When true, do not render an input for this parameter. The `autofill` value is injected at call time. REQUIRES `autofill`. Use for variant actions like `revoke` where a parameter is fixed (e.g. amount = 0)."
},
"disabled": {
"type": "boolean",
"description": "When true, render the input but make it non-editable. Displays the autofilled value for transparency. REQUIRES `autofill`. Mutually exclusive with `hidden: true`."
}
}
},
Expand Down Expand Up @@ -642,7 +657,7 @@
}
}
},
"FunctionExample": {
"ActionExample": {
"type": "object",
"required": ["label", "params"],
"additionalProperties": false,
Expand Down
13 changes: 8 additions & 5 deletions schema/interface.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/1001-digital/contract-metadata/schema/interface.schema.json",
"title": "Contract Metadata Interface",
"description": "Reusable metadata for standard interfaces (ERC-20, ERC-721, etc.). Provides groups, functions, events, and messages that can be included by contract metadata files via the includes field.",
"description": "Reusable metadata for standard interfaces (ERC-20, ERC-721, etc.). Provides groups, actions, events, and messages that can be included by contract metadata files via the includes field.",
"type": "object",
"additionalProperties": false,
"properties": {
"groups": {
"type": "object",
"description": "Named groups for organizing functions in the UI.",
"description": "Named groups for organizing actions in the UI.",
"additionalProperties": {
"$ref": "contract-metadata.schema.json#/$defs/Group"
}
},
"functions": {
"actions": {
"type": "object",
"description": "Per-function metadata. Keys can be a bare ABI name, a full Solidity signature for overloads, or a 4-byte selector for unverified contracts.",
"description": "User-facing actions, keyed by free-form identifier. Each action references an ABI function via its `function` field. Multiple actions may target the same function to provide UX variants.",
"propertyNames": {
"pattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$"
},
"additionalProperties": {
"$ref": "contract-metadata.schema.json#/$defs/FunctionMeta"
"$ref": "contract-metadata.schema.json#/$defs/ActionMeta"
}
},
"events": {
Expand Down
Loading