Quick Start
Here's a basic example to get you started with the ZarnithFi Router SDK:
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
import { RouterSDK } from '@zarnithfi/sol-fee-router';
// Setup connection and wallet
const connection = new Connection('https://api.mainnet-beta.solana.com');
const wallet = new Keypair(); // In a real app, use a proper wallet adapter
// Initialize the RouterSDK
const routerSDK = new RouterSDK(connection, wallet);
// Define destinations with percentage splits
const destinations = [
{
address: new PublicKey('Treasuryaddress'),
percentage: 50 // 50%
},
{
address: new PublicKey('Developeraddress'),
percentage: 30 // 30%
},
{
address: new PublicKey('Marketingaddress'),
percentage: 20 // 20%
}
];
// Create a router
const createRouter = async () => {
try {
const signature = await routerSDK.createRouter(destinations);
console.log(`Router created with transaction signature: ${signature}`);
} catch (error) {
console.error('Error creating router:', error);
}
};
// Route SOL to destinations
const routeSol = async () => {
try {
const routerAddress = await routerSDK.getRouterAddress();
const signature = await routerSDK.routeSolFees(routerAddress, 1); // Route 1 SOL
console.log(`SOL routed with transaction signature: ${signature}`);
} catch (error) {
console.error('Error routing SOL:', error);
}
};Initialize the SDK
Create a New Router
Route SOL to Destinations
Update Router Destinations
Get Router Data
Close Router and Reclaim Rent
Last updated