概要

ITeleporterMessengerは、Avalancheのクロスチェーンメッセージングプロトコルである「Teleporter」のコアとなるスマートコントラクトのインターフェースです。 sendCrossChainMessageを呼び出すことで別のチェーンへメッセージを送信し、宛先チェーンではITeleporterReceiverインターフェースを実装したコントラクトがメッセージを受け取ります。

ITeleporterMessengerは、単純なメッセージングだけでなく、リレーヤーへのインセンティブ設計、メッセージの送付保証、失敗したメッセージ実行の再試行といった、クロスチェーン通信に不可欠な機能を実装しています。 開発者はこのインターフェースを通じて、複雑な署名検証やチェーン間のステート同期を意識することなく、自身のアプリケーションロジックに集中できます。

機能

このインターフェースが定義する主な機能は以下の通りです。

  • 異なるブロックチェーンへのメッセージ送信
  • 他のチェーンから送信されたメッセージの受信と実行
  • 送信失敗の可能性があるメッセージの再送信
  • 実行に失敗したメッセージの再実行
  • メッセージ送付時の手数料(インセンティブ)の追加
  • 宛先チェーンに滞留したレシート(配送証明)の送信
  • メッセージを配送したリレーヤーへの報酬支払い
  • メッセージや手数料に関する各種情報の取得

フロー

  • クロスチェーンメッセージの送信・受信・報酬獲得
  • メッセージ実行失敗と再試行
  • 滞留レシートの送付要求

クロスチェーンメッセージの送信・受信・報酬獲得

sequenceDiagram
    participant User as ユーザー
    participant AppA as dApp (チェーンA)
    participant TeleporterA as Teleporter (チェーンA)
    participant Relayer as リレーヤー
    participant TeleporterB as Teleporter (チェーンB)
    participant AppB as dApp (チェーンB)

    User->>+AppA: クロスチェーン処理を要求
    AppA->>+TeleporterA: sendCrossChainMessage(宛先, メッセージ, 手数料)
    TeleporterA-->>-AppA: messageID
    Note over TeleporterA: 手数料をロック
    AppA-->>-User: 要求を受け付け

    Relayer->>TeleporterA: 送信メッセージを監視
    Relayer->>+TeleporterB: receiveCrossChainMessage(メッセージ, 報酬アドレス)
    TeleporterB->>+AppB: receiveTeleporterMessage(メッセージ)
    AppB-->>-TeleporterB: 処理完了
    Note over TeleporterB: 配送レシートを保存
    TeleporterB-->>-Relayer: 配送成功

    loop 次のB→Aメッセージ発生時
        participant User2
        participant AppB2
        User2->>AppB2: 別のクロスチェーン処理
        AppB2->>TeleporterB: sendCrossChainMessage(...)
        Note over TeleporterB: 保存していたレシートをメッセージに同梱
    end

    Relayer->>TeleporterB: B→Aメッセージを監視・配送
    Note right of Relayer: B→AメッセージをチェーンAへ届ける
    Relayer->>TeleporterA: receiveCrossChainMessage(...)
    Note over TeleporterA: 同梱されたレシートを処理し、<br/>報酬のロックを解除

    Relayer->>+TeleporterA: redeemRelayerRewards()
    TeleporterA-->>-Relayer: 報酬トークンを送金

メッセージ実行失敗と再試行

sequenceDiagram
    participant Relayer as リレーヤー
    participant TeleporterB as Teleporter (チェーンB)
    participant AppB as dApp (チェーンB)
    participant User as ユーザー

    Relayer->>+TeleporterB: receiveCrossChainMessage(...)
    Note over TeleporterB: メッセージ配送は成功として記録<br/>(リレーヤーの報酬対象となる)
    TeleporterB->>AppB: receiveTeleporterMessage(メッセージ)
    activate AppB
    Note over AppB: ガス不足などで実行がRevert
    AppB-->>-TeleporterB: 実行失敗
    deactivate AppB
    Note over TeleporterB: 失敗したメッセージのハッシュを保存
    TeleporterB-->>-Relayer: 配送は完了

    User->>+TeleporterB: retryMessageExecution(失敗したメッセージ)
    Note over User: ユーザーは失敗を検知し、<br/>十分なガスを確保して再試行
    TeleporterB->>+AppB: receiveTeleporterMessage(メッセージ)
    AppB-->>-TeleporterB: 実行成功
    TeleporterB-->>-User: 再試行成功

滞留レシートの送付要求

sequenceDiagram
    participant Relayer as リレーヤー
    participant TeleporterB as Teleporter (チェーンB)
    participant TeleporterA as Teleporter (チェーンA)

    Note over Relayer, TeleporterB: チェーンBからAへの通信がなく、<br/>レシートがチェーンBに滞留している状態

    Relayer->>+TeleporterB: sendSpecifiedReceipts(滞留レシートのID)
    Note over TeleporterB: 指定されたレシートのみを含む<br/>空のメッセージを作成し、送信
    TeleporterB-->>-Relayer: 新しいmessageID

    Relayer->>TeleporterB: 新しいメッセージを監視
    Relayer->>+TeleporterA: receiveCrossChainMessage(レシート専用メッセージ)
    Note over TeleporterA: レシートを処理し、報酬のロックを解除
    TeleporterA-->>-Relayer: 配送成功

    Relayer->>+TeleporterA: redeemRelayerRewards()
    TeleporterA-->>-Relayer: 報酬獲得

コード

solidity
// (c) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

// SPDX-License-Identifier: LicenseRef-Ecosystem

pragma solidity 0.8.25;

// A message receipt identifies the message that was delivered by its nonce,
// and the address that can redeem the reward for that message.
struct TeleporterMessageReceipt {
    uint256 receivedMessageNonce;
    address relayerRewardAddress;
}

// Represents all of the information required for submitting a Teleporter message
// to be sent to the given destination chain ID and address. Includes the fee
// information for the message, the amount of gas the relayer must provide to execute
// the message on the destination chain, the relayer accounts allowed to deliver the
// message, and the message data itself.
struct TeleporterMessageInput {
    bytes32 destinationBlockchainID;
    address destinationAddress;
    TeleporterFeeInfo feeInfo;
    uint256 requiredGasLimit;
    address[] allowedRelayerAddresses;
    bytes message;
}

// Represents a message sent or received by an implementation of {ITeleporterMessenger}.
struct TeleporterMessage {
    uint256 messageNonce;
    address originSenderAddress;
    bytes32 destinationBlockchainID;
    address destinationAddress;
    uint256 requiredGasLimit;
    address[] allowedRelayerAddresses;
    TeleporterMessageReceipt[] receipts;
    bytes message;
}

// Represents the fee information associated to a given Teleporter message.
// The contract address is the asset contract the fee will be paid in, and
// the amount is the amount of that specified asset.
struct TeleporterFeeInfo {
    address feeTokenAddress;
    uint256 amount;
}

/**
 * @dev Interface that describes functionalities for a cross-chain messenger implementing the Teleporter protcol.
 *
 * @custom:security-contact https://github.com/ava-labs/icm-contracts/blob/main/SECURITY.md
 */
interface ITeleporterMessenger {
    /**
     * @notice Emitted when the blockchain ID of the contract instance is initialized using the Warp precompile.
     */
    event BlockchainIDInitialized(bytes32 indexed blockchainID);

    /**
     * @notice Emitted when sending a Teleporter message cross-chain.
     */
    event SendCrossChainMessage(
        bytes32 indexed messageID,
        bytes32 indexed destinationBlockchainID,
        TeleporterMessage message,
        TeleporterFeeInfo feeInfo
    );

    /**
     * @notice Emitted when an additional fee amount is added to a Teleporter message that had previously
     * been sent, but not yet delivered to the destination chain.
     */
    event AddFeeAmount(bytes32 indexed messageID, TeleporterFeeInfo updatedFeeInfo);

    /**
     * @notice Emitted when a Teleporter message is being delivered on the destination chain to an address,
     * but message execution fails. Failed messages can then be retried with `retryMessageExecution`
     */
    event MessageExecutionFailed(
        bytes32 indexed messageID, bytes32 indexed sourceBlockchainID, TeleporterMessage message
    );

    /**
     * @notice Emitted when a Teleporter message is successfully executed with the
     * specified destination address and message call data. This can occur either when
     * the message is initially received, or on a retry attempt.
     *
     * Each message received can be executed successfully at most once.
     */
    event MessageExecuted(bytes32 indexed messageID, bytes32 indexed sourceBlockchainID);

    /**
     * @notice Emitted when a TeleporterMessage is successfully received.
     */
    event ReceiveCrossChainMessage(
        bytes32 indexed messageID,
        bytes32 indexed sourceBlockchainID,
        address indexed deliverer,
        address rewardRedeemer,
        TeleporterMessage message
    );

    /**
     * @notice Emitted when a receipt is marked as received on the source chain that sent the
     * corresponding Teleporter message.
     */
    event ReceiptReceived(
        bytes32 indexed messageID,
        bytes32 indexed destinationBlockchainID,
        address indexed relayerRewardAddress,
        TeleporterFeeInfo feeInfo
    );

    /**
     * @notice Emitted when an account redeems accumulated relayer rewards.
     */
    event RelayerRewardsRedeemed(address indexed redeemer, address indexed asset, uint256 amount);

    /**
     * @notice Called by transactions to initiate the sending of a cross-chain message.
     * @return The message ID of the newly sent message.
     */
    function sendCrossChainMessage(
        TeleporterMessageInput calldata messageInput
    ) external returns (bytes32);

    /**
     * @notice Called by transactions to retry the sending of a cross-chain message.
     *
     * @dev Retriggers the sending of a message previously emitted by sendCrossChainMessage that has not yet been acknowledged
     * with a receipt from the destination chain. This may be necessary in the unlikely event that less than the required
     * threshold of stake weight successfully inserted the message in their messages DB at the time of the first submission.
     * The message is checked to have already been previously submitted by comparing its message hash against those kept in
     * state until a receipt is received for the message.
     */
    function retrySendCrossChainMessage(
        TeleporterMessage calldata message
    ) external;

    /**
     * @notice Adds the additional fee amount to the amount to be paid to the relayer that delivers
     * the given message ID to the destination chain.
     *
     * @dev The fee token address must be the same asset type as the fee asset specified in the original
     * call to sendCrossChainMessage. Reverts if the message doesn't exist or there is already
     * receipt of delivery of the message.
     */
    function addFeeAmount(
        bytes32 messageID,
        address feeTokenAddress,
        uint256 additionalFeeAmount
    ) external;

    /**
     * @notice Receives a cross-chain message, and marks the `relayerRewardAddress` for fee reward for a successful delivery.
     *
     * @dev The message specified by `messageIndex` must be provided at that index in the access list storage slots of the transaction,
     * and is verified in the precompile predicate.
     */
    function receiveCrossChainMessage(uint32 messageIndex, address relayerRewardAddress) external;

    /**
     * @notice Retries the execution of a previously delivered message by verifying the payload matches
     * the hash of the payload originally delivered, and calling the destination address again.
     *
     * @dev Intended to be used if message excution failed on initial delivery of the Teleporter message.
     * For example, this may occur if the original required gas limit was not sufficient for the message
     * execution, or if the destination address did not contain a contract, but a compatible contract
     * was later deployed to that address. Messages are ensured to be successfully executed at most once.
     */
    function retryMessageExecution(
        bytes32 sourceBlockchainID,
        TeleporterMessage calldata message
    ) external;

    /**
     * @notice Sends the receipts for the given `messageIDs`.
     *
     * @dev Sends the specified message receipts in a new message (with an empty payload) back to the source chain.
     * This is intended for use in sending receipts that have not been sent in a timely manner by the standard
     * receipt delivery mechanism.
     * @return The message ID of the newly sent message.
     */
    function sendSpecifiedReceipts(
        bytes32 sourceBlockchainID,
        bytes32[] calldata messageIDs,
        TeleporterFeeInfo calldata feeInfo,
        address[] calldata allowedRelayerAddresses
    ) external returns (bytes32);

    /**
     * @notice Sends any fee amount rewards for the given fee asset out to the caller.
     */
    function redeemRelayerRewards(
        address feeTokenAddress
    ) external;

    /**
     * @notice Gets the hash of a given message stored in the EVM state, if the message exists.
     * @return The message hash
     */
    function getMessageHash(
        bytes32 messageID
    ) external view returns (bytes32);

    /**
     * @notice Checks whether or not the given message has been received by this chain.
     * @return Boolean representing if the given message has been received.
     */
    function messageReceived(
        bytes32 messageID
    ) external view returns (bool);

    /**
     * @notice Returns the address the relayer reward should be sent to on the source chain
     * for a given message, assuming that the message has already been delivered.
     * @return The relayer reward address for the given message.
     */
    function getRelayerRewardAddress(
        bytes32 messageID
    ) external view returns (address);

    /**
     * @notice Gets the current reward amount of a given fee asset that is redeemable by the given relayer.
     * @return The amount of the fee asset redeemable by the specified relayer.
     */
    function checkRelayerRewardAmount(
        address relayer,
        address feeTokenAddress
    ) external view returns (uint256);

    /**
     * @notice Gets the fee token address and amount for a given sent message.
     * @return The fee token address and fee amount for a the given sent message ID.
     * If the message ID is not found, zero address and amount values are returned.
     */
    function getFeeInfo(
        bytes32 messageID
    ) external view returns (address, uint256);

    /**
     * @notice Gets the message ID that would currently be used for the next message sent from the contract
     * instance to the given destination blockchain.
     *
     * @dev This message ID may never be used in the event that the next call to sendCrossChainMessage in a
     * transaction uses a different destination blockchain. The current value as returned by this function will
     * change with each successful call to sendCrossChainMessage.
     * @return The specified message ID.
     */
    function getNextMessageID(
        bytes32 destinationBlockchainID
    ) external view returns (bytes32);

    /**
     * @notice Gets the number of receipts that are waiting to be sent to the given source chain ID.
     * @return Size of the given queue.
     */
    function getReceiptQueueSize(
        bytes32 sourceBlockchainID
    ) external view returns (uint256);

    /**
     * @notice Gets the receipt at the given index in the queue for the given source chain ID.
     * @return The receipt requested.
     */
    function getReceiptAtIndex(
        bytes32 sourceBlockchainID,
        uint256 index
    ) external view returns (TeleporterMessageReceipt memory);
}

構造体

TeleporterMessageReceipt

text
struct TeleporterMessageReceipt {
    uint256 receivedMessageNonce;
    address relayerRewardAddress;
}

メッセージが宛先チェーンで受信されたことを証明するレシート。 この情報は、次にメッセージが逆方向(宛先→送信元)に送られる時に含まれ、送信元チェーンでリレーヤーの報酬を有効化するために使われます。

  • receivedMessageNonce 受信したメッセージのノンス(一意の番号)。
  • relayerRewardAddress メッセージを送付したリレーヤーが指定している報酬を受け取るアドレス。

TeleporterMessageInput

text
struct TeleporterMessageInput {
    bytes32 destinationBlockchainID;
    address destinationAddress;
    TeleporterFeeInfo feeInfo;
    uint256 requiredGasLimit;
    address[] allowedRelayerAddresses;
    bytes message;
}

sendCrossChainMessage関数を呼び出して、新しいクロスチェーンメッセージを送信する時に必要となる全ての情報をまとめた構造体。

  • destinationBlockchainID メッセージの宛先となるブロックチェーンのID。
  • destinationAddress 宛先チェーンでメッセージを受け取るコントラクトのアドレス。
  • feeInfo リレーヤーへの報酬として支払う手数料の情報。
  • requiredGasLimit 宛先チェーンでメッセージを実行する時に、リレーヤーが必要とする最低限のガス量。
  • allowedRelayerAddresses このメッセージの送付を許可されたリレーヤーのアドレスのリスト。 空の場合はどのリレーヤーでも送付できます。
  • message 宛先コントラクトに渡される、エンコードされた実際のメッセージデータ。

TeleporterMessage

text
struct TeleporterMessage {
    uint256 messageNonce;
    address originSenderAddress;
    bytes32 destinationBlockchainID;
    address destinationAddress;
    uint256 requiredGasLimit;
    address[] allowedRelayerAddresses;
    TeleporterMessageReceipt[] receipts;
    bytes message;
}

Teleporterプロトコルで送受信されるメッセージの構造体。 送信時の情報に加え、他のメッセージの送付証明であるレシートが含まれます。

  • messageNonce メッセージの一意性を保証するためのノンス。
  • originSenderAddress 送信元チェーンでこのメッセージを最初に送信したアカウントのアドレス。
  • destinationBlockchainID 宛先となるブロックチェーンのID。
  • destinationAddress 宛先チェーンの受信コントラクトアドレス。
  • requiredGasLimit 宛先での実行に必要なガスリミット。
  • allowedRelayerAddresses メッセージの送付を許可されたリレーヤーのリスト。
  • receipts このメッセージと一緒に送付される、過去の別メッセージのレシートのリスト。
  • message 実際のメッセージペイロード。

TeleporterFeeInfo

text
struct TeleporterFeeInfo {
    address feeTokenAddress;
    uint256 amount;
}

メッセージに紐づく手数料の情報を定義している構造体。 リレーヤーへのインセンティブとして機能します。

  • feeTokenAddress 手数料として支払われるERC20トークンのコントラクトアドレス。
  • amount 支払われるトークンの量。

イベント

BlockchainIDInitialized

text
event BlockchainIDInitialized(bytes32 indexed blockchainID);

コントラクトが自身のブロックチェーンIDをWarpプリコンパイルから初期化した時に発行されるイベント。

SendCrossChainMessage

text
event SendCrossChainMessage(
    bytes32 indexed messageID,
    bytes32 indexed destinationBlockchainID,
    TeleporterMessage message,
    TeleporterFeeInfo feeInfo
);

sendCrossChainMessageが呼ばれ、新しいクロスチェーンメッセージが送信された時に発行されるイベント。

AddFeeAmount

text
event AddFeeAmount(bytes32 indexed messageID, TeleporterFeeInfo updatedFeeInfo);

未送信のメッセージに対してaddFeeAmountが呼ばれ、追加の手数料が設定された時に発行されるイベント。

MessageExecutionFailed

text
event MessageExecutionFailed(
    bytes32 indexed messageID, bytes32 indexed sourceBlockchainID, TeleporterMessage message
);

メッセージが宛先チェーンで受信されたものの、宛先コントラクトでの実行に失敗した時に発行されるイベント。

MessageExecuted

text
event MessageExecuted(bytes32 indexed messageID, bytes32 indexed sourceBlockchainID);

メッセージが宛先チェーンで正常に実行された時に発行されるイベント。 初回の受信時、またはretryMessageExecutionによる再試行時のどちらでも発行されます。

ReceiveCrossChainMessage

text
event ReceiveCrossChainMessage(
    bytes32 indexed messageID,
    bytes32 indexed sourceBlockchainID,
    address indexed deliverer,
    address rewardRedeemer,
    TeleporterMessage message
);

receiveCrossChainMessageが呼ばれ、クロスチェーンメッセージが正常に受信された時に発行されるイベント。 この段階ではまだメッセージの実行は完了していません。

ReceiptReceived

text
event ReceiptReceived(
    bytes32 indexed messageID,
    bytes32 indexed destinationBlockchainID,
    address indexed relayerRewardAddress,
    TeleporterFeeInfo feeInfo
);

メッセージの送付証明であるレシートが、元の送信チェーンに無事届いた時に発行されるイベント。 このイベントが発行されると、リレーヤーは報酬を引き出せるようになります。

RelayerRewardsRedeemed

text
event RelayerRewardsRedeemed(address indexed redeemer, address indexed asset, uint256 amount);

リレーヤーがredeemRelayerRewardsを呼び出し、蓄積された報酬を引き出した時に発行されるイベント。

関数

sendCrossChainMessage

text
function sendCrossChainMessage(
    TeleporterMessageInput calldata messageInput
) external returns (bytes32);

新しいクロスチェーンメッセージの送信を開始する関数。 この関数は、他のブロックチェーン上のスマートコントラクトにメッセージを送るためのエントリーポイントです。 TeleporterMessageInput構造体で指定された情報(宛先、メッセージ内容、手数料など)に基づいてメッセージを構築し、AvalancheのICMに送信を依頼します。 成功すると、そのメッセージを識別するための一意なmessageIDを返します。

引数

  • messageInput TeleporterMessageInput構造体。 宛先チェーンID、宛先アドレス、手数料情報、必要なガスリミット、許可されたリレーヤー、メッセージ本体が含まれます。

戻り値

  • bytes32 送信されたメッセージに割り当てられた一意のID (messageID)。

retrySendCrossChainMessage

text
function retrySendCrossChainMessage(
    TeleporterMessage calldata message
) external;

過去に送信したものの、まだ配送が確認されていないメッセージの再送信を試みる関数。 送信元チェーンのバリデーターセットが大きく変動した場合など、ごく稀な状況でメッセージが宛先チェーンに届かないことがあります。 この関数は、そのような未送信のメッセージを、現在のバリデーターセットの署名で再度送信し直すために使用されます。 既に配送済みのメッセージに対しては実行できません。

引数

  • message TeleporterMessage構造体。 再送信したいメッセージの完全なデータ。

addFeeAmount

text
function addFeeAmount(
    bytes32 messageID,
    address feeTokenAddress,
    uint256 additionalFeeAmount
) external;

送信済みだが未送信のメッセージに対して、リレーヤーへの手数料を追加する関数。 設定した手数料が低すぎてリレーヤーがメッセージを送付してくれない場合に、インセンティブを増やすために使用します。 指定されたmessageIDのメッセージに、additionalFeeAmount分の手数料を追加します。 手数料のトークンアドレスは、最初に指定したものと同じある必要があります。

引数

  • messageID 手数料を追加したいメッセージのID。
  • feeTokenAddress 手数料として使用するトークンのアドレス。
  • additionalFeeAmount 追加する手数料の額。

receiveCrossChainMessage

text
function receiveCrossChainMessage(uint32 messageIndex, address relayerRewardAddress) external;

リレーヤーによって呼び出され、他のチェーンから送られてきたメッセージを受信する関数。

リレーヤーは、Avalanche Warp Messagingによって検証済みのメッセージを指定し、この関数を実行します。 関数はメッセージを受け取り、その送付証明(レシート)を生成・保存します。 同時に、メッセージで指定された宛先コントラクトのreceiveTeleporterMessage関数を呼び出し、メッセージの実行を試みます。

引数

  • messageIndex トランザクションのアクセスリストに含まれる、Warpメッセージのインデックス。
  • relayerRewardAddress この送付に対する報酬を受け取るリレーヤーのアドレス。

retryMessageExecution

text
function retryMessageExecution(
    bytes32 sourceBlockchainID,
    TeleporterMessage calldata message
) external;

過去に受信済みだが、実行に失敗したメッセージの再実行を試みる関数。 receiveCrossChainMessageでメッセージは正常に受信されたものの、ガス不足や宛先コントラクトのロジックエラーなどで実行が失敗した場合に使用します。 この関数を呼び出すことで、再度メッセージの実行を試みることができます。 例えば、初回実行時より高いガスリミットでトランザクションを発行することで、ガス不足による失敗を解決できる可能性があります。 各メッセージは、最大で一度しか正常に実行されません。

引数

  • sourceBlockchainID メッセージの送信元となったブロックチェーンのID。
  • message TeleporterMessage構造体。再実行したいメッセージの完全なデータ。

sendSpecifiedReceipts

text
function sendSpecifiedReceipts(
    bytes32 sourceBlockchainID,
    bytes32[] calldata messageIDs,
    TeleporterFeeInfo calldata feeInfo,
    address[] calldata allowedRelayerAddresses
) external returns (bytes32);

宛先チェーンに滞留している特定のメッセージレシート(送付証明)を、送信元チェーンへ送り返す関数。

通常、レシートは逆方向のメッセージに含まれて送信元に戻ります。 しかし、通信が一方通行で逆方向のメッセージが発生しない場合、レシートが滞留しリレーヤーが報酬を受け取れません。 この関数は、指定したmessageIDsに対応するレシートだけを含む新しい空のメッセージを作成し、送信元チェーンへ送り返すために使われます。

引数

  • sourceBlockchainID レシートの送り先となる、元の送信元チェーンのID。
  • messageIDs 送信したいレシートに対応するメッセージIDの配列。
  • feeInfo このレシート送付メッセージを送付するリレーヤーへの手数料。
  • allowedRelayerAddresses このメッセージの送付を許可するリレーヤーのリスト。

戻り値

  • bytes32 レシートを送付するために新しく作成されたメッセージのID。

redeemRelayerRewards

text
function redeemRelayerRewards(
    address feeTokenAddress
) external;

リレーヤーが、正常に送付したメッセージに対して蓄積された報酬を引き出すための関数。 リレーヤーがメッセージを配送し、そのレシートが送信元チェーンに戻ってくると、報酬が引き出し可能な状態になります。 この関数を呼び出すことで、呼び出し元アドレス(リレーヤー)は指定したトークン(feeTokenAddress)で蓄積された全ての報酬を受け取ることができます。

引数

  • feeTokenAddress 引き出したい報酬のトークンアドレス。

getMessageHash

text
function getMessageHash(
    bytes32 messageID
) external view returns (bytes32);

指定されたmessageIDを持つ送信済みメッセージのハッシュを取得する関数。 送信されたメッセージの内容をハッシュ化した値を取得します。 メッセージが存在しない場合はゼロ値を返します。 メッセージが改ざんされていないかを確認する際などに利用できます。

引数

  • messageID ハッシュを取得したいメッセージのID。

戻り値

  • bytes32 メッセージのハッシュ値。

messageReceived

text
function messageReceived(
    bytes32 messageID
) external view returns (bool);

指定されたmessageIDのメッセージが、このチェーンで受信されたかどうかを確認する関数。 メッセージがリレーヤーによってreceiveCrossChainMessageで送付された場合、true を返します。 メッセージの実行が成功したかどうかは問いません。

引数

  • messageID 確認したいメッセージのID。

戻り値

  • bool 受信されていればtrue、そうでなければfalse。

getRelayerRewardAddress

text
function getRelayerRewardAddress(
    bytes32 messageID
) external view returns (address);

送付済みのメッセージについて、報酬を受け取るリレーヤーのアドレスを取得する関数。 指定されたmessageIDのメッセージが既に送付済みの場合、その送付を担当したリレーヤーが報酬受け取り用に指定したアドレスを返します。

引数

  • messageID 確認したいメッセージのID。

戻り値

  • address リレーヤーの報酬受け取りアドレス。

checkRelayerRewardAmount

text
function checkRelayerRewardAmount(
    address relayer,
    address feeTokenAddress
) external view returns (uint256);

特定のリレーヤーが引き出し可能な報酬額を確認する関数。 指定されたリレーヤーアドレス(relayer)が、指定されたトークン(feeTokenAddress)で現在引き出すことができる報酬の総額を返します。

引数

  • relayer 報酬額を確認したいリレーヤーのアドレス。
  • feeTokenAddress 報酬として支払われるトークンのアドレス。

戻り値

  • uint256 引き出し可能な報酬の総額。

getFeeInfo

text
function getFeeInfo(
    bytes32 messageID
) external view returns (address, uint256);

送信されたメッセージに設定されている手数料の情報を取得する関数。 指定されたmessageIDを持つメッセージについて、手数料として設定されているトークンのアドレスと、その総額(追加分も含む)を返します。

引数

  • messageID 手数料情報を取得したいメッセージのID。

戻り値

  • address 手数料トークンのアドレス。
  • uint256 手数料の総額。

getNextMessageID

text
function getNextMessageID(
    bytes32 destinationBlockchainID
) external view returns (bytes32);

次に特定の宛先チェーンへメッセージを送信した場合に割り当てられるmessageIDを取得する関数。 指定した宛先ブロックチェーンに対して、次にsendCrossChainMessageが呼び出された時に生成されるmessageIDを返します。 これは、メッセージIDが送信元と宛先の組み合わせ、およびノンスに基づいて決定されるため予測可能です。

引数

  • destinationBlockchainID 宛先となるブロックチェーンのID。

戻り値

  • bytes32 次に生成されると予測されるmessageID。

getReceiptQueueSize

text
function getReceiptQueueSize(
    bytes32 sourceBlockchainID
) external view returns (uint256);

特定の送信元チェーンへ送り返されるのを待っているレシートの数を取得する関数。 指定されたsourceBlockchainIDから受信したメッセージに対するレシートで、まだそのチェーンに送り返されていない(滞留している)ものの総数を返します。

引数

  • sourceBlockchainID 送信元チェーンのID。

戻り値

  • uint256 待機中のレシートの数。

getReceiptAtIndex

text
function getReceiptAtIndex(
    bytes32 sourceBlockchainID,
    uint256 index
) external view returns (TeleporterMessageReceipt memory);

待機中のレシートキューから、指定したインデックスのレシート情報を取得する関数。 getReceiptQueueSizeで確認できる待機中レシートのキューの中から、特定のインデックスにあるレシートの具体的な内容(メッセージノンスとリレーヤーの報酬アドレス)を返します。

引数

  • sourceBlockchainID 送信元チェーンのID。
  • index 取得したいレシートのキュー内でのインデックス。

戻り値

  • TeleporterMessageReceipt memory 要求されたレシートの情報。