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.

This article examines ERC-6170, a proposal for a common interface that applications can use to interact with messaging protocols and exchange messages across different blockchains.

Messaging protocols

A messaging protocol is a set of rules and standards for exchanging information between computer systems or software components. It defines the format, ordering, timing, and transmission of data so that different systems and applications can communicate efficiently and correctly.

Messaging protocols are particularly important in distributed networks and blockchain environments, where nodes and contracts need common rules to communicate. They enable applications to exchange data, initiate transactions, and invoke smart contract functionality across blockchains and layers, depending on the capabilities of the underlying infrastructure.

For example, if an Ethereum smart contract needs to use information from the Bitcoin network, it requires a mechanism for transmitting and interpreting that information. A common messaging protocol can facilitate such interactions between different blockchain systems, allowing applications to work with a broader range of digital assets and data.

The explanation below translates, summarizes, and expands on the original proposal.

ERC-6170 was at the Draft stage as of December 8, 2023.

I also cover a range of other ERCs.

Overview

This EIP proposes a common interface for cross-chain arbitrary message bridges (AMBs) that send and receive messages between different blockchains.

The goal is to standardize how applications exchange information across chains. A contract on Ethereum could, for example, interact with infrastructure connected to another network such as Bitcoin.

Such an integration might allow an Ethereum contract to obtain information about Bitcoin or initiate an operation supported by the destination network. The actual capabilities depend on the bridge implementation and the destination chain. The interface alone does not enable arbitrary Ethereum-style contract calls on Bitcoin.

The standard is particularly relevant to applications that move assets such as ERC-20 and ERC-721 tokens across blockchains. Cross-chain contract interactions can also support more complex applications that handle digital assets and data across multiple networks.

This proposal defines an interface rather than prescribing a particular bridge implementation.

Motivation

Cross-chain arbitrary message bridges do not all expose the same interface. Protocols such as LayerZero, Hyperlane, Axelar, Wormhole, and Matic State Tunnel use different approaches. Both chain-specific messaging mechanisms and independent message bridges face this integration problem.

The proposal introduces a standardized interface for AMBs, with several anticipated benefits.

Easier development

A common interface allows developers to build applications that operate across different blockchains without implementing a completely different application-facing interface for every bridge.

Improved scalability

Cross-chain applications can integrate and use multiple message bridges more efficiently.

Improved security

Different message bridges have different security characteristics. For example, the proposal discusses the use of nonces in LayerZero and Merkle root hashes in Hyperlane in the context of message verification and replay protection. A standardized interface can help applications express common security-related requirements, although the interface does not make the underlying security models equivalent.

Improved resilience

Message bridges that depend on off-chain components may be exposed to censorship and downtime. Applications built on such infrastructure may otherwise require substantial state migration when a bridge fails, which can be impractical for large and complex systems. A common interface can reduce the integration burden when changing or adding messaging infrastructure.

Specification

All conforming cross-chain arbitrary message bridges must implement the following interface.

javascript
// SPDX-License-Identifier: Apache-3.0

pragma solidity >=0.8.0;

/// @title Cross-Chain Messaging interface
/// @dev Allows seamless interchain messaging.
/// @author Sujith Somraaj
/// Note: Bytes are used throughout the implementation to support non-evm chains.

interface IEIP6170 {
    /// @dev This emits when a cross-chain message is sent.
    /// Note: MessageSent MUST trigger when a message is sent, including zero bytes transfers.
    event MessageSent(
        bytes to,
        bytes toChainId,
        bytes message,
        bytes extraData
    );

    /// @dev This emits when a cross-chain message is received.
    /// MessageReceived MUST trigger on any successful call to receiveMessage(bytes chainId, bytes sender, bytes message) function.
    event MessageReceived(bytes from, bytes fromChainId, bytes message);

    /// @dev Sends a message to a receiving address on a different blockchain.
    /// @param chainId_ is the unique identifier of receiving blockchain.
    /// @param receiver_ is the address of the receiver.
    /// @param message_ is the arbitrary message to be delivered.
    /// @param data_ is a bridge-specific encoded data for off-chain relayer infrastructure.
    /// @return the status of the process on the sending chain.
    /// Note: this function is designed to support both evm and non-evm chains
    /// Note: proposing chain-ids be the bytes encoding their native token name string. For eg., abi.encode("ETH"), abi.encode("SOL") imagining they cannot override.
    function sendMessage(
        bytes memory chainId_,
        bytes memory receiver_,
        bytes memory message_,
        bytes memory data_
    ) external payable returns (bool);

    /// @dev Receives a message from a sender on a different blockchain.
    /// @param chainId_ is the unique identifier of the sending blockchain.
    /// @param sender_ is the address of the sender.
    /// @param message_ is the arbitrary message sent by the sender.
    /// @param data_ is an additional parameter to be used for security purposes. E.g, can send nonce in layerzero.
    /// @return the status of message processing/storage.
    /// Note: sender validation (or) message validation should happen before processing the message.
    function receiveMessage(
        bytes memory chainId_,
        bytes memory sender_,
        bytes memory message_,
        bytes memory data_
    ) external payable returns (bool);
}

Events


MessageSent

javascript
event MessageSent(
    bytes to,
    bytes toChainId,
    bytes message,
    bytes extraData
);

Overview

An event emitted when a cross-chain message is sent.

Details

The event must be triggered whenever a message is sent, including messages with a zero-length payload. This allows external observers to monitor messages dispatched to other chains.

Parameters

  • to
    • The destination address, represented as bytes.
  • toChainId
    • The destination chain identifier, represented as bytes.
  • message
    • The message payload, represented as bytes.
  • extraData
    • Additional data, represented as bytes.

MessageReceived

javascript
event MessageReceived(bytes from, bytes fromChainId, bytes message);

Overview

An event emitted when a cross-chain message is successfully received.

Details

The event must be triggered on successful execution of the message reception function. It allows external observers to determine that a message from another chain has been successfully received.

Parameters

  • from
    • The source address, represented as bytes.
  • fromChainId
    • The source chain identifier, represented as bytes.
  • message
    • The received message payload, represented as bytes.

Functions


sendMessage

javascript
function sendMessage(
    bytes memory chainId_,
    bytes memory receiver_,
    bytes memory message_,
    bytes memory data_
) external payable returns (bool);

Overview

Sends a message to a recipient on another blockchain.

Details

The function accepts the destination chain's unique identifier (chainId_), the recipient address (receiver_), an arbitrary message payload (message_), and bridge-specific encoded data for off-chain relayer infrastructure (data_). It uses byte arrays to accommodate both EVM and non-EVM chains.

Arguments

  • chainId_
    • The unique identifier of the destination blockchain, represented as bytes.
  • receiver_
    • The recipient address, represented as bytes.
  • message_
    • The arbitrary message payload to deliver, represented as bytes.
  • data_
    • Bridge-specific encoded data for off-chain relayer infrastructure, represented as bytes.

Return value

  • Returns true on success on the sending chain. This does not by itself establish successful delivery or execution on the destination chain.

receiveMessage

javascript
function receiveMessage(
    bytes memory chainId_,
    bytes memory sender_,
    bytes memory message_,
    bytes memory data_
) external payable returns (bool);

Overview

Receives a message from a sender on another blockchain.

Details

The function accepts the source chain's unique identifier (chainId_), the sender's address (sender_), an arbitrary message payload from the sender (message_), and additional security-related data (data_). Sender authentication or message validation should take place before the message is processed.

Arguments

  • chainId_
    • The unique identifier of the source blockchain, represented as bytes.
  • sender_
    • The sender's address, represented as bytes.
  • message_
    • The arbitrary message payload from the sender, represented as bytes.
  • data_
    • Additional data used for security-related purposes, represented as bytes.

Return value

  • Returns true or false, indicating the status of message processing or storage.

Rationale

This Ethereum Improvement Proposal introduces a common cross-chain arbitrary messaging interface to simplify interactions between different blockchains. The interface is deliberately minimal and lightweight while providing essential messaging functionality. It accommodates bridges between different networks and leaves room for innovation in the underlying relayer infrastructure.

The proposal aims to make cross-chain applications easier to build and scale. Its scope is not limited to Ethereum and compatible Layer 2 networks; applications can also integrate other pairs of blockchains where suitable messaging infrastructure exists. For example, an application connecting Ethereum and Solana could take advantage of capabilities offered by both networks.

The interface also aims to reduce the risk of a single point of failure (SPOF) in applications and protocols. An application designed to support interchangeable bridges may be able to update its AMB address and continue operating when the original infrastructure becomes unavailable. Safe migration still requires consideration of pending messages, authorization, and the new bridge's trust assumptions.

A single point of failure (SPOF) is a component of a system or network whose failure causes the entire system to stop functioning. The term is common in information technology and engineering.

For example, if all network traffic must pass through one server, failure of that server can disrupt the entire network. Similarly, if a system depends on a single power supply, a problem with that supply can affect the whole system.

System designers generally mitigate single points of failure through redundancy. Critical functions may have backups, or alternative routes and components may be provided so that the failure of one component does not disable the entire system. This improves overall reliability and resilience.

Security considerations

The proposal notes that unrestricted message submission may present security risks to a protocol. Developers integrating a messaging tunnel are therefore encouraged to examine its implementation carefully.

Without proper sender authentication, an arbitrary party could potentially submit messages to a receiving contract and cause unauthorized state changes.

The EIP focuses on standardizing how messages are sent and received. Integrators can use the data_ parameter to implement additional authentication or bridge-specific processing within the reception function. These mechanisms must be validated against the underlying bridge's security model; merely accepting additional data does not authenticate a message.

Citation

Sujith Somraaj (@sujithsomraaj), "ERC-6170: Cross-Chain Messaging Interface [DRAFT]," Ethereum Improvement Proposals, no. 6170, December 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6170.

Conclusion

This article covered ERC-6170, a proposal for a common interface through which applications can interact with messaging protocols and send or receive messages across blockchains.

If you have questions, feel free to reach out via Twitter DM.

Twitter @cardene777

I also publish on the following platforms.

https://chaldene.net/