Skip to content

Instantly share code, notes, and snippets.

@tavakyan
Last active January 30, 2024 22:20
Show Gist options
  • Select an option

  • Save tavakyan/c44b4a39eeba371f4af9ad51afec56da to your computer and use it in GitHub Desktop.

Select an option

Save tavakyan/c44b4a39eeba371f4af9ad51afec56da to your computer and use it in GitHub Desktop.

EIP-6170 Extension: Data Commitment Interface

This extension introduces the Data Commitment Interface, which handles the pre-transaction data commitment. It's designed for platforms like Solana, where dynamic data (ie accounts) needs to be known along with the transaction instruction.

Developers can use the IDataCommitment interface to commit data before processing a cross-chain message with the extended IExtendedCrossChainMessaging interface. This can be useful by allowing the extraData field to be modified to contain the data needed for processing, such as public keys and accounts.

IDataCommitment Interface

// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.8.0;

interface IDataCommitment {
    // Event to log the commitment of message data
    event MessageDataCommitted(bytes dataCommitmentId, bytes chainId, bytes receiver, bytes messageData, bytes extraData);

    // Function to commit message data for a future cross-chain transaction
    // Returns a unique identifier for the committed data
    function commitMessageData(
        bytes chainId,
        bytes receiver,
        bytes messageData,
        bytes extraData
    ) external returns (bytes dataCommitmentId);

    // Optional: Function to retrieve committed data
    function getCommittedData(bytes dataCommitmentId) 
        external 
        view 
        returns (bytes chainId, bytes receiver, bytes messageData, bytes extraData);
}

commitMessageData Function

This function commits message data for a future cross-chain transaction and returns a unique identifier (dataCommitmentId) for the committed data. It accepts the following parameters:

  • chainId: The identifier of the destination blockchain.
  • receiver: The recipient's address on the destination blockchain.
  • messageData: The message data to be committed.
  • extraData: Additional security or metadata related to the commitment.

It emits a MessageDataCommitted event contains all the data committed along with the commitment id.

getCommittedData Function (Optional)

This function allows retrieval of committed data based on the provided dataCommitmentId.

The extraData or security param can be modified to include the 'accounts' field and the 'dataCommitmentId' to support this extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment