@arkade-os/sdk Documentation - v0.4.0-next.8
    Preparing search index...

    Class Wallet

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

    // Create a wallet with URL configuration
    const wallet = await Wallet.create({
    identity: SingleKey.fromHex('your_private_key'),
    arkServerUrl: 'https://ark.example.com',
    esploraUrl: 'https://mempool.space/api'
    });

    // Or with custom provider instances (e.g., for Expo/React Native)
    const wallet = await Wallet.create({
    identity: SingleKey.fromHex('your_private_key'),
    arkProvider: new ExpoArkProvider('https://ark.example.com'),
    indexerProvider: new ExpoIndexerProvider('https://ark.example.com'),
    esploraUrl: 'https://mempool.space/api'
    });

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

    // Send bitcoin
    const txid = await wallet.sendBitcoin({
    address: 'tb1...',
    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
    indexerProvider: IndexerProvider
    network: Network
    networkName: NetworkName
    offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script
    onchainProvider: OnchainProvider
    renewalConfig: Required<Omit<RenewalConfig | undefined, "enabled">> & {
        enabled: boolean;
        thresholdMs: number;
    }
    serverUnrollScript: CSVMultisigTapscript.Type
    walletRepository: WalletRepository
    MIN_FEE_RATE: number = 1

    Accessors

    • get defaultContractScript(): string

      Get the contract script for the wallet's default address. This is the pkScript hex, used to identify the wallet in ContractManager.

      Returns string

    Methods

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

      Parameters

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

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

    • Finalizes pending transactions by retrieving them from the server and finalizing each one.

      Parameters

      • Optionalvtxos: ExtendedVirtualCoin[]

        Optional list of VTXOs 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). Falls back to only the current script if ContractManager is not yet initialized.

      Returns Promise<string[]>

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

      Parameters

      Returns Promise<string>

      Promise resolving to the ark transaction ID

      const txid = await wallet.send({
      address: 'ark1...',
      amount: 1000, // (optional, default to dust) btc amount to send to the output
      assets: [{ assetId: 'abc123...', amount: 50 }] // (optional) list of assets to send
      });
    • 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: SingleKey.fromHex('...'), ... });
      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.sendBitcoin(...); // TypeScript error