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.
1. What this guide covers
Section titled “1. What this guide covers”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.
2. Prerequisites
Section titled “2. Prerequisites”Before coding, make sure you have:
- A registered VoidAI tenant and valid
apiKey. - A
secretKeyfor backend usage. - An environment target (
devnet,testnet, ormainnet). - Required wallets for your flow:
- Bittensor wallet (Talisman/Subwallet/Polkadot.js)
- EVM wallet (MetaMask or WalletConnect-compatible)
- Solana wallet (Phantom/Solflare), if relevant
3. Install the SDK
Section titled “3. Install the SDK”npm install @voidaisdk/bridge-sdkyarn add @voidaisdk/bridge-sdkIf your app signs transactions directly, install the wallet ecosystem packages you use (for example ethers, wagmi, or @solana/wallet-adapter-react).
4. Initialize the SDK
Section titled “4. Initialize the SDK”import { BridgeSDK } from '@voidaisdk/bridge-sdk';
const sdk = new BridgeSDK({ apiKey: 'YOUR_PUBLIC_API_KEY', environment: 'mainnet', // 'devnet' | 'testnet' | 'mainnet'});
await sdk.ready;import { BridgeSDKServer } from '@voidaisdk/bridge-sdk';
const serverSdk = new BridgeSDKServer({ apiKey: process.env.VOID_API_KEY!, secretKey: process.env.VOID_SECRET_KEY!, environment: (process.env.VOID_ENVIRONMENT || 'mainnet') as 'devnet' | 'testnet' | 'mainnet',});
await serverSdk.ready;5. Connect wallets (frontend only)
Section titled “5. Connect wallets (frontend only)”Use the SDK wallet helper for Bittensor and standard ecosystem libraries for EVM/Solana.
// Bittensor extension wallet via SDK helperconst 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().
6. Run your first bridge flow
Section titled “6. Run your first bridge flow”-
Fetch chains and assets
const chains = await sdk.api.getSupportedChains();const assets = await sdk.api.getAssetList();console.log(chains, assets); -
Estimate fees
const estimate = await sdk.bridge.getBridgeFeeEstimate({fromToken: 'wtao',toToken: 'tao',amount: 1.5,}); -
Request bridge payload
const response = await sdk.bridge.bridge({fromChain: 'ethereum',toChain: 'bittensor',fromToken: 'wtao',toToken: 'tao',fromWallet: '0xYourEvmAddress',toWallet: '5YourBittensorAddress',amount: 1.5,}); -
Sign and submit using your connected wallet
if (response.evmTransaction) {await window.ethereum.request({method: 'eth_sendTransaction',params: [response.evmTransaction],});}
7. Track and manage transactions
Section titled “7. Track and manage transactions”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.
8. Common errors and troubleshooting
Section titled “8. Common errors and troubleshooting”Frequent issues include:
- Invalid or missing credentials.
- Wrong environment selection (
devnet/testnet/mainnetmismatch). - Wallet not connected or wrong sender/recipient chain addresses.
- Insufficient network balance for gas/fees.
See Error Handling for detailed diagnostics and remediation patterns.