Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC8217 proposes a way to associate AI agents registered under ERC8004 with existing NFTs or other tokens. When ownership of an external token changes, control of the associated agent can follow that transfer.

Overview

What is ERC8004?

Under ERC8004, the registry that manages AI agent identities registers each agent as an NFT. This registry is called the Identity Registry, and the NFT's token ID serves as the agent's agentId.

Details about a registered agent are available in the registration file referenced by agentURI. The registry can also record additional information on-chain as key-value pairs in metadata. ERC8217 makes use of agentId and metadata.

For more on ERC8004, see the following article.

[ERC8004] Understanding Trustless Agents

What ERC8217 Adds

Existing project NFTs and character NFTs are managed by token contracts separate from the ERC8004 agent. ERC8217 records the association between an agentId and an external token in a dedicated contract, with one such contract designated per chain. The standard calls this a binding contract.

Suppose we want to associate the agent with agentId = 17 with tokenId = 42 of an ERC721 contract. The agent's metadata contains only the 20-byte address of the binding contract. A client then calls bindingOf(17) on that contract to retrieve standard = ERC721, the token contract address, and tokenId = 42.

Overview of resolving an external token from an ERC8004 agentId through a binding contract

Even if the external token is transferred from Alice to Bob, the association between agentId = 17 and tokenId = 42 remains unchanged. Instead, subject to the control rules adopted by the binding contract, Bob, the current owner, can be identified as the agent's controller. How ownership or balances are used for authorization is outside the scope of ERC8217 and is determined by the binding contract.

Motivation

An ERC8004 registration is itself an NFT. If holders of existing project NFTs are to control agents, the association between each registration NFT and each project NFT must be recorded. If projects record these associations differently, wallets, marketplaces, and indexers must integrate a separate data format and verification procedure for each project.

Without ERC8217, one project might write the token contract directly into metadata, while another might deploy its own management contract. Clients would then be unable to tell from the metadata alone whether external-token control is in use or which contract to query. ERC8217 therefore specifies a common key, agent-binding, and a 20-byte address format.

Comparison of project-specific verification methods and the common ERC8217 verification procedure

The standard covers discovery of the binding contract and retrieval of standard, tokenContract, and tokenId through bindingOf. A single fixed authorization condition would not accommodate both ERC721 ownership and ERC1155 or ERC6909 balances. ERC8217 therefore standardizes discovery while leaving the determination of the current controller to the binding contract.

Specification

ERC8217 separates responsibilities at registration and verification time. The registry or adapter that registers an agent writes the canonical binding contract address to agent-binding. The binding contract stores a Binding at initial registration and does not subsequently change standard, tokenContract, or tokenId. Clients retrieve these three values by calling bindingOf(agentId).

Metadata and Binding

agent-binding is a reserved key in ERC8004 metadata. Its value is exactly 20 bytes: the EVM address of the single canonical binding contract used on that chain.

js
abi.encodePacked(bindingContract)

Because bindingContract is an EVM address, no additional data or padding to 32 bytes is included. For example, if the address is as follows, the metadata value contains the same 20 bytes.

text
0x9c4e8f2a1b7d6e3c0a5f8d2b9e1c4a7f3d6e8b0c

The token standard, token contract, and token ID are not decoded from these 20 bytes. A client interprets them as the address to call and retrieves all three values from that contract through bindingOf(agentId).

Metadata stores only the 20-byte reference, while Binding supplies external token information

metadata identifies where to make the query, while Binding specifies standard, tokenContract, and tokenId. Clients can thus distinguish the 20-byte address from the external token information when retrieving it.

IERCAgentBindings

A binding contract exposes at least the following interface. It may also provide registration functions, administrative functions, URI updates, wallet associations, and upgrade administration, but those are outside the verification scope of ERC8217.

js
pragma solidity ^0.8.24;

interface IERCAgentBindings {
    enum TokenStandard {
        ERC721,
        ERC1155,
        ERC6909
    }

    struct Binding {
        TokenStandard standard;
        address tokenContract;
        uint256 tokenId;
    }

    event AgentBound(
        uint256 indexed agentId,
        TokenStandard indexed standard,
        address indexed tokenContract,
        uint256 tokenId,
        address registeredBy
    );

    function bindingOf(uint256 agentId) external view returns (Binding memory);
}

The interface specifies only bindingOf, which reads a Binding, and the AgentBound event, which tracks initial registration. Clients can therefore verify the registered result with the same call without knowing the implementation-specific registration procedure.

TokenStandard

js
enum TokenStandard {
    ERC721,
    ERC1155,
    ERC6909
}

TokenStandard is an enum that distinguishes the standards of the bound tokens. The value of Binding.standard tells a client which token standard to use when interpreting tokenContract and tokenId.

Value Token type
ERC721 An NFT that records a single owner for each token ID
ERC1155 A token standard that manages multiple token types and balances within one contract
ERC6909 A lightweight token standard that manages multiple token IDs and balances within one contract

Each enum value identifies the token type without determining who counts as the controller. For example, with ERC1155, the binding contract determines whether holding at least one unit is sufficient or whether a specified minimum balance is required.

Binding

js
struct Binding {
    TokenStandard standard;
    address tokenContract;
    uint256 tokenId;
}

Binding is a struct representing the external token associated with an agentId. The binding contract stores it at initial registration, and clients retrieve it by calling bindingOf(agentId).

  • Fields
Field Description
standard The token standard used to interpret tokenContract and tokenId.
tokenContract The address of the contract managing the external token.
tokenId The ID identifying the bound token within the external token contract.

For example, with standard = ERC721, tokenContract = 0x111...1111, and tokenId = 42, the agentId is bound to token 42 in that ERC721 contract. An ERC8217-compliant binding contract does not change these three values after initial registration.

AgentBound

js
event AgentBound(
    uint256 indexed agentId,
    TokenStandard indexed standard,
    address indexed tokenContract,
    uint256 tokenId,
    address registeredBy
);

The AgentBound event is emitted when the Binding for an agentId is stored for the first time. Indexers can filter by the indexed agentId, standard, and tokenContract to track which external token was registered.

  • Fields
Field Description
agentId The ERC8004 agent ID being bound. Indexed for event queries.
standard The external token standard. Indexed for event queries.
tokenContract The external token contract address. Indexed for event queries.
tokenId The token ID within the external token contract.
registeredBy The address that called the Binding registration operation.

The event log reveals who associated each agentId with which token. For verification, however, clients use the Binding returned by bindingOf(agentId) rather than event logs. Even if they miss an event, they can call the function to retrieve the currently stored Binding.

bindingOf

js
function bindingOf(uint256 agentId) external view returns (Binding memory);

bindingOf is a view function that returns the Binding stored for a specified agent. A client calls it on the binding contract discovered through metadata.

  1. Read the Binding for agentId

    The binding contract reads the Binding associated with the supplied agentId from contract storage.

  2. Return the Binding

    It returns a struct containing standard, tokenContract, and tokenId to the caller.

  • Parameters
Parameter Description
agentId The ERC8004 agent ID whose associated external token is to be retrieved.
  • Return value
Return value Description
Binding memory A Binding containing the token standard, token contract, and token ID.
  • Execution conditions

  • No caller authorization conditions are specified.

  • The call is made to the canonical binding contract obtained from metadata.

  • The interface does not define a return value or revert condition for an unregistered agentId.

The last condition varies by binding contract. Clients must check not only whether the call succeeds, but also whether the returned Binding is valid under the binding contract's specification.

Seven Registration Requirements

When an agentId and an external token are first registered with the binding contract, the following seven conditions must be met. After registration, neither the agent-binding address nor the standard, tokenContract, and tokenId stored in the Binding may change.

  • Reserved key

    Reserve agent-binding and prevent untrusted callers from overwriting it with arbitrary values.

  • 20-byte value

    Write the address of the canonical binding contract to metadata as exactly 20 bytes.

  • Matching query destination

    The address in metadata must match the contract that provides bindingOf for that agentId.

  • Canonical contract per chain

    Use only one canonical binding contract on a given chain.

  • Initial registration event

    Emit AgentBound when the Binding for an agentId is first stored.

  • Immutable registered address

    Do not change the binding contract address written to agent-binding.

  • Immutable Binding fields

    Do not change the standard, tokenContract, or tokenId returned by bindingOf(agentId).

Because the agent-binding address and the three fields of the Binding remain unchanged, clients and indexers can cache a verified Binding. Ownership and balances of external tokens can change, however, so clients must query the external token again when determining the current controller.

Verification Procedure

Clients verify metadata and the binding contract separately. If any stage fails, the client stops processing the association as verified.

Verification procedure from reading ERC8004 metadata to checking the bindingOf return value

  1. Read agent-binding

    The client retrieves agent-binding for the target agentId from the ERC8004 registry.

  2. Interpret it as a 20-byte address

    Confirm that the value is 20 bytes long and interpret it as the EVM address of the binding contract. If the key is absent or the length differs, stop and treat the binding as unverified.

  3. Call bindingOf(agentId)

    Pass agentId to the retrieved address to read the Binding. If the call fails, stop and treat the binding as unverified.

  4. Check the control conditions

    Use the returned standard, tokenContract, and tokenId to proceed with the authorization procedure defined by the binding contract. For example, if the binding contract uses ERC721 ownership, query ownerOf(tokenId) on the external token contract to identify the current owner.

The fourth step determines the actual controller after the Binding has been verified. ERC8217 standardizes only the first three steps; the binding contract retains the rules for determining controllers from ownership or balances.

Additional Considerations

ERC8217 does not introduce a binding contract simply to reduce the size of metadata. By separating external token identification from the rules that use the token for authorization, it identifies the contract that clients need to evaluate.

Information discoverable from metadata and the scope of trust in the binding contract

Why Store the Binding Contract?

A token contract and token ID alone do not establish who can control an agent. Even with the same ERC1155 token, a contract that treats holders of one or more units as controllers will produce different authorization results from a contract that requires at least ten units.

The metadata therefore stores the address of the binding contract implementing the authorization logic. In addition to checking the return value of bindingOf, a client can examine how that contract evaluates ownership or balances. Even when contracts refer to the same token, those with different authorization rules can be evaluated separately.

Information Not Duplicated in Metadata

The token standard, token contract, and token ID are stored in the binding contract's Binding. Only that contract's 20-byte address is written to metadata.

If all three fields were stored in both places and only one copy were updated, metadata and the return value of bindingOf would disagree. Under ERC8217, the token standard, token contract, and token ID are retrieved solely from the return value of bindingOf. Because the Binding is immutable, the three values, once verified, cannot subsequently be replaced with a different token.

Compatibility

ERC8217 does not change the behavior of existing registration registries or external tokens. It adds the agent-binding key for storing the binding contract address and IERCAgentBindings for returning a Binding.

Relationship to ERC8004

The ERC8004 registry manages an agentId and metadata for each agent. ERC8217-compatible registries or adapters write agent-binding into the existing metadata, so they do not create a new agent identifier.

Existing ERC8004 registries and adapters do not have to support agent-binding. Those that do can read the common 20-byte format and discover the binding contract using the same procedure.

Relationship to External Tokens

ERC721 is an NFT standard that records a single owner per token ID. The binding contract can use that owner as the agent's controller.

For more on ERC721, see the following article.

[ERC721] An Introduction to ERC721

ERC1155 manages multiple token types and balances in a single contract. The binding contract can therefore use the balance of a specified token ID as a control condition.

For more on ERC1155, see the following article.

[ERC1155] An Introduction to ERC1155

ERC6909 also manages multiple token IDs and balances in one contract. However, the binding contract, not ERC8217, determines how many units are needed for control and how to handle multiple holders who simultaneously meet the condition.

In other words, ERC8217 identifies three token standards as binding targets but does not alter their ownership, balance, or transfer behavior. When ownership or balances of an external token change, only the binding contract's authorization results change; the Binding itself continues to return the same values.

Tests

Tests check the 20-byte metadata value separately from the three fields returned by bindingOf. Reading token information from agent-binding alone does not conform to ERC8217.

20-byte Metadata

Assume the binding contract has the following address.

text
bindingContract = 0x9c4e8f2a1b7d6e3c0a5f8d2b9e1c4a7f3d6e8b0c

The value stored in agent-binding is 40 hexadecimal digits excluding the 0x prefix, or 20 bytes.

text
0x9c4e8f2a1b7d6e3c0a5f8d2b9e1c4a7f3d6e8b0c

This test checks that the stored value exactly matches the address. A value concatenating TokenStandard, the external token contract, and the token ID fails the test. Values shorter than 20 bytes or padded to 32 bytes also fail.

Return Value of bindingOf

Call bindingOf(17) on the same binding contract, for example. When the agent is bound to ERC721 token 42, the return value is as follows.

js
Binding({
    standard: TokenStandard.ERC721,
    tokenContract: 0x1111111111111111111111111111111111111111,
    tokenId: 42
})

This test checks that standard, tokenContract, and tokenId match the values from initial registration. It also verifies that calling an update operation after registration cannot change either the return value of bindingOf(17) or the agent-binding address.

The proposal's test examples also include ERC1155 tokenId = 5 and ERC721 tokenId = 0x1234. These values are likewise returned from the Binding and are not included in metadata.

Security

Correctly reading the 20-byte agent-binding value does not establish the current controller. Clients separately verify the referenced contract and ownership or balances of the external token.

Why Metadata Alone Is Insufficient

metadata identifies only the address of the contract on which to call bindingOf(agentId). The external token is identified from the return value of bindingOf, while the control conditions are determined by how the binding contract checks ownership or balances.

For example, even if a Binding returns ERC721 token 42, it does not include the current owner's address. A binding contract that uses ownership as a control condition can identify the current controller only after calling ownerOf(42) on the external token contract. Decoding metadata alone must therefore not be used to authorize signatures or asset operations.

Risks of the Canonical Contract and Upgrades

Using a single canonical binding contract per chain lets clients and indexers focus their evaluation and monitoring on one contract. However, if that contract returns an incorrect Binding, none of the affected agentId values registered with it can be reliably verified.

Clients should examine the binding contract's code, audit results, operational history, and upgradeability. Even an upgradeable binding contract must preserve the agent-binding address and registered Binding values after an upgrade. A contract whose administrative privileges allow registered standard, tokenContract, or tokenId values to be changed does not satisfy ERC8217's requirements.

If multiple binding contracts are deployed on the same chain, clients must evaluate each separately and indexers must monitor each contract's AgentBound events. ERC8217 uses a single canonical contract per chain to avoid fragmenting the basis for trust and monitoring.

Format Boundaries

agent-binding represents only a 20-byte EVM address. Because it contains no chain ID, clients interpret it together with the context of the call, specifically the chain on which they read the ERC8004 registry's metadata.

This format cannot represent addresses on non-EVM chains. Bindings to tokens on non-EVM chains and bindings across chains are outside the scope of ERC8217.

Registries and adapters registering agents protect agent-binding as a reserved key and reject overwrites by untrusted callers. On the client side, a value being 20 bytes long does not establish that it is the canonical binding contract. Clients must check that it is the contract adopted on that chain before trusting bindingOf.

The official ERC8217 specification is available here.

Conclusion

ERC8217 records a binding contract's 20-byte address in ERC8004 metadata and retrieves the token standard, token contract, and token ID through bindingOf(agentId). The Binding remains immutable, while the current controller is determined from ownership or balances of the external token. This enables control of an agent to follow transfers of the external token without rewriting registration information.

I also publish articles on other platforms.