@arkade-os/sdk Documentation - v0.4.21
    Preparing search index...

    Class Wallet

    Main wallet implementation for Bitcoin transactions with Arkade protocol support. The wallet does not store any data locally and relies on Arkade and onchain providers to fetch onchain and virtual outputs.

    // Create a wallet with URL configuration
    const wallet = await Wallet.create({
    identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
    arkServerUrl: 'https://arkade.computer',
    esploraUrl: 'https://mempool.space/api'
    });

    // Or with custom provider instances (e.g., for Expo/React Native)
    const wallet = await Wallet.create({
    identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
    arkProvider: new ExpoArkProvider('https://arkade.computer'),
    indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
    esploraUrl: 'https://mempool.space/api'
    });

    // Get addresses
    const arkAddress = await wallet.getAddress();
    const boardingAddress = await wallet.getBoardingAddress();

    // Send bitcoin
    const txid = await wallet.send({
    address: 'ark1q...',
    amount: 50000,
    });

    Hierarchy (View Summary)

    Implements

    Index

    Properties

    arkProvider: ArkProvider
    arkServerPublicKey: Bytes
    boardingTapscript: DefaultVtxo.Script
    contractRepository: ContractRepository
    delegatorProvider?: DelegatorProvider
    dustAmount: bigint
    forfeitOutputScript: Bytes
    forfeitPubkey: Bytes
    identity: Identity

    Signing identity associated with the wallet.

    indexerProvider: IndexerProvider
    network: Network
    offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script
    onchainProvider: OnchainProvider
    renewalConfig: Required<Omit<RenewalConfig | undefined, "enabled">> & {
        enabled: boolean;
        thresholdMs: number;
    }

    Use settlementConfig instead

    serverUnrollScript: CSVMultisigTapscript.Type
    settlementConfig: false | SettlementConfig
    walletContractTimelocks: RelativeTimelock[]
    walletRepository: WalletRepository
    MIN_FEE_RATE: number = 1

    Accessors

    • get assetManager(): IAssetManager

      Asset manager bound to this wallet instance.

      Returns IAssetManager

    • get defaultContractScript(): string

      Get the pkScript hex for the wallet's primary offchain address. For the full wallet-owned script set registered in ContractManager, use getWalletScripts().

      Returns string

    Methods

    • Build an offchain transaction from the given inputs and outputs, sign it, submit to the Arkade provider, and finalize.

      Parameters

      Returns Promise<{ arkTxid: string; signedCheckpointTxs: string[] }>

      The Arkade transaction id and server-signed checkpoint PSBTs (for bookkeeping)

    • Clear the global VTXO sync cursor, forcing a full re-bootstrap on next sync. Useful for recovery after indexer reprocessing or debugging.

      Returns Promise<void>

    • Create a batch event handler for settlement flows.

      Parameters

      • intentId: string

        The intent ID.

      • inputs: ExtendedCoin[]

        Inputs used by the intent.

      • expectedRecipients: Recipient[]

        Expected recipients to validate in the virtual output tree.

      • Optionalsession: SignerSession

        Optional musig2 signing session. When omitted, signing steps are skipped.

      Returns Handler

    • Finalizes pending transactions by retrieving them from the server and finalizing each one. Skips the server check entirely when no send was interrupted (no pending tx flag set).

      Parameters

      • Optionalvtxos: ExtendedVirtualCoin[]

        Optional list of virtual outputs to use instead of retrieving them from the server

      Returns Promise<{ finalized: string[]; pending: string[] }>

      Array of transaction IDs that were finalized

    • Get the ContractManager for managing contracts including the wallet's default address.

      The ContractManager handles:

      • The wallet's default receiving address (as a "default" contract)
      • External contracts (Boltz swaps, HTLCs, etc.)
      • Multi-contract watching with resilient connections

      Returns Promise<ContractManager>

      const manager = await wallet.getContractManager();

      // Create a contract for a Boltz swap
      const contract = await manager.createContract({
      label: "Boltz Swap",
      type: "vhtlc",
      params: { ... },
      script: swapScript,
      address: swapAddress,
      });

      // Start watching for events (includes wallet's default address)
      const stop = await manager.onContractEvent((event) => {
      console.log(`${event.type} on ${event.contractScript}`);
      });
    • Get all pkScript hex strings for the wallet's own addresses (both delegate and non-delegate, current and historical).

      Returns Promise<string[]>

    • Subscribe to onchain and offchain notifications for newly received funds.

      Parameters

      • eventCallback: (coins: IncomingFunds) => void

        Callback invoked when matching funds are detected

      Returns Promise<() => void>

      A function that stops the subscriptions

    • Send BTC and/or assets to one or more recipients.

      Parameters

      • ...args: [Recipient, ...Recipient[]]

        Recipients with their addresses, BTC amounts, and assets

      Returns Promise<string>

      Promise resolving to the Arkade transaction ID

      const txid = await wallet.send({
      address: 'ark1q...',
      amount: 1000, // (optional, default to dust) btc amount to send to the output
      assets: [{ assetId: 'abc123...', amount: 50 }] // (optional) list of assets to send
      });
    • Settle boarding inputs and/or virtual outputs into a finalized mainnet transaction.

      Parameters

      • Optionalparams: SettleParams

        Optional settlement inputs and outputs. When omitted, the wallet settles all eligible funds.

      • OptionaleventCallback: (event: SettlementEvent) => void

        Optional callback invoked for settlement stream events.

      Returns Promise<string>

      The finalized Arkade transaction id

    • Convert this wallet to a readonly wallet.

      Returns Promise<ReadonlyWallet>

      A readonly wallet with the same configuration but readonly identity

      const wallet = await Wallet.create({ identity: MnemonicIdentity.fromMnemonic('abandon abandon...'), ... });
      const readonlyWallet = await wallet.toReadonly();

      // Can query balance and addresses
      const balance = await readonlyWallet.getBalance();
      const address = await readonlyWallet.getAddress();

      // But cannot send transactions (type error)
      // readonlyWallet.send(...); // TypeScript error
    • Create a full wallet and initialize its background managers.

      Parameters

      Returns Promise<Wallet>

      A wallet ready to query balances and send transactions

      const wallet = await Wallet.create({
      identity,
      arkServerUrl: 'https://arkade.computer',
      });