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.

ERC-7786 proposes a standard interface for sending and receiving messages between smart contracts on different blockchains.

This article explains and expands on the proposal below.

I also cover EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.

Overview

ERC-7786 specifies a common interface and workflow for smart contracts to send arbitrary data through cross-chain messaging protocols. It aims to make different messaging protocols, or bridges, accessible through the same interface, improving interoperability and composability across chains.

A contract designed to operate across several chains can send messages through the interface without integrating a particular bridge directly. This reduces vendor lock-in and makes it easier to switch providers.

The design is modular. Bridges can expose their own features as attributes, or structured metadata, while simple messages use the same core interface. Applications can therefore use a common path for basic messages and attach additional information when they need more control.

Motivation

Different approaches to cross-chain messaging

Cross-chain messaging protocols let smart contracts on separate blockchains communicate. Their designs vary in several ways.

Aspect How protocols differ
Decentralization Some use decentralized validation. Others rely on a central validator.
Architecture Relaying, authentication, and transfer rules differ.
Interface Each protocol has its own APIs or sending functions.
Guarantees Protocols differ in finality, safety, and whether they guarantee retries.

Because their workflows and interfaces differ, code written for one bridge rarely works with another unchanged. Developers have to write bridge-specific code, which makes switching bridges and building reusable cross-chain contracts difficult.

What the proposal aims to achieve

ERC-7786 standardizes the interface and workflow for communication between smart contracts on different chains. It lets applications use the same function calls across messaging protocols, use a bridge without embedding its internal procedures in application code, and combine several bridges in a single application.

A protocol that does not implement the standard natively can support the interface through a gateway adapter contract.

Comparison with earlier ERCs

The Japanese article contrasts ERC-7786 with earlier approaches focused mainly on Ethereum and EVM-compatible chains.

Aspect Earlier approaches ERC-7786
Chain scope Ethereum and EVM-compatible chains Designed to accommodate other chains, including non-EVM chains
Extensibility Adding features can be difficult Attributes can carry additional structured metadata
Bridge dependence Often designed for a particular bridge Adapters can expose a common interface
Interoperability Partial A shared workflow supports integrations across bridges

The interface is designed for use beyond Ethereum and can form part of a system that spans several blockchains.

Specification

Message field encoding

Field Description
Sender The sending account or contract on the source chain
Recipient The receiving account or contract on the destination chain
Payload The message body as binary data
Value Native token value sent with the message
Attributes A list of attributes carrying additional information

Sender and recipient

The sender and recipient use the Interoperable Address format defined by ERC-7930, with binary serialization following CAIP-350.

For more on ERC-7930, see the following article.

[ERC-7930] One address format for multiple chains

For more on CAIP-350, see the following article.

[CAIP-350] Address conversion across chains

The specification describes broadcast mode for an unspecified or zero-value recipient address. The bridge protocol selects the final recipient in this mode.

Payload

The payload is an opaque byte sequence carrying arbitrary data. A bridge forwards those bytes without interpreting their contents.

Attributes

Each attribute is a key-value pair carrying additional information. The key determines the attribute's encoding and meaning to the gateway.

The mechanism is extensible. Attributes intended for standard use can be proposed as additional ERCs. A gateway can choose which standard or custom attributes to support.

Component Description
Attribute key A four-byte value, preferably derived as a Solidity function selector. For example, minGasLimit(uint256) yields 0x39f87ba1.
Attribute value A byte sequence whose type and meaning are defined by the key.

The list is encoded as bytes[]. Each element concatenates the key and value. It can be encoded with abi.encodeWithSignature. An empty attribute list is valid.

Sending a message

A message is sent through a contract called the source gateway. It must implement IERC7786GatewaySource.

IERC7786GatewaySource

javascript
interface IERC7786GatewaySource {
    event MessageSent(
        bytes32 indexed sendId,
        bytes sender,    // Binary Interoperable Address
        bytes recipient, // Binary Interoperable Address
        bytes payload,
        uint256 value,
        bytes[] attributes
    );

    error UnsupportedAttribute(bytes4 selector);

    function supportsAttribute(bytes4 selector) external view returns (bool);

    function sendMessage(
        bytes calldata recipient, // Binary Interoperable Address
        bytes calldata payload,
        bytes[] calldata attributes
    ) external payable returns (bytes32 sendId);
}

MessageSent

javascript
event MessageSent(
    bytes32 indexed sendId,
    bytes sender,
    bytes recipient,
    bytes payload,
    uint256 value,
    bytes[] attributes
);

The source gateway emits this event when it receives a request to send a message to another chain. If the send returns an identifier, post-processing may be required to activate delivery.

Parameters

  • sendId
    • A unique identifier for the send operation.
  • sender
    • The source address in Interoperable Address format.
  • recipient
    • The destination address in Interoperable Address format.
  • payload
    • The message body.
  • value
    • The amount of native tokens attached to the call.
  • attributes
    • The list of message attributes.

UnsupportedAttribute

javascript
error UnsupportedAttribute(bytes4 selector);

The gateway uses this error when a request includes an attribute key it does not support.

Parameters

  • selector
    • The unsupported four-byte attribute key.

supportsAttribute

javascript
function supportsAttribute(bytes4 selector) external view returns (bool);

Checks whether the gateway supports a given attribute. A gateway can add support for more attributes over time. Removing support for an existing attribute is discouraged because it can break existing integrations.

Argument

  • selector
    • The attribute key.

Return value

  • bool
    • true if the gateway supports the attribute and false otherwise.

sendMessage

javascript
function sendMessage(
    bytes calldata recipient,
    bytes calldata payload,
    bytes[] calldata attributes
) external payable returns (bytes32 sendId);

Starts the process of sending a message to a recipient on another chain. Other actions, such as paying for gas, may be necessary to enable delivery.

  • The gateway reverts with UnsupportedAttribute if the request includes an unsupported attribute.
  • It may revert for other invalid input.
  • It reverts if the gateway does not allow the requested native token value.
  • It may return a unique sendId for the message.
  • That sendId can be used to track the send or complete post-processing.

Arguments

  • recipient
    • The destination address in Interoperable Address format.
  • payload
    • The data to send.
  • attributes
    • The list of attributes attached to the message.

Return value

  • sendId
    • The unique identifier for the send, or zero if no identifier is returned.

Post-processing

A message may require additional work after sendMessage returns before it can be delivered. For example, a participant might have to pay for its execution on the destination chain. ERC-7786 leaves the interface and procedures for those actions to the messaging protocol.

Receiving a message

The destination gateway verifies the message and delivers it to the recipient contract. ERC-7786 does not prescribe how that gateway is implemented or invoked. The recipient must implement the following interface.

IERC7786Recipient

javascript
interface IERC7786Recipient {
    function receiveMessage(
        bytes32 receiveId,     // Unique identifier
        bytes calldata sender, // Binary Interoperable Address
        bytes calldata payload
    ) external payable returns (bytes4);
}

receiveMessage

javascript
function receiveMessage(
    bytes32 receiveId,
    bytes calldata sender,
    bytes calldata payload
) external payable returns (bytes4);

The destination gateway invokes this method to deliver a message from another chain. The recipient must verify that the caller is a gateway it trusts. On success it must return 0x2432ef26, the selector of IERC7786Recipient.receiveMessage. The gateway reverts if the recipient returns a different value.

Arguments

  • receiveId
    • An identifier that is either empty or unique for the calling gateway.
  • sender
    • The source address in Interoperable Address format.
  • payload
    • The message body.

Return value

  • bytes4
    • The fixed value 0x2432ef26 indicating successful receipt.

Interaction diagram

The following diagram shows how a message moves from the source gateway to the recipient.

Cross-chain message flow from source to destination https://eips.ethereum.org/EIPS/eip-7786

Properties

Safety

Safety means the destination receives only messages actually sent at the source, with no duplicate deliveries or delivery before finality.

Requirement Description
Authenticity The destination must never receive a message for which there is no send on the source chain.
At-most-once delivery Each send is eligible for delivery once. Two sends with identical content remain separate, and replay or fabrication must not create a new delivery.
Source finality Delivery must wait until the transaction on the source chain is finalized.

These requirements make cross-chain delivery dependable and prevent a previously delivered message from being executed again.

Liveness

Liveness means a sent message eventually reaches its destination. Safety on its own does not ensure a message will ever arrive. The liveness guarantee depends on the following assumptions.

Requirement Description
Chain availability The source and destination chains are operating normally and transactions are not censored.
Costs covered The necessary gas and protocol fees have been paid.
Verifiable relay path The message can be verified as it moves through relayers or bridges, and its contents are protected from tampering.

Under those assumptions, a healthy messaging protocol eventually delivers a sent message.

Timeliness

Timeliness means delivery within a stated bound. The property is recommended rather than required. It matters for time-sensitive applications such as games or financial transactions, where an indefinite wait can make an otherwise valid message unusable.

Requirement Description
Delivery bound Define a maximum delivery time and guarantee delivery within that interval.
Documentation Explain the time bound and latency characteristics so users can understand them.

Documented latency makes bridge performance easier to compare when choosing a provider.

Decentralized guarantees

Safety, liveness, and timeliness should not depend on trusting a central operator. The article gives these examples of mechanisms for decentralized safety.

Mechanism Description
Light client proof The destination verifies source chain blocks cryptographically without relying on a central intermediary.
Decentralized validator set A distributed network attests to message authenticity using signatures or certificates.

Preserving liveness also calls for decentralized or permissionless delivery. If a single relayer stops operating or refuses to relay messages, a protocol that depends on it can stall.

Rationale

Why use attributes

Attributes give bridges a way to expose protocol-specific features without adding new application-facing methods. Applications can keep the basic message format while changing the attributes when switching gateways. They are less tied to one implementation and can support more than one deployment pattern.

Portability in practice

Situation Dedicated interface Common interface with attributes
Gateway outage or retirement Applications may need to change or redeploy their contracts. An application that stores a configurable gateway address can update the address.
Upgrading to a new version Message formats or calling procedures may change. Applications can keep the message format and capture differences in attributes.
Vendor lock-in Higher Lower
Using multiple bridges Requires separate integrations Routing is easier to implement behind the common interface.

This flexibility can reduce downtime and maintenance effort.

Combining bridges

A gateway can move messages through more than one independent bridge. Accepting a message when any one bridge delivers it favors availability. Requiring confirmation through several bridges can favor safety, depending on the trust assumptions. Applications can choose a policy suited to their needs.

Extra parameters and post-processing

Some protocols need more than the destination and payload, such as a gas limit or execution fee on the destination chain. ERC-7786 allows additional steps after sendMessage and before delivery so callers do not need every protocol-specific value when first submitting the message.

Method How it works Result
Specify an attribute Attach the additional parameter to the message. No follow-up call is needed.
Make a follow-up call Supply the missing input after submitting the message. Required when the needed value was omitted. The protocol should let another party supply it.

Ideally, any participant can help complete delivery. An attempt to supply an invalid parameter should leave other participants able to provide a valid one.

Arbitrary calls and their risks

Some gateways can call a recipient directly with arbitrary calldata. The recipient then has to identify the call as a cross-chain invocation and may need to query the gateway for information such as the source chain and sender.

This capability can be dangerous if the gateway holds assets or permissions. An untrusted message should never be able to direct a gateway to exercise its own privileges. A dedicated receiveMessage endpoint keeps receipt separate from the gateway's assets and permissions.

An application that needs arbitrary execution can implement it in a separate recipient wrapper. The wrapper must validate the message before deciding whether to forward the call.

javascript
// 擬似コード(Solidity風)。任意コールの安全なラッパー例。
interface IERC7786Recipient {
    function receiveMessage(bytes32 receiveId, bytes calldata sender, bytes calldata payload)
        external payable returns (bytes4);
}

contract SafeArbitraryCallWrapper is IERC7786Recipient {
    address public immutable trustedGateway;

    constructor(address _gateway) {
        trustedGateway = _gateway;
    }

    function receiveMessage(bytes32 receiveId, bytes calldata sender, bytes calldata payload)
        external payable override returns (bytes4)
    {
        // 1) ゲートウェイ検証
        require(msg.sender == trustedGateway, "unauthorized gateway");

        // 2) ペイロードの検証・デコード(例:dst, data, value等)
        (address dst, bytes memory data, uint256 callValue) = abi.decode(payload, (address, bytes, uint256));

        // 3) 任意コールの安全実行(reentrancy/戻り値チェック等は実装ポリシーに従う)
        (bool ok, ) = dst.call{value: callValue}(data);
        require(ok, "call failed");

        // 4) 規定のセレクタを返す
        return this.receiveMessage.selector; // 0x2432ef26 と同値
    }
}

The excerpt illustrates gateway authentication, payload decoding, and forwarding. For production use, it also needs an application-specific authorization policy for the remote sender, the destination, and the value. Checking the gateway alone does not establish that the message sender is authorized to execute the payload.

Compatibility

Many existing cross-chain protocols expose their own interfaces. ERC-7786 recommends native support where practical and gateway adapters where a direct implementation is unavailable.

Component Role
Existing protocol Keeps its own endpoints and procedures.
Gateway adapter Maps the common sendMessage and receiveMessage flows to the existing protocol's operations.
Application contract Uses the common interface while bridge switching and combination happen behind it.

This makes incremental adoption possible and supports interoperability without requiring every protocol to change at once.

Security considerations

Address handling

ERC-7786 assumes canonical serialization for ERC-7930 Interoperable Addresses under CAIP-350. If implementations accept noncanonical forms, they may identify the same address differently and silently fail to deliver a message or deliver it incorrectly.

Practice Details
Reject noncanonical encodings Validate the format and reject extra zero bytes, incorrect lengths, or invalid network identifiers.
Normalize supported variations Convert supported variations to canonical form before emitting events or writing values to storage.
Make events easy to audit Emit canonical values in events such as MessageSent so operators can compare logs and monitor delivery.

Strict validation and a narrowly defined normalization policy help keep address handling consistent across chains and implementations.

Citation

Francisco Giordano (@frangio), Hadrien Croubois (@Amxx), Ernesto Garcia (@ernestognw), CJ Cobb (@cjcobb23), Sergey Gorbunov (@sergeynog), joxes (@Joxess), "ERC-7786: Cross-Chain Messaging Gateway," Ethereum Improvement Proposals, no. 7786, October 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7786.

Conclusion

ERC-7786 provides a shared interface for smart contracts to exchange messages across blockchains. Attributes and adapters let applications use the same interface with different messaging protocols.

Questions are welcome by direct message.

Twitter @cardene777

I also publish elsewhere.

https://chaldene.net/