Skip to content

Server-Side Usage

The BridgeSDKServer class is designed for secure backend integrations. It requires both apiKey and secretKey to authenticate, and exposes the same sdk.bridge methods available in the frontend SDK.


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

When BridgeSDKServer is initialized, the SDK automatically:

  1. Calls POST /api/v1/auth/login with your apiKey and secretKey.
  2. Receives a JWT Access Token.
  3. Attaches the JWT to all subsequent API requests.
  4. Refreshes the token automatically before expiry.

After successful initialization, retrieve the tenant metadata associated with your API key:

const keyData = serverSdk.getValidatedApiKeyData();
if (keyData) {
console.log('Tenant ID:', keyData.tenantId);
console.log('Project Name:', keyData.name);
}

This data is parsed from the JWT obtained during login.


The serverSdk.bridge property provides the full BridgeSDK interface — all bridge, swap, CCIP, and transaction methods are available server-side.

// Cancel a pending bridge swap
const result = await serverSdk.bridge.cancelBridgeSwap({
uuid: 'transaction-uuid',
fromToken: 'wtao',
toToken: 'tao',
});
console.log('Cancelled:', result.success);
// Fetch recent transactions
const history = await serverSdk.bridge.getRecentTransactions(1, 50);
console.log('Total transactions:', history.totalItems);

Use CaseDescription
Payment VerificationConfirm a user has successfully bridged assets before unlocking content or fulfilling an order.
Transaction HistoryFetch and display cross-chain history in your own dashboard or data pipeline.
Automated BridgingProgrammatically initiate bridge requests for custodial wallets or backend workflows.
Fee MonitoringPeriodically fetch transaction data to reconcile accumulated tenant fees.

.env
VOID_API_KEY=your_public_api_key
VOID_SECRET_KEY=your_secret_key
VOID_ENVIRONMENT=mainnet
const serverSdk = new BridgeSDKServer({
apiKey: process.env.VOID_API_KEY,
secretKey: process.env.VOID_SECRET_KEY,
environment: process.env.VOID_ENVIRONMENT as 'mainnet' | 'testnet' | 'devnet',
});