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 covers ACP108, which proposes a standard mechanism for securely importing and using events emitted on another chain within Avalanche.

This article translates, summarizes, and expands on the proposal linked below.

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

Overview

ACP108 defines a standard smart contract interface and an abstract implementation for importing EVM events from any L1 blockchain within Avalanche. Specifically, it uses Avalanche Warp Messaging (AWM) to enable applications to reference events across chains. Smart contracts can thus work with events emitted on other Avalanche L1 chains and with state changes on those chains without requiring the chains to interact directly.

Motivation

Avalanche Warp Messaging is implemented in components such as coreth and subnet-evm, which already provide a way to obtain authenticated block hashes. An authenticated block hash establishes that the block has been accepted within Avalanche. In addition, the acceptance proofs proposed by ACP75 (Acceptance Proofs) allow events and state changes within that block to be verified.

At the time of the proposal, however, there was no clear standard for handling these authenticated block hashes inside smart contracts. Application developers attempting to use this mechanism for cross-chain data face two challenges.

  • They must supply the contract with an encoded block header matching the block hash.
  • They must verify Merkle proofs against the state root or receipts root contained in that header.

Implementing these complex operations from scratch takes time and reduces development efficiency.

A standard interface and abstract contract can make the following operations reusable, allowing developers to work more easily with data from other Avalanche L1 chains.

  • Handling authenticated block hashes
  • Verifying Merkle proofs

This simplifies cross-chain application development and supports the growth of the Avalanche ecosystem.

Specification

ACP108 defines a standard interface and abstract implementation for securely importing EVM events from another Avalanche chain, building on Warp Messaging (the cross-chain messaging mechanism) and authenticated block hashes. The goal is to let developers use other chains' events in their own contracts without implementing complex low-level operations such as block header processing and Merkle proofs (proofs that data is included in a block).

Purpose of EventImportingInterface

importEvent imports a single EVM event emitted on another Avalanche chain into a contract on the target chain. An event is uniquely identified by the source chain ID, block header, transaction index (the transaction's position within the block), and event index (the event's position within the transaction).

The import process performs the following checks.

  1. The hash computed from the supplied blockHeader must match an authenticated block hash for that chain.
  2. Against the receiptsroot in blockHeader (the Merkle root covering all transaction receipts in the block), the supplied receiptProof must be valid and demonstrate that the target transaction receipt is included.

If both checks succeed, the event log identified by logIndex is extracted from the receipt, and an EventImported event is emitted. The notification identifies the chain, block, and contract that originally emitted the event.

importEvent

js
function importEvent(
    bytes32 sourceBlockchainID,
    bytes calldata blockHeader,
    uint256 txIndex,
    bytes[] calldata receiptProof,
    uint256 logIndex
) external;

Parameters

Parameter Purpose Details
sourceBlockchainID Identifier of the source blockchain Check that the authenticated block hash associated with this ID matches blockHeader.
blockHeader Encoded EVM block header of the source block Decode the header, check that hash(blockHeader) matches the authenticated hash, and obtain receiptsroot.
txIndex Zero-based transaction position within the block Identifies the key in the receiptsTrie.
receiptProof Merkle proof that the receipt at txIndex is included under receiptsroot Successful verification yields the encoded transaction receipt itself.
logIndex Position of the log (event) to import within the receipt Identifies the specific Log to import.

Required verification

Check Purpose Example success condition
Block hash authentication Confirm that the source block has been accepted within Avalanche hash(blockHeader) matches an authenticated block hash
receiptProof verification Confirm that the receipt at txIndex is included under receiptsroot Verifying receiptProof recovers that receipt
Log extraction Retrieve the intended event log logs[logIndex] exists in the receipt and can be retrieved

Block hash authentication options

The interface does not mandate the use of the Warp precompile. Two implementation approaches are envisaged.

Approach Description Advantages
Call the Warp precompile directly within the transaction Retrieve and check the authenticated block hash from the Warp precompile in the transaction calling importEvent. Fewer external state dependencies; self-contained and easy to understand.
Authenticate in advance using an external contract Store authenticated hashes in an external contract such as BlockHashRegistry, then look them up from importEvent. A single authentication can be reused multiple times. Alternative authentication mechanisms such as oracles are easier to support.

The following code illustrates an external lookup.

js
bool valid = blockHashRegistry.checkAuthenticatedBlockHash(
    sourceBlockchainID,
    keccak256(blockHeader) // ← 正: keccak256
);
require(valid, "Invalid block header");

The EventImported event

js
event EventImported(
    bytes32 indexed sourceBlockchainID,
    bytes32 indexed sourceBlockHash,
    address indexed loggerAddress,
    uint256 txIndex,
    uint256 logIndex
);
Field Meaning
sourceBlockchainID Source chain identifier
sourceBlockHash Hash of the imported block
loggerAddress Address of the contract that emitted the event on the source chain
txIndex Transaction position within the block
logIndex Log position within the receipt

This event records on-chain which chain, block, transaction, and log were imported.

Abstract contract behavior

The abstract contract standardizes the following operations inside importEvent.

  1. Obtain the authenticated block hash of the source chain and check whether it matches the supplied blockHeader.
  2. Extract receiptsroot from blockHeader.
  3. Use txIndex and receiptProof to verify the Merkle proof and recover the target transaction receipt.
  4. Extract the Log at logIndex from the receipt and package the metadata in EVMEventInfo.
  5. On success, emit EventImported and call the internal hook _onEventImport, handing control to the inheriting contract's business logic.

Functions and data structures

A contract inheriting this implementation needs to implement only one internal hook function.

js
function _onEventImport(EVMEventInfo memory eventInfo) internal virtual;

The associated structs are as follows.

js
struct EVMLog {
    address loggerAddress;
    bytes32[] topics;
    bytes data;
}

struct EVMEventInfo {
    bytes32 blockchainID;
    uint256 blockNumber;
    uint256 txIndex;
    uint256 logIndex;
    EVMLog log;
}
Struct Field Meaning
EVMLog loggerAddress Contract that emitted the event on the source chain
topics Event signature and hashes of indexed arguments
data Byte sequence containing non-indexed arguments
EVMEventInfo blockchainID Source chain ID
blockNumber Source block number
txIndex Transaction position within the block
logIndex Log position within the receipt
log Actual event log

Processing flow

  1. The client (or relayer) calls importEvent, passing sourceBlockchainID, blockHeader, txIndex, receiptProof, and logIndex.
  2. The implementation uses the Warp precompile or an external registry to check that keccak256(blockHeader) matches the authenticated block hash.
  3. If it matches, decode blockHeader and extract receiptsroot.
  4. Verify the Merkle proof using txIndex and receiptProof, then recover and decode the encoded receipt.
  5. Extract the Log at logIndex from the recovered receipt and format it as EVMEventInfo.
  6. Emit EventImported and call _onEventImport(eventInfo) to update state or perform application-specific processing.

Sequence diagram

The original Japanese diagram labels are retained.

sequenceDiagram
    participant Caller as Caller/Relayer
    participant Target as TargetContract
    participant Auth as WarpPrecompile/Registry
    participant EVM as EVMReceiptTrie

    Caller->>Target: importEvent(sourceBlockchainID, blockHeader, txIndex, receiptProof, logIndex)
    Target->>Auth: 認証済みブロックハッシュの取得/照会
    Auth-->>Target: verifiedBlockHash
    Target->>Target: keccak256(blockHeader)と一致確認
    Target->>Target: blockHeaderデコード→receiptsroot取得
    Target->>EVM: Merkle検証(receiptProof, txIndex, receiptsroot)
    EVM-->>Target: 取引レシート(デコード可能)
    Target->>Target: レシートからlogs[logIndex]抽出
    Target-->>Caller: emit EventImported(...)
    Target->>Target: _onEventImport(EVMEventInfo)

Reference implementation

The example below is retained as written in the original article, including its Japanese code comments and implementation-dependent stubs.

js
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

abstract contract EventImporterBase {
    event EventImported(
        bytes32 indexed sourceBlockchainID,
        bytes32 indexed sourceBlockHash,
        address indexed loggerAddress,
        uint256 txIndex,
        uint256 logIndex
    );

    struct EVMLog {
        address loggerAddress;
        bytes32[] topics;
        bytes data;
    }

    struct EVMEventInfo {
        bytes32 blockchainID;
        uint256 blockNumber;
        uint256 txIndex;
        uint256 logIndex;
        EVMLog log;
    }

    // 実装依存: 認証済みブロックハッシュの取得方法を差し替え可能に
    function _getVerifiedBlockHash(bytes32 sourceBlockchainID, bytes calldata blockHeader)
        internal
        view
        virtual
        returns (bytes32)
    {
        // 例: Warpprecompileや外部Registryを参照
        // return IBlockHashRegistry(registry).get(sourceBlockchainID, keccak256(blockHeader));
        return bytes32(0);
    }

    // 実装依存: blockHeaderデコード→(blockNumber, receiptsRoot)を返す
    function _decodeBlockHeader(bytes calldata blockHeader)
        internal
        pure
        virtual
        returns (uint256 blockNumber, bytes32 receiptsRoot)
    {
        // 実際にはRLPデコード等を行う
        return (0, bytes32(0));
    }

    // 実装依存: Merkle証明の検証→エンコード済みレシート
    function _proveReceipt(
        bytes32 receiptsRoot,
        uint256 txIndex,
        bytes[] calldata receiptProof
    ) internal view virtual returns (bytes memory encodedReceipt) {
        return bytes("");
    }

    // 実装依存: レシートからlogIndexのログをデコード
    function _extractLog(bytes memory encodedReceipt, uint256 logIndex)
        internal
        pure
        virtual
        returns (EVMLog memory log)
    {
        return EVMLog({loggerAddress: address(0), topics: new bytes32, data: bytes("")});
    }

    function importEvent(
        bytes32 sourceBlockchainID,
        bytes calldata blockHeader,
        uint256 txIndex,
        bytes[] calldata receiptProof,
        uint256 logIndex
    ) external {
        bytes32 verifiedHash = _getVerifiedBlockHash(sourceBlockchainID, blockHeader);
        require(verifiedHash != bytes32(0), "Block not verified");

        bytes32 headerHash = keccak256(blockHeader);
        require(headerHash == verifiedHash, "Invalid block header");

        (uint256 blockNumber, bytes32 receiptsRoot) = _decodeBlockHeader(blockHeader);

        bytes memory encodedReceipt = _proveReceipt(receiptsRoot, txIndex, receiptProof);

        EVMLog memory evmLog = _extractLog(encodedReceipt, logIndex);

        emit EventImported(
            sourceBlockchainID,
            headerHash,
            evmLog.loggerAddress,
            txIndex,
            logIndex
        );

        _onEventImport(
            EVMEventInfo({
                blockchainID: sourceBlockchainID,
                blockNumber: blockNumber,
                txIndex: txIndex,
                logIndex: logIndex,
                log: evmLog
            })
        );
    }

    function _onEventImport(EVMEventInfo memory eventInfo) internal virtual;
}

Open questions

The open questions identify issues to consider in future operation and extensions. These include the extent of the trust assumptions, how to keep processing costs down, and how to reuse authentication results.

The specification focuses on standardizing the interface and verification procedure. Details such as oracle design and registry operation are outside its scope. Developers should choose between directly calling the Warp precompile and using an external registry according to their use case, taking security and reusability into account.

Security

When importing events from other chains within Avalanche, it is essential to prove correctly that the event really was emitted in the specified block. Correctness depends primarily on two factors.

  • The mechanism for authenticating that the block hash corresponds to a block finalized on the other chain
  • The library used to verify the Merkle proof that the specified transaction receipt is included in that block

A bug or vulnerability in either component could cause a fabricated event to be accepted as genuine.

Reliability of block hash authentication

Proving the block containing an event first requires establishing that the block has genuinely reached finality on another Avalanche chain. Block hash authentication provides that assurance.

If an attacker can present a fabricated block hash, they can claim that a nonexistent event occurred. The authentication process must therefore use a trustworthy mechanism. Avalanche provides a way to authenticate block hashes securely through Warp Messaging.

Correctness of Merkle proof verification

The other critical component is Merkle proof verification. A Merkle proof uses compact path information to verify that a piece of data (a transaction receipt in this case) is included in a block.

Correct verification requires a library that handles Merkle trees properly. A bug in that library could cause a forged proof to be incorrectly accepted as valid.

Implementations should therefore use well-audited, widely used libraries. An untrustworthy custom implementation increases the risk of introducing vulnerabilities.

Conclusion

This article covered ACP108, a proposal for a standard mechanism to securely import and use events emitted on another chain within Avalanche. I hope this explanation was useful.

If you have questions, feel free to send me a direct message on Twitter.

Twitter @cardene777

I also publish content on other platforms.

https://chaldene.net/