Interface IWeb3Service

The Web3 service provides access to the Spyre blockchain actions, coordinated through the Thirdweb client, chain-chomp, and other Spyre services.

interface IWeb3Service {
    get activeAddress(): WatchedValue<null | `0x${string}`>;
    get config(): Web3Config;
    get isInAppWallet(): WatchedValue<boolean>;
    get linkedAddress(): WatchedValue<null | `0x${string}`>;
    get needsToSwitchChains(): WatchedValue<boolean>;
    get stakingBalance(): WatchedAsyncValue<bigint>;
    get status(): WatchedValue<Web3ConnectionStatus>;
    get usdcBalance(): WatchedAsyncValue<bigint>;
    get usdcPermitAmount(): WatchedAsyncValue<bigint>;
    get withdrawAfter(): WatchedAsyncValue<Date>;
    approve(namespace: string, wad?: bigint, cancel?: CancelToken): Promise<Txn>;
    deposit(namespace: string, amount: bigint, cancel?: CancelToken): Promise<Txn>;
    link(cancel?: CancelToken): Promise<void>;
    signStake(params: SignStakeParameters, cancel?: CancelToken): Promise<Signature>;
    switchChain(): Promise<void>;
    watch(txn: Txn): Promise<void>;
}

Accessors

  • get linkedAddress(): WatchedValue<null | `0x${string}`>
  • The address linked to the current user account. Note that this is NOT necessarily the same as the current active address. A user may have linked one account (via Metamask or some other provider), then switch wallets. Both the linked and the active addresses must match to perform Spyre transactions.

    Returns WatchedValue<null | `0x${string}`>

Methods

  • Approves the staking contract to transfer USDC on the user's behalf.

    The transaction object returned from this function represents a potentially in progress transaction. That is, this function returns after submission, not after confirmation. Use the watch function to watch the transaction for status changes.

    Parameters

    • namespace: string

      The namespace of the staking contract.

    • Optionalwad: bigint

      The amount to approve.

    • Optionalcancel: CancelToken

      An optional cancel token to cancel the operation.

    Returns Promise<Txn>

  • Deposits USDC into the staking contract.

    The transaction object returned from this function represents a potentially in progress transaction. That is, this function returns after submission, not after confirmation. Use the watch function to watch the transaction for status changes.

    Parameters

    • namespace: string

      The namespace of the staking contract.

    • amount: bigint

      The amount to deposit.

    • Optionalcancel: CancelToken

      An optional cancel token to cancel the operation.

    Returns Promise<Txn>

  • Switches the user's wallet to the correct chain given by the configuration.

    Returns Promise<void>

  • Watches a transaction for status change.

    Parameters

    • txn: Txn

      The transaction to watch.

    Returns Promise<void>