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

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

    Type Parameters

    • PN extends keyof ProtocolToPlatformMapping

    Parameters

    • protocolName: keyof ProtocolToPlatformMapping

      The name of the protocol to construct a client for

    • Optional rpc: any

    Returns Promise<ProtocolImplementation<P, PN>>

    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.

  • 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 the Automatic Circle Bridge protocol is supported by this chain

    Returns boolean

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

  • 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

  • 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

  • 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

  • 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

  • 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 ProtocolToPlatformMapping

      the name of the Protocol to check for support

    Returns boolean

    a boolean indicating if this protocol is supported

  • 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

  • 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

Generated using TypeDoc