Class ChainContext<N, C, P>Abstract

A ChainContext provides a consistent interface for interacting with a chain. It holds the configuration for the chain and cached RPC and protocol clients.

Type Parameters

  • N extends Network

  • C extends Chain = Chain

  • P extends Platform = ChainToPlatform<C>

Hierarchy

  • ChainContext

Properties

getAutomaticCircleBridge: (() => Promise<AutomaticCircleBridge<N, C>>)

Type declaration

getAutomaticTokenBridge: (() => Promise<AutomaticTokenBridge<N, C>>)

Type declaration

    • (): Promise<AutomaticTokenBridge<N, C>>
    • Get the Automatic Token Bridge protocol client for this chain

      Returns Promise<AutomaticTokenBridge<N, C>>

      the Automatic Token Bridge protocol client for this chain

getCircleBridge: (() => Promise<CircleBridge<N, C>>)

Type declaration

    • (): Promise<CircleBridge<N, C>>
    • Get the Circle Bridge protocol client for this chain

      Returns Promise<CircleBridge<N, C>>

      the Circle Bridge protocol client for this chain

getIbcBridge: (() => Promise<IbcBridge<N, C>>)

Type declaration

    • (): Promise<IbcBridge<N, C>>
    • Get the IBC Bridge protocol client for this chain

      Returns Promise<IbcBridge<N, C>>

      the IBC Bridge protocol client for this chain

getPorticoBridge: (() => Promise<PorticoBridge<N, C>>)

Type declaration

    • (): Promise<PorticoBridge<N, C>>
    • Get the Portico Bridge protocol client for this chain

      Returns Promise<PorticoBridge<N, C>>

      the Portico Bridge protocol client for this chain

getTokenBridge: (() => Promise<TokenBridge<N, C>>)

Type declaration

    • (): Promise<TokenBridge<N, C>>
    • Get the Token Bridge protocol client for this chain

      Returns Promise<TokenBridge<N, C>>

      the Token Bridge protocol client for this chain

getWormholeCore: (() => Promise<WormholeCore<N, C>>)

Type declaration

    • (): Promise<WormholeCore<N, C>>
    • Get the Wormhole Core protocol client for this chain

      Returns Promise<WormholeCore<N, C>>

      the Wormhole Core protocol client for this chain

supportsAutomaticCircleBridge: (() => boolean)

Type declaration

    • (): boolean
    • Check to see if the Automatic Circle Bridge protocol is supported by this chain

      Returns boolean

      a boolean indicating if this chain supports the Automatic Circle Bridge protocol

supportsAutomaticTokenBridge: (() => boolean)

Type declaration

    • (): boolean
    • Check to see if the Automatic Token Bridge protocol is supported by this chain

      Returns boolean

      a boolean indicating if this chain supports the Automatic Token Bridge protocol

supportsCircleBridge: (() => boolean)

Type declaration

    • (): boolean
    • Check to see if the Circle Bridge protocol is supported by this chain

      Returns boolean

      a boolean indicating if this chain supports the Circle Bridge protocol

supportsIbcBridge: (() => boolean)

Type declaration

    • (): boolean
    • Check to see if the IBC Bridge protocol is supported by this chain

      Returns boolean

      a boolean indicating if this chain supports the IBC Bridge protocol

supportsPorticoBridge: (() => boolean)

Type declaration

    • (): boolean
    • Check to see if the Portico Bridge protocol is supported by this chain

      Returns boolean

      a boolean indicating if this chain supports the Portico Bridge protocol

supportsTokenBridge: (() => boolean)

Type declaration

    • (): boolean
    • Check to see if the Token Bridge protocol is supported by this chain

      Returns boolean

      a boolean indicating if this chain supports the Token Bridge protocol

supportsWormholeCore: (() => boolean)

Type declaration

    • (): boolean
    • Check to see if the Wormhole Core protocol is supported by this chain

      Returns boolean

      a boolean indicating if this chain supports the Wormhole Core protocol

Methods

  • Get the balance of a token for a given address

    Parameters

    • walletAddr: string

      the address to get the balance for

    • token: TokenAddress<C>

      the token to get the balance for

    Returns Promise<null | bigint>

    the balance of the token for the address

  • Get the number of decimals for a token

    Parameters

    Returns Promise<number>

    the number of decimals for the token

  • Get the latest block number seen by the chain according to the RPC

    Returns Promise<number>

    the latest block number

  • Get the latest finalized block number seen by the chain according to the RPC

    Returns Promise<number>

    the latest finalized block number

  • Get the token id of the wrapped token for the native gas token

    Returns Promise<TokenId<C>>

    the wrapped token for the native gas token

  • Construct a protocol client for the given protocol

    Note: If no contracts are passed, we assume the default contracts should be used and that the protocol client is cacheable

    Type Parameters

    • PN extends keyof WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Rootstock" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia">

    Parameters

    • protocolName: PN

      The name of the protocol to construct a client for

    • Optional contracts: Contracts
    • Optional rpc: any

    Returns Promise<ProtocolInstance<P, PN, N, C>>

    An instance of the protocol client that implements the protocol interface for the chain

  • Get an RPC connection for this chain, uses the configuration passed in the initial constructor

    Returns Promise<any>

    the RPC connection for this chain

  • Get the token data from the local cache if available

    Parameters

    • symbol: string

      the symbol of the token to get

    Returns undefined | Token

    the token data if available

  • Get the token account for a given address and token

    Parameters

    Returns Promise<ChainAddress<C>>

    the token account for the address and token

    Remarks

    This is really only useful in the context of Solana but in order to provide a consistent interface, we provide it here.

  • Parse the Wormhole Core messages from a transaction

    Parameters

    • txid: string

      the transaction to parse

    Returns Promise<WormholeMessageId[]>

    the Wormhole Core messages emitted by the transaction

  • Send a transaction and wait for it to be confirmed

    Parameters

    • stxns: any[]

      the signed transaction to send

    Returns Promise<string[]>

    the transaction hashes of the sent transactions

  • Check to see if a given protocol is supported by this chain by checking if it is registered in the platform and the configuration is available and correct

    Parameters

    • protocolName: keyof WormholeRegistry.ProtocolToInterfaceMapping<"Mainnet" | "Testnet" | "Devnet", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Rootstock" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia">

      the name of the Protocol to check for support

    Returns boolean

    a boolean indicating if this protocol is supported

Generated using TypeDoc