ERC-8338 Token-bound executable skill (Token-Bound Executable Skills)
Draft · NFTs & multi-token · created 2026-07-10
Binds an AI agent's executable skill package (a bundle of documents and files) to an ERC-721 token via a hash, so content changes can be verified and update authority and privacy can be managed separately from ownership.
Why it is needed
AI agents can have on-chain identities like ERC-8004 or smart accounts like ERC-4337, but the skills they actually execute are stored in centralized registries. Such registries cannot be verified or owned, and there is no way to know if an operator silently changes the content, making them a root cause of supply chain attacks. tokenURI is merely a display pointer shown in wallet interfaces and does not guarantee that the content has not changed. Even if a registry or package manager can identify, locate, and distribute a skill, it cannot answer a more fundamental question that the execution runtime needs: exactly which document and file composition, which version, and which update history is the token bound to. Without a common artifact-binding model, different clients may apply different companion files, different update histories, and different confidentiality interpretations even for the same skill.
What to implement
function skillOf(uint256 tokenId) external view returns (SkillBinding memory);: Returns a SkillBinding containing the mdHash, packageHash, and version values bound to the token.function skillURI(uint256 tokenId) external view returns (string memory);: Returns a transport hint URI from which the package for that token can be fetched.function updateAuthorityOf(uint256 tokenId) external view returns (address);: Returns the address authorized to update the content of that token.function isSkillFrozen(uint256 tokenId) external view returns (bool);: Returns whether the content of that token has been permanently frozen.function updateSkill(uint256 tokenId, bytes32 mdHash, bytes32 packageHash) external;: Atomically updates the token's mdHash and packageHash and increments version by 1.function setSkillURI(uint256 tokenId, string calldata packageURI) external;: Updates packageURI, the package transport hint. version does not change.function setUpdateAuthority(uint256 tokenId, address newAuthority) external;: Changes the update authority of that token. It cannot be changed to the zero address.function freezeSkill(uint256 tokenId) external;: Permanently freezes the content of that token so it can no longer be updated.event SkillUpdated(uint256 indexed tokenId, bytes32 mdHash, bytes32 packageHash, uint64 version);: Announces the new mdHash, packageHash, and version when a token's binding is minted or updated.event SkillURIUpdated(uint256 indexed tokenId, string packageURI);: Announces that a token's packageURI has changed.event SkillUpdateAuthorityChanged(uint256 indexed tokenId, address indexed previousAuthority, address indexed newAuthority);: Announces the previous and new authority when a token's update authority changes.event SkillFrozen(uint256 indexed tokenId);: Announces that a token's content has been frozen.function hasOnchainSkillDocument(uint256 tokenId) external view returns (bool);: Returns whether a plaintext copy of that token's source document exists on chain. Once it becomes true, it remains true permanently.function skillDocument(uint256 tokenId) external view returns (bytes memory document);: Returns the exact plaintext UTF-8 bytes of the source document stored on chain. Reverts if no copy exists.function updateSkillWithDocument(uint256 tokenId, bytes calldata document, bytes32 packageHash) external;: Updates the on-chain document and the binding together in a single transaction. mdHash is computed from the document inside the contract.function publishSkillDocument(uint256 tokenId, bytes calldata document) external;: Publishes an existing source document on chain for the first time without changing version or packageHash.event SkillDocumentPublished(uint256 indexed tokenId, bytes32 mdHash);: Announces, together with mdHash, that a source document has been published on chain.
In depth
Core binding: mdHash, packageHash, version
The SkillBinding struct in ISkillToken consists of mdHash (the SHA-256 hash of the plaintext source document), packageHash (the SHA-256 hash of the deterministically encoded bytes of the entire published SkillRoot), and version (the content version, starting at 1). At mint time all three values must be populated, version must be 1, and mdHash and packageHash cannot be bytes32(0). An update changes mdHash and packageHash atomically in a single call to updateSkill, and the new packageHash must differ from the existing value, but mdHash can remain unchanged if the source document itself did not change. version is not specified by the caller; the contract increments it by exactly 1 on every successful update and reverts on uint64 overflow.
Separation of identity and transport
A skill's identity consists of the three values (mdHash, packageHash, version), and packageURI is merely a transport hint indicating where to download the package, and is not part of the identity. setSkillURI does not change version and only emits SkillURIUpdated, so replacing a dead endpoint with a new address does not create a new skill version. packageURI must not be treated as a trusted input; consumers must verify downloaded content against the committed values regardless of where it was obtained, and discard it if it does not match.
Publishing authority is distinct from ownership
updateAuthorityOf(tokenId) is initialized at mint time, and only the current update authority may call updateSkill, updateSkillWithDocument, setSkillURI, setUpdateAuthority, or freezeSkill. ownerOf does not automatically become the update authority, ERC-721 transfers do not change the update authority, and approved/operator approvals do not grant these authorities either. setUpdateAuthority(tokenId, address(0)) must revert, because relinquishing management should be expressed through freezeSkill rather than by zeroing out the authority. A zero-address authority would be the worst possible state, since it would make packageURI permanently unfixable while leaving frozen as false.
Freezing binds only the content
freezeSkill is irreversible and must emit SkillFrozen, and once frozen, updateSkill and updateSkillWithDocument revert forever. Freezing binds only the content, mdHash, packageHash, and version, not the transport, so setSkillURI and setUpdateAuthority remain callable after freezing. This is so that if a particular storage provider disappears, the discovery hints for a frozen skill can still be kept alive.
Definition of the hashes
mdHash is the SHA-256 of the raw bytes of the plaintext source markdown document as is, with no line-ending, whitespace, BOM, or Unicode normalization, and no salt or key. Even if the published copy is encrypted, the commitment target is always the plaintext. packageHash is the SHA-256 of the deterministically encoded SkillRoot bytes, that is, the package exactly as published, and in confidential mode it targets the ciphertext objects. It is not the hash of a zip, tar, or .skill archive.
SkillRoot: an off-chain object graph
SkillRoot is an object encoded as CBOR following the deterministic encoding rules of RFC 8949 (fixed length, shortest-form integers, map keys sorted by encoded bytes), containing md (source document), manifest (link to the public manifest), entry (execution entry point), and optionally license, files, confidentiality, and prev. Every object is referenced by CID, and paths must be relative, case-sensitive UTF-8 POSIX paths, matched only byte-for-byte. There is exactly one source document, and it cannot reappear as a key in files; if version is greater than 1, prev must be present, and the digest within it must equal the packageHash of the immediately preceding version. If entry.path equals md.path, entry.cid must equal md.cid; otherwise files[entry.path] must equal entry.cid.
Optional on-chain document extension
IOnchainSkillDocument is an optional extension that publishes the source document on chain in plaintext. hasOnchainSkillDocument must remain permanently true once it becomes true, and publishSkillDocument publishes the current document without changing packageHash or version, succeeding only if sha256(document) equals the existing mdHash. updateSkillWithDocument is used when the document content actually changes; it computes mdHash inside the contract as sha256(document) and updates the document, both hashes, and version in a single transaction. For a token with an on-chain document, any updateSkill call that changes mdHash must revert and must instead go through updateSkillWithDocument. If the source document is confidential, hasOnchainSkillDocument must return false and skillDocument must revert.
The confidentiality descriptor, verification procedure, and relationship to other standards
The confidentiality descriptor is public JSON that exists only when a confidentiality link is present; schemaVersion, mode, profile, and objects are required, and objects records, per path, ciphertext (which must match the CID in the SkillRoot) and plaintextHash (the SHA-256 of the plaintext). Public-mode verification proceeds by fetching the SkillRoot, checking packageHash, the path rules, and the version chain, then verifying each leaf by CID, while confidential mode first verifies the ciphertext by CID, then proves authorization, obtains the key according to the profile, decrypts, and finally confirms the plaintext hash. Unlike ERC-4907 (usage roles) and ERC-5169 (contract-level scripts), this standard binds content-addressed executable artifacts at the token level, and it is used complementarily alongside ERC-1155-based rights contracts or registries like ERC-8257, with each handling a separate role. This proposal is currently in Draft status, not yet finalized, and its details may change or discussion may stall.
Things to watch out for
- The update functions are the core attack surface: Swapping in different content without changing the hash is computationally infeasible, so the risk concentrates in the update functions. Mitigations include an independent update authority (not reachable via ERC-721 approvals), irreversible freezing, append-only versioning with a closed prev chain, and runtime version-pinning practices, while gating with timelocks or approval procedures is left to auxiliary extensions.
- Publishing authority must be checked before purchase: Transferring ERC-721 ownership does not transfer the update authority along with it, so a buyer must check updateAuthorityOf and isSkillFrozen before acquiring the token. Buying a token whose update authority remains with a third party is equivalent to buying an asset that the third party can still modify.
- Skill content is untrusted input: Prompt injection targets LLM runtimes through the source document. This standard guarantees only integrity, not that the content is harmless, so runtimes must sandbox execution with least-privilege tools, and content vetting is the job of an attestation or reputation layer.
- Publishing plaintext on chain is irreversible: A document published through the on-chain document extension cannot be made secret again, and the permanent true state of hasOnchainSkillDocument reflects this. Switching to encrypted mode in a later version does not erase the past plaintext left in the chain's history.
- A plaintext commitment can reveal equivalence: A published mdHash or plaintextHash can be used to confirm identity of content, so an attacker who can guess the exact bytes of a document can confirm that guess by matching it against the hash. This exposure should be considered when publishing short or easily guessable confidential documents.