ERC-8121 Cross-chain function call hook (Cross-Chain Function Calls via Hooks)

Draft · Names & metadata · created 2025-12-12

A standard that self-describingly embeds, within a metadata value, information about a specific function call on another chain, allowing a client to fetch data from a trusted contract on that other chain.

Why it is needed

At present, even when a contract's metadata value is meant to point to real data on another chain, such as proof of personhood (PoP) or a KYC certificate, there is no standardized way to express this. There was no common format for storing, as bytes or a string, which chain, which contract, which function, and with what values to call, in a way that anyone could interpret and invoke directly without accompanying documentation. As a result, cross-chain identity and credential lookups ended up implemented arbitrarily by each project, and plain text such as the markdown read by AI agents had no way to carry this call information in a human-readable form. There was also no standardized basis for a client to judge in advance whether a call target was trustworthy.

What to implement

In depth

Components of a hook

A hook consists of five elements: functionSelector (optional), functionSignature, functionCall, returnType, and target. functionSelector is a checksum hash of the signature that prevents type ambiguity; functionSignature is the full function signature with explicit types; functionCall is a human-readable call string with values filled in; returnType is the return tuple notation for ABI decoding; and target is an ERC-7930 interoperable address specifying the target chain and contract. These five elements alone let a hook be fully interpreted without external documentation.

Function call string format

functionCall uses Solidity-style syntax. String values are wrapped in single quotes ('value'), bytes/hex values use the 0x prefix, numbers are written as plain literals, arrays use square brackets ([1,2,3]), and structs/tuples use parentheses (('alice', 42, true)). These rules let even complex parameters, including nested structs, be expressed as a single human-readable line.

bytes and string encoding, and hook identification

In bytes storage, the hook MUST be ABI-encoded, prefixed with 0x037f43ed from keccak256("hook(bytes4,string,string,string,bytes)") if a selector is included, or 0x6113bfa3 from keccak256("hook(string,string,string,bytes)") if not. In string storage, it is written as a literal string of the form "hook(...)". A parser determines whether a selector is included by checking whether the first parameter after "hook(" is an 8-digit hex value starting with 0x.

Hook resolution procedure (reading)

The client detects the format from the value's prefix or the first parameter after "hook(" and parses functionSelector, functionSignature, functionCall, returnType, and target. If a selector is present, it hashes functionSignature to verify a match and rejects on mismatch. Decoding target as ERC-7930 to obtain the chain and address and checking whether the target is trustworthy is RECOMMENDED. The client extracts the function name and arguments from functionCall, ABI-encodes them using the functionSignature types, then calls the target function with ERC-3668 mandatorily enabled and receives the result. If the target is not trusted, the client MAY choose not to resolve the hook.

Write Operations

Writes follow the same flow as reads, but instead of querying a result they submit a signed transaction to the network for inclusion in a block. The function, parameters, target contract, and chain specified by the hook are used the same way.

Why both a selector and a string are used

The 4-byte selector unambiguously distinguishes types that a string alone cannot, such as getData(bytes32) versus getData(bytes), while the string stays human readable. The client can verify that the selector matches the signature and reject a mismatch as an error or a tampering attempt. ERC-7930 is used so that the hook, including chain information, becomes a complete cross-chain call specification, and returnType is included so clients can predict and decode the shape of the return value without needing documentation.

Mandatory ERC-3668 and security considerations

The hook explicitly requires ERC-3668 (CCIP-Read) support. Some clients disable ERC-3668 by default, but by tying it to the hook they can selectively enable it only for trusted hook resolution without turning on the full feature. For security, clients SHOULD maintain a list of trustworthy target addresses or a third-party registry and fail resolution for untrusted targets. It is also recommended to limit resolution depth to around 3 to 5 levels to prevent infinite loops caused by a hook pointing to another hook.

Status: Draft

This proposal is still in Draft status, and its content may change or be discontinued.

Things to watch out for

Original ERC · ← ERCs