Skip to content

Simple Bridge - Core SDK

The Core SDK provides framework-agnostic functions for getting bridge quotes and executing cross-chain transactions. These functions can be used in Node.js backends, Telegram bots, or any environment where React hooks are not available.

Overview

The Simple Bridge functionality in the Core SDK includes:

  • Quote Management: Get quotes from multiple bridge providers
  • Optimal Solving: Find optimal USDC amounts for bridge operations
  • Transaction Execution: Execute bridge transactions with proper chain switching
  • Status Monitoring: Check the status of bridge transactions

Key Features

  • Provider Comparison: Automatically compares multiple providers to find the best rate
  • Framework Agnostic: Works in any JavaScript/TypeScript environment
  • Type Safe: Full TypeScript support with comprehensive types
  • Error Handling: Graceful fallback when providers fail

Installation

pnpm add @silentswap/sdk

Basic Example

import { getBridgeQuote } from '@silentswap/sdk';
 
// Get a quote for bridging USDC from Ethereum to Avalanche
const quote = await getBridgeQuote(
  1, // Source chain ID (Ethereum)
  '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // Source token (USDC)
  '1000000', // Amount in token units (1 USDC = 1e6)
  43114, // Destination chain ID (Avalanche)
  '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', // Destination token (USDC.e)
  '0x...' // User address
);
 
console.log('Provider:', quote.provider);
console.log('Output Amount:', quote.outputAmount);
console.log('Fee (USD):', quote.feeUsd);
console.log('Retention Rate:', quote.retentionRate);

Use Cases

Node.js Backend

import { getBridgeQuote, executeBridgeTransaction } from '@silentswap/sdk';
import { createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
 
// Create wallet client for transaction execution
const account = privateKeyToAccount('0x...');
const walletClient = createWalletClient({
  account,
  chain: ethereum,
  transport: http(),
});
 
// Get quote
const quote = await getBridgeQuote(/* ... */);
 
// Execute transaction
const status = await executeBridgeTransaction(
  quote,
  walletClient,
  connector, // Your connector implementation
  (step) => console.log('Step:', step)
);

Next Steps