Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CrossChainMessenger

Hierarchy

  • CrossChainMessenger

Index

Constructors

Properties

bedrock: boolean

Whether or not Bedrock compatibility is enabled.

List of custom bridges for the given network.

contracts: OEContracts

Contract objects attached to their respective providers and addresses.

depositConfirmationBlocks: number

Number of blocks before a deposit is considered confirmed.

estimateGas: { approveERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>); depositERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>); depositETH: ((amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>); finalizeMessage: ((message: MessageLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>); proveMessage: ((message: MessageLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>); resendMessage: ((message: MessageLike, messageGasLimit: NumberLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>); sendMessage: ((message: CrossChainMessageRequest, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides }) => Promise<BigNumber>); withdrawERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>); withdrawETH: ((amount: NumberLike, opts?: { overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>) } = ...

Object that holds the functions that estimates the gas required for a given transaction. Follows the pattern used by ethers.js.

Type declaration

  • approveERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>)
      • Estimates gas required to approve some tokens to deposit into the L2 chain.

        Parameters

        • l1Token: AddressLike

          The L1 token address.

        • l2Token: AddressLike

          The L2 token address.

        • amount: NumberLike

          Amount of the token to approve.

        • Optional opts: { overrides?: CallOverrides }

          Additional options.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

        Returns Promise<BigNumber>

        Transaction response for the approval transaction.

  • depositERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>)
      • Estimates gas required to deposit some ERC20 tokens into the L2 chain.

        Parameters

        • l1Token: AddressLike

          Address of the L1 token.

        • l2Token: AddressLike

          Address of the L2 token.

        • amount: NumberLike

          Amount to deposit.

        • Optional opts: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }

          Additional options.

          • Optional l2GasLimit?: NumberLike

            Optional gas limit to use for the transaction on L2.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L2. Defaults to sender.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

  • depositETH: ((amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>)
      • Estimates gas required to deposit some ETH into the L2 chain.

        Parameters

        • amount: NumberLike

          Amount of ETH to deposit.

        • Optional opts: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }

          Additional options.

          • Optional l2GasLimit?: NumberLike

            Optional gas limit to use for the transaction on L2.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L2. Defaults to sender.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

  • finalizeMessage: ((message: MessageLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>)
      • (message: MessageLike, opts?: { overrides?: CallOverrides }): Promise<BigNumber>
      • Estimates gas required to finalize a cross chain message. Only applies to L2 to L1 messages.

        Parameters

        • message: MessageLike

          Message to generate the finalization transaction for.

        • Optional opts: { overrides?: CallOverrides }

          Additional options.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

  • proveMessage: ((message: MessageLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>)
      • (message: MessageLike, opts?: { overrides?: CallOverrides }): Promise<BigNumber>
      • Estimates gas required to prove a cross chain message. Only applies to L2 to L1 messages.

        Parameters

        • message: MessageLike

          Message to generate the proving transaction for.

        • Optional opts: { overrides?: CallOverrides }

          Additional options.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

  • resendMessage: ((message: MessageLike, messageGasLimit: NumberLike, opts?: { overrides?: CallOverrides }) => Promise<BigNumber>)
      • (message: MessageLike, messageGasLimit: NumberLike, opts?: { overrides?: CallOverrides }): Promise<BigNumber>
      • Estimates gas required to resend a cross chain message. Only applies to L1 to L2 messages.

        Parameters

        • message: MessageLike

          Cross chain message to resend.

        • messageGasLimit: NumberLike

          New gas limit to use for the message.

        • Optional opts: { overrides?: CallOverrides }

          Additional options.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

  • sendMessage: ((message: CrossChainMessageRequest, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides }) => Promise<BigNumber>)
      • Estimates gas required to send a cross chain message.

        Parameters

        • message: CrossChainMessageRequest

          Cross chain message to send.

        • Optional opts: { l2GasLimit?: NumberLike; overrides?: CallOverrides }

          Additional options.

          • Optional l2GasLimit?: NumberLike

            Optional gas limit to use for the transaction on L2.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

  • withdrawERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>)
      • Estimates gas required to withdraw some ERC20 tokens back to the L1 chain.

        Parameters

        • l1Token: AddressLike

          Address of the L1 token.

        • l2Token: AddressLike

          Address of the L2 token.

        • amount: NumberLike

          Amount to withdraw.

        • Optional opts: { overrides?: CallOverrides; recipient?: AddressLike }

          Additional options.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L1. Defaults to sender.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

  • withdrawETH: ((amount: NumberLike, opts?: { overrides?: CallOverrides; recipient?: AddressLike }) => Promise<BigNumber>)
      • Estimates gas required to withdraw some ETH back to the L1 chain.

        Parameters

        • amount: NumberLike

          Amount of ETH to withdraw.

        • Optional opts: { overrides?: CallOverrides; recipient?: AddressLike }

          Additional options.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L1. Defaults to sender.

        Returns Promise<BigNumber>

        Gas estimate for the transaction.

l1BlockTimeSeconds: number

Estimated average L1 block time in seconds.

l1ChainId: number

Chain ID for the L1 network.

l1SignerOrProvider: Provider | Signer

Provider connected to the L1 chain.

l2ChainId: number

Chain ID for the L2 network.

l2SignerOrProvider: Provider | Signer

Provider connected to the L2 chain.

populateTransaction: { approveERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: Overrides }) => Promise<TransactionRequest>); depositERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }, isEstimatingGas?: boolean) => Promise<TransactionRequest>); depositETH: ((amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: PayableOverrides; recipient?: AddressLike }, isEstimatingGas?: boolean) => Promise<TransactionRequest>); finalizeMessage: ((message: MessageLike, opts?: { overrides?: PayableOverrides }) => Promise<TransactionRequest>); proveMessage: ((message: MessageLike, opts?: { overrides?: PayableOverrides }) => Promise<TransactionRequest>); resendMessage: ((message: MessageLike, messageGasLimit: NumberLike, opts?: { overrides?: Overrides }) => Promise<TransactionRequest>); sendMessage: ((message: CrossChainMessageRequest, opts?: { l2GasLimit?: NumberLike; overrides?: Overrides }) => Promise<TransactionRequest>); withdrawERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: Overrides; recipient?: AddressLike }) => Promise<TransactionRequest>); withdrawETH: ((amount: NumberLike, opts?: { overrides?: Overrides; recipient?: AddressLike }) => Promise<TransactionRequest>) } = ...

Object that holds the functions that generate transactions to be signed by the user. Follows the pattern used by ethers.js.

Type declaration

  • approveERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: Overrides }) => Promise<TransactionRequest>)
      • Generates a transaction for approving some tokens to deposit into the L2 chain.

        Parameters

        • l1Token: AddressLike

          The L1 token address.

        • l2Token: AddressLike

          The L2 token address.

        • amount: NumberLike

          Amount of the token to approve.

        • Optional opts: { overrides?: Overrides }

          Additional options.

          • Optional overrides?: Overrides

            Optional transaction overrides.

        Returns Promise<TransactionRequest>

        Transaction response for the approval transaction.

  • depositERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }, isEstimatingGas?: boolean) => Promise<TransactionRequest>)
      • Generates a transaction for depositing some ERC20 tokens into the L2 chain.

        Parameters

        • l1Token: AddressLike

          Address of the L1 token.

        • l2Token: AddressLike

          Address of the L2 token.

        • amount: NumberLike

          Amount to deposit.

        • Optional opts: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike }

          Additional options.

          • Optional l2GasLimit?: NumberLike

            Optional gas limit to use for the transaction on L2.

          • Optional overrides?: CallOverrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L2. Defaults to sender.

        • isEstimatingGas: boolean = false

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to deposit the tokens.

  • depositETH: ((amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: PayableOverrides; recipient?: AddressLike }, isEstimatingGas?: boolean) => Promise<TransactionRequest>)
      • (amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: PayableOverrides; recipient?: AddressLike }, isEstimatingGas?: boolean): Promise<TransactionRequest>
      • Generates a transaction for depositing some ETH into the L2 chain.

        Parameters

        • amount: NumberLike

          Amount of ETH to deposit.

        • Optional opts: { l2GasLimit?: NumberLike; overrides?: PayableOverrides; recipient?: AddressLike }

          Additional options.

          • Optional l2GasLimit?: NumberLike

            Optional gas limit to use for the transaction on L2.

          • Optional overrides?: PayableOverrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L2. Defaults to sender.

        • isEstimatingGas: boolean = false

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to deposit the ETH.

  • finalizeMessage: ((message: MessageLike, opts?: { overrides?: PayableOverrides }) => Promise<TransactionRequest>)
      • (message: MessageLike, opts?: { overrides?: PayableOverrides }): Promise<TransactionRequest>
      • Generates a message finalization transaction that can be signed and executed. Only applicable for L2 to L1 messages. Will throw an error if the message has not completed its challenge period yet.

        Parameters

        • message: MessageLike

          Message to generate the finalization transaction for.

        • Optional opts: { overrides?: PayableOverrides }

          Additional options.

          • Optional overrides?: PayableOverrides

            Optional transaction overrides.

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to finalize the message.

  • proveMessage: ((message: MessageLike, opts?: { overrides?: PayableOverrides }) => Promise<TransactionRequest>)
      • (message: MessageLike, opts?: { overrides?: PayableOverrides }): Promise<TransactionRequest>
      • Generates a message proving transaction that can be signed and executed. Only applicable for L2 to L1 messages.

        Parameters

        • message: MessageLike

          Message to generate the proving transaction for.

        • Optional opts: { overrides?: PayableOverrides }

          Additional options.

          • Optional overrides?: PayableOverrides

            Optional transaction overrides.

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to prove the message.

  • resendMessage: ((message: MessageLike, messageGasLimit: NumberLike, opts?: { overrides?: Overrides }) => Promise<TransactionRequest>)
      • (message: MessageLike, messageGasLimit: NumberLike, opts?: { overrides?: Overrides }): Promise<TransactionRequest>
      • Generates a transaction that resends a given cross chain message. Only applies to L1 to L2 messages. This transaction can be signed and executed by a signer.

        Parameters

        • message: MessageLike

          Cross chain message to resend.

        • messageGasLimit: NumberLike

          New gas limit to use for the message.

        • Optional opts: { overrides?: Overrides }

          Additional options.

          • Optional overrides?: Overrides

            Optional transaction overrides.

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to resend the message.

  • sendMessage: ((message: CrossChainMessageRequest, opts?: { l2GasLimit?: NumberLike; overrides?: Overrides }) => Promise<TransactionRequest>)
      • Generates a transaction that sends a given cross chain message. This transaction can be signed and executed by a signer.

        Parameters

        • message: CrossChainMessageRequest

          Cross chain message to send.

        • Optional opts: { l2GasLimit?: NumberLike; overrides?: Overrides }

          Additional options.

          • Optional l2GasLimit?: NumberLike

            Optional gas limit to use for the transaction on L2.

          • Optional overrides?: Overrides

            Optional transaction overrides.

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to send the message.

  • withdrawERC20: ((l1Token: AddressLike, l2Token: AddressLike, amount: NumberLike, opts?: { overrides?: Overrides; recipient?: AddressLike }) => Promise<TransactionRequest>)
      • Generates a transaction for withdrawing some ERC20 tokens back to the L1 chain.

        Parameters

        • l1Token: AddressLike

          Address of the L1 token.

        • l2Token: AddressLike

          Address of the L2 token.

        • amount: NumberLike

          Amount to withdraw.

        • Optional opts: { overrides?: Overrides; recipient?: AddressLike }

          Additional options.

          • Optional overrides?: Overrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L1. Defaults to sender.

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to withdraw the tokens.

  • withdrawETH: ((amount: NumberLike, opts?: { overrides?: Overrides; recipient?: AddressLike }) => Promise<TransactionRequest>)
      • (amount: NumberLike, opts?: { overrides?: Overrides; recipient?: AddressLike }): Promise<TransactionRequest>
      • Generates a transaction for withdrawing some ETH back to the L1 chain.

        Parameters

        • amount: NumberLike

          Amount of ETH to withdraw.

        • Optional opts: { overrides?: Overrides; recipient?: AddressLike }

          Additional options.

          • Optional overrides?: Overrides

            Optional transaction overrides.

          • Optional recipient?: AddressLike

            Optional address to receive the funds on L1. Defaults to sender.

        Returns Promise<TransactionRequest>

        Transaction that can be signed and executed to withdraw the ETH.

Accessors

  • get l1Provider(): Provider
  • get l1Signer(): Signer
  • get l2Provider(): Provider
  • get l2Signer(): Signer

Methods

  • Queries the account's approval amount for a given L1 token.

    Parameters

    • l1Token: AddressLike

      The L1 token address.

    • l2Token: AddressLike

      The L2 token address.

    • Optional opts: { signer?: Signer }

      Additional options.

      • Optional signer?: Signer

        Optional signer to get the approval for.

    Returns Promise<BigNumber>

    Amount of tokens approved for deposits from the account.

  • Approves a deposit into the L2 chain.

    Parameters

    • l1Token: AddressLike

      The L1 token address.

    • l2Token: AddressLike

      The L2 token address.

    • amount: NumberLike

      Amount of the token to approve.

    • Optional opts: { overrides?: Overrides; signer?: Signer }

      Additional options.

      • Optional overrides?: Overrides

        Optional transaction overrides.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the approval transaction.

  • Deposits some ERC20 tokens into the L2 chain.

    Parameters

    • l1Token: AddressLike

      Address of the L1 token.

    • l2Token: AddressLike

      Address of the L2 token.

    • amount: NumberLike

      Amount to deposit.

    • Optional opts: { l2GasLimit?: NumberLike; overrides?: CallOverrides; recipient?: AddressLike; signer?: Signer }

      Additional options.

      • Optional l2GasLimit?: NumberLike

        Optional gas limit to use for the transaction on L2.

      • Optional overrides?: CallOverrides

        Optional transaction overrides.

      • Optional recipient?: AddressLike

        Optional address to receive the funds on L2. Defaults to sender.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the deposit transaction.

  • depositETH(amount: NumberLike, opts?: { l2GasLimit?: NumberLike; overrides?: Overrides; recipient?: AddressLike; signer?: Signer }): Promise<TransactionResponse>
  • Deposits some ETH into the L2 chain.

    Parameters

    • amount: NumberLike

      Amount of ETH to deposit (in wei).

    • Optional opts: { l2GasLimit?: NumberLike; overrides?: Overrides; recipient?: AddressLike; signer?: Signer }

      Additional options.

      • Optional l2GasLimit?: NumberLike

        Optional gas limit to use for the transaction on L2.

      • Optional overrides?: Overrides

        Optional transaction overrides.

      • Optional recipient?: AddressLike

        Optional address to receive the funds on L2. Defaults to sender.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the deposit transaction.

  • estimateL2MessageGasLimit(message: MessageRequestLike, opts?: { bufferPercent?: number; from?: string }): Promise<BigNumber>
  • Estimates the amount of gas required to fully execute a given message on L2. Only applies to L1 => L2 messages. You would supply this gas limit when sending the message to L2.

    Parameters

    • message: MessageRequestLike

      Message get a gas estimate for.

    • Optional opts: { bufferPercent?: number; from?: string }

      Options object.

      • Optional bufferPercent?: number

        Percentage of gas to add to the estimate. Defaults to 20.

      • Optional from?: string

        Address to use as the sender.

    Returns Promise<BigNumber>

    Estimates L2 gas limit.

  • estimateMessageWaitTimeSeconds(message: MessageLike): Promise<number>
  • Returns the estimated amount of time before the message can be executed. When this is a message being sent to L1, this will return the estimated time until the message will complete its challenge period. When this is a message being sent to L2, this will return the estimated amount of time until the message will be picked up and executed on L2.

    Parameters

    • message: MessageLike

      Message to estimate the time remaining for.

    Returns Promise<number>

    Estimated amount of time remaining (in seconds) before the message can be executed.

  • finalizeMessage(message: MessageLike, opts?: { overrides?: PayableOverrides; signer?: Signer }): Promise<TransactionResponse>
  • Finalizes a cross chain message that was sent from L2 to L1. Only applicable for L2 to L1 messages. Will throw an error if the message has not completed its challenge period yet.

    Parameters

    • message: MessageLike

      Message to finalize.

    • Optional opts: { overrides?: PayableOverrides; signer?: Signer }

      Additional options.

      • Optional overrides?: PayableOverrides

        Optional transaction overrides.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the finalization transaction.

  • getBedrockMessageProof(message: MessageLike): Promise<BedrockCrossChainMessageProof>
  • Generates the bedrock proof required to finalize an L2 to L1 message.

    Parameters

    Returns Promise<BedrockCrossChainMessageProof>

    Proof that can be used to finalize the message.

  • Finds the appropriate bridge adapter for a given L1<>L2 token pair. Will throw if no bridges support the token pair or if more than one bridge supports the token pair.

    Parameters

    Returns Promise<IBridgeAdapter>

    The appropriate bridge adapter for the given token pair.

  • getChallengePeriodSeconds(): Promise<number>
  • Queries the current challenge period in seconds from the StateCommitmentChain.

    Returns Promise<number>

    Current challenge period in seconds.

  • Gets all deposits for a given address.

    Parameters

    • address: AddressLike

      Address to search for messages from.

    • opts: { fromBlock?: BlockTag; toBlock?: BlockTag } = {}

      Options object.

      • Optional fromBlock?: BlockTag

        Block to start searching for messages from. If not provided, will start from the first block (block #0).

      • Optional toBlock?: BlockTag

        Block to stop searching for messages at. If not provided, will stop at the latest known block ("latest").

    Returns Promise<TokenBridgeMessage[]>

    All deposit token bridge messages sent by the given address.

  • getMessageBedrockOutput(message: MessageLike): Promise<BedrockOutputData>
  • Returns the Bedrock output root that corresponds to the given message.

    Parameters

    • message: MessageLike

      Message to get the Bedrock output root for.

    Returns Promise<BedrockOutputData>

    Bedrock output root.

  • Finds the receipt of the transaction that executed a particular cross chain message.

    Parameters

    Returns Promise<MessageReceipt>

    CrossChainMessage receipt including receipt of the transaction that relayed the given message.

  • Returns the state root that corresponds to a given message. This is the state root for the block in which the transaction was included, as published to the StateCommitmentChain. If the state root for the given message has not been published yet, this function returns null.

    Parameters

    • message: MessageLike

      Message to find a state root for.

    Returns Promise<StateRoot>

    State root for the block in which the message was created.

  • Retrieves all cross chain messages sent within a given transaction.

    Parameters

    • transaction: TransactionLike

      Transaction hash or receipt to find messages from.

    • opts: { direction?: MessageDirection } = {}

      Options object.

      • Optional direction?: MessageDirection

        Direction to search for messages in. If not provided, will attempt to automatically search both directions under the assumption that a transaction hash will only exist on one chain. If the hash exists on both chains, will throw an error.

    Returns Promise<CrossChainMessage[]>

    All cross chain messages sent within the transaction.

  • Queries the OptimismPortal contract's provenWithdrawals mapping for a ProvenWithdrawal that matches the passed withdrawalHash

    bedrock

    Note: This function is bedrock-specific.

    Parameters

    • withdrawalHash: string

    Returns Promise<ProvenWithdrawal>

    A ProvenWithdrawal object

  • getStateBatchAppendedEventByBatchIndex(batchIndex: number): Promise<Event>
  • Returns the StateBatchAppended event that was emitted when the batch with a given index was created. Returns null if no such event exists (the batch has not been submitted).

    Parameters

    • batchIndex: number

      Index of the batch to find an event for.

    Returns Promise<Event>

    StateBatchAppended event for the batch, or null if no such batch exists.

  • getStateBatchAppendedEventByTransactionIndex(transactionIndex: number): Promise<Event>
  • Returns the StateBatchAppended event for the batch that includes the transaction with the given index. Returns null if no such event exists.

    Parameters

    • transactionIndex: number

      Index of the L2 transaction to find an event for.

    Returns Promise<Event>

    StateBatchAppended event for the batch that includes the given transaction by index.

  • getStateRootBatchByTransactionIndex(transactionIndex: number): Promise<StateRootBatch>
  • Returns information about the state root batch that included the state root for the given transaction by index. Returns null if no such state root has been published yet.

    Parameters

    • transactionIndex: number

      Index of the L2 transaction to find a state root batch for.

    Returns Promise<StateRootBatch>

    State root batch for the given transaction index, or null if none exists yet.

  • Gets all withdrawals for a given address.

    Parameters

    • address: AddressLike

      Address to search for messages from.

    • opts: { fromBlock?: BlockTag; toBlock?: BlockTag } = {}

      Options object.

      • Optional fromBlock?: BlockTag

        Block to start searching for messages from. If not provided, will start from the first block (block #0).

      • Optional toBlock?: BlockTag

        Block to stop searching for messages at. If not provided, will stop at the latest known block ("latest").

    Returns Promise<TokenBridgeMessage[]>

    All withdrawal token bridge messages sent by the given address.

  • proveMessage(message: MessageLike, opts?: { overrides?: Overrides; signer?: Signer }): Promise<TransactionResponse>
  • Proves a cross chain message that was sent from L2 to L1. Only applicable for L2 to L1 messages.

    Parameters

    • message: MessageLike

      Message to finalize.

    • Optional opts: { overrides?: Overrides; signer?: Signer }

      Additional options.

      • Optional overrides?: Overrides

        Optional transaction overrides.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the finalization transaction.

  • resendMessage(message: MessageLike, messageGasLimit: NumberLike, opts?: { overrides?: Overrides; signer?: Signer }): Promise<TransactionResponse>
  • Resends a given cross chain message with a different gas limit. Only applies to L1 to L2 messages. If provided an L2 to L1 message, this function will throw an error.

    Parameters

    • message: MessageLike

      Cross chain message to resend.

    • messageGasLimit: NumberLike

      New gas limit to use for the message.

    • Optional opts: { overrides?: Overrides; signer?: Signer }

      Additional options.

      • Optional overrides?: Overrides

        Optional transaction overrides.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the message resending transaction.

  • Sends a given cross chain message. Where the message is sent depends on the direction attached to the message itself.

    Parameters

    • message: CrossChainMessageRequest

      Cross chain message to send.

    • Optional opts: { l2GasLimit?: NumberLike; overrides?: Overrides; signer?: Signer }

      Additional options.

      • Optional l2GasLimit?: NumberLike

        Optional gas limit to use for the transaction on L2.

      • Optional overrides?: Overrides

        Optional transaction overrides.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the message sending transaction.

  • Resolves a MessageLike into a CrossChainMessage object. Unlike other coercion functions, this function is stateful and requires making additional requests. For now I'm going to keep this function here, but we could consider putting a similar function inside of utils/coercion.ts if people want to use this without having to create an entire CrossChainProvider object.

    Parameters

    • message: MessageLike

      MessageLike to resolve into a CrossChainMessage.

    Returns Promise<CrossChainMessage>

    Message coerced into a CrossChainMessage.

  • waitForMessageReceipt(message: MessageLike, opts?: { confirmations?: number; pollIntervalMs?: number; timeoutMs?: number }): Promise<MessageReceipt>
  • Waits for a message to be executed and returns the receipt of the transaction that executed the given message.

    Parameters

    • message: MessageLike

      Message to wait for.

    • opts: { confirmations?: number; pollIntervalMs?: number; timeoutMs?: number } = {}

      Options to pass to the waiting function.

      • Optional confirmations?: number

        Number of transaction confirmations to wait for before returning.

      • Optional pollIntervalMs?: number

        Number of milliseconds to wait between polling for the receipt.

      • Optional timeoutMs?: number

        Milliseconds to wait before timing out.

    Returns Promise<MessageReceipt>

    CrossChainMessage receipt including receipt of the transaction that relayed the given message.

  • waitForMessageStatus(message: MessageLike, status: MessageStatus, opts?: { pollIntervalMs?: number; timeoutMs?: number }): Promise<void>
  • Waits until the status of a given message changes to the expected status. Note that if the status of the given message changes to a status that implies the expected status, this will still return. If the status of the message changes to a status that exclues the expected status, this will throw an error.

    Parameters

    • message: MessageLike

      Message to wait for.

    • status: MessageStatus

      Expected status of the message.

    • opts: { pollIntervalMs?: number; timeoutMs?: number } = {}

      Options to pass to the waiting function.

      • Optional pollIntervalMs?: number

        Number of milliseconds to wait when polling.

      • Optional timeoutMs?: number

        Milliseconds to wait before timing out.

    Returns Promise<void>

  • Withdraws some ERC20 tokens back to the L1 chain.

    Parameters

    • l1Token: AddressLike

      Address of the L1 token.

    • l2Token: AddressLike

      Address of the L2 token.

    • amount: NumberLike

      Amount to withdraw.

    • Optional opts: { overrides?: Overrides; recipient?: AddressLike; signer?: Signer }

      Additional options.

      • Optional overrides?: Overrides

        Optional transaction overrides.

      • Optional recipient?: AddressLike

        Optional address to receive the funds on L1. Defaults to sender.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the withdraw transaction.

  • withdrawETH(amount: NumberLike, opts?: { overrides?: Overrides; recipient?: AddressLike; signer?: Signer }): Promise<TransactionResponse>
  • Withdraws some ETH back to the L1 chain.

    Parameters

    • amount: NumberLike

      Amount of ETH to withdraw.

    • Optional opts: { overrides?: Overrides; recipient?: AddressLike; signer?: Signer }

      Additional options.

      • Optional overrides?: Overrides

        Optional transaction overrides.

      • Optional recipient?: AddressLike

        Optional address to receive the funds on L1. Defaults to sender.

      • Optional signer?: Signer

        Optional signer to use to send the transaction.

    Returns Promise<TransactionResponse>

    Transaction response for the withdraw transaction.

Generated using TypeDoc