The main class used to interact with the Sei network, optionally associated with a wallet.

This provides various abstractions for interacting with different assets usable on Sei, along with the ability to interact with both EVM and WASM contracts.

Hierarchy (view full)

Constructors

Properties

account: null | SeiClientAccountData

User's account data. Will be null if this isn't associated with an account

chainId:
    | "sei-chain"
    | "arctic-1"
    | "atlantic-2"
    | "pacific-1"

The Sei network ID this client is connected to

cometClient: CometClient
cosmRegistry: Registry

The stargateClient needs this to encode things properly.

ethereumClient: null | EthereumProvider

If an ethereum wallet is connected, it will be exposed here.

queryClient: SeiQueryClient

The underlying query client, used to query the specific modules on Sei.

readonlyReason: string

If this is a read-only account, this says why.

signer: null | OfflineSigner

A SigningStargateClient if this ClientEnv is used with an account which can sign transactions, or a StargateClient otherwise. Used for general network information and optionally signing things.

Methods

  • Gets the balance of the specified fungible asset

    Parameters

    • unifiedDenom: string

      the fungible to get the balance of

    • OptionalaccountAddress: string

      account address, can be a 0x or sei1 address (if they're associated) defaults to this user's 0x or sei1 address depending on whether which asset is specified.

    Returns Promise<bigint>

    the raw value. If you wish to make it look pretty, use it with UIAmount.

  • Gets the total supply of the specified fungible asset.

    Parameters

    • unifiedDenom: string

      the asset to look up

    Returns Promise<bigint>

    the raw value. If you wish to make it look pretty, use it with UIAmount.

  • Checks whether or not this account is associated. (The node is aware of the relationship between the 0x and sei1 accounts)

    Always returns false if this ClientEnv isn't associated with an account.

    Returns Promise<boolean>

  • A key compontent in compensating for Sei's idiosyncracies in its CosmWasm <> EVM interop.

    Idiosyncracies being:

    • Sei requires top-level EVM invoke instructions to be ...
      • the one and only thing that occupies the transaction.
      • signed by an Ethereum wallet. There's no way to invoke the EVM on the top level using a cosmos signature.

    Additionally, ethereum wallets cannot bundle multiple instructions per transaction.

    To help with this, this function takes the EncodeObject[] provided, which may include an internal typeUrl which reprensts EVM invocations, and seperates them into EVM messages or Cosmos messages as needed.

    • If this represents an Ethereum-only client
    • If this represents a cosmos client
      • Cosmos messages will be returned as-is, with any interspersed EVM messages returned as EVM messages

    Parameters

    Returns Promise<({
        evmMsg: Transaction;
    } | {
        cosmMsg: EncodeObject[];
    })[]>

  • Makes a read-only call to a solidity contract

    Parameters

    • contractAddress: string

      The 0x... contract address

    • functionDefinition: string | EVMABIFunctionDefinition

      Function to call with its return types

    • params: any[]

      Function arguments

    Returns Promise<any[]>

    the returned values as an array

  • Makes a read-only call to a solidity contract

    Parameters

    • contractAddress: string

      The 0x... contract address

    • functionDefinition: string | EVMABIFunctionDefinition

      Function to call with its return types

    • params: any[]

      Function arguments

    Returns Promise<any>

    the returned values as a struct

  • Simulates the transaction and provides actually useful information. Like the events emitted.

    Parameters

    Returns Promise<SimulateResponse>

  • Waits for the specified EVM transaction hash to confirm

    Parameters

    • tx: string

      the transcation hash

    • OptionaltimeoutMs: number

      how long to wait until timing out. Defaults to 60 seconds

    • OptionalthrowOnTimeout: boolean

      whether or not to throw an error if the timeout time has elapsed instead of returning null

    Returns Promise<null | ReceiptInformation>

    the confirmed transaction, or null if we waited too long and throwOnTimeout is falsy

  • Waits for the specified EVM transaction hash to confirm

    Parameters

    • tx: string

      the transcation hash

    • timeoutMs: undefined | number

      how long to wait until timing out. Defaults to 60 seconds if undefined

    • throwOnTimeout: true

      you explicitly set this to true, so prepare for error throwing

    Returns Promise<ReceiptInformation>

    the confirmed transaction

  • Waits for the specified cosmos transaction to confirm

    Parameters

    • tx: string

      the transcation hash

    • OptionaltimeoutMs: number

      how long to wait until timing out. Defaults to 60 seconds

    • OptionalthrowOnTimeout: boolean

      whether or not to throw an error if the timeout time has elapsed instead of returning null

    Returns Promise<null | DeliverTxResponse>

    the confirmed transaction, or null if we waited too long and throwOnTimeout is falsy

  • Waits for the specified cosmos transaction to confirm

    Parameters

    • tx: string

      the transcation hash

    • timeoutMs: undefined | number

      how long to wait until timing out. Defaults to 60 seconds if undefined

    • throwOnTimeout: true

      you explicitly set this to true, so prepare for error throwing

    Returns Promise<DeliverTxResponse>

    the confirmed transaction

  • Don't be afraid of the type definition, just use ClientEnv.get()

    This gets a ClientEnv from the provider specified.

    Type Parameters

    Parameters

    • this: T
    • provider: MaybeSelectedProvider = defaultProvider

      The provider to use

    • chainId:
          | "sei-chain"
          | "arctic-1"
          | "atlantic-2"
          | "pacific-1" = ...

      The network ID to connect to

    • gasPrice: GasPrice = defaultGasPrice

      gas price

    Returns Promise<InstanceType<T>>