Skip to content

How to Initialize and Use the SDK

This guide walks you through a practical SDK setup flow for both browser and server environments, then shows how to run a first bridge transaction and track it.

You will learn how to:

  • Prepare your tenant credentials and environment.
  • Install and initialize the SDK for frontend and backend usage.
  • Connect wallets for frontend applications.
  • Run a first bridge flow with fee estimation.
  • Track and manage transactions after submission.

Before coding, make sure you have:

  • A registered VoidAI tenant and valid apiKey.
  • A secretKey for backend usage.
  • An environment target (devnet, testnet, or mainnet).
  • Required wallets for your flow:
    • Bittensor wallet (Talisman/Subwallet/Polkadot.js)
    • EVM wallet (MetaMask or WalletConnect-compatible)
    • Solana wallet (Phantom/Solflare), if relevant
Terminal window
npm install @voidaisdk/bridge-sdk

If your app signs transactions directly, install the wallet ecosystem packages you use (for example ethers, wagmi, or @solana/wallet-adapter-react).

import { BridgeSDK } from '@voidaisdk/bridge-sdk';
const sdk = new BridgeSDK({
apiKey: 'YOUR_PUBLIC_API_KEY',
environment: 'mainnet', // 'devnet' | 'testnet' | 'mainnet'
});
await sdk.ready;

Use the SDK wallet helper for Bittensor and standard ecosystem libraries for EVM/Solana.

// Bittensor extension wallet via SDK helper
const account = await sdk.wallets.bittensor.connect();
console.log(account.address);

For EVM and Solana, connect with your wallet library first, then pass the connected address into SDK methods such as bridge().

  1. Fetch chains and assets

    const chains = await sdk.api.getSupportedChains();
    const assets = await sdk.api.getAssetList();
    console.log(chains, assets);
  2. Estimate fees

    const estimate = await sdk.bridge.getBridgeFeeEstimate({
    fromToken: 'wtao',
    toToken: 'tao',
    amount: 1.5,
    });
  3. Request bridge payload

    const response = await sdk.bridge.bridge({
    fromChain: 'ethereum',
    toChain: 'bittensor',
    fromToken: 'wtao',
    toToken: 'tao',
    fromWallet: '0xYourEvmAddress',
    toWallet: '5YourBittensorAddress',
    amount: 1.5,
    });
  4. Sign and submit using your connected wallet

    if (response.evmTransaction) {
    await window.ethereum.request({
    method: 'eth_sendTransaction',
    params: [response.evmTransaction],
    });
    }

Use transaction APIs to monitor history and handle pending operations:

const recent = await sdk.bridge.getRecentTransactions(1, 20);
console.log(recent.items);

Cancel a pending operation if needed:

await sdk.bridge.cancelBridgeSwap({
uuid: 'transaction-uuid',
fromToken: 'wtao',
toToken: 'tao',
});

If indexer confirmation is delayed for eligible flows, use manual confirmation endpoints in the transactions guide.

Frequent issues include:

  • Invalid or missing credentials.
  • Wrong environment selection (devnet/testnet/mainnet mismatch).
  • Wallet not connected or wrong sender/recipient chain addresses.
  • Insufficient network balance for gas/fees.

See Error Handling for detailed diagnostics and remediation patterns.