UNPKG

ttxd-alpha

Version:

An SDK for building applications on top of V2,V3 and Solana exchanges

30 lines (28 loc) 819 B
"use strict"; // src/example-raydiumv4Amm.ts var import_ttxd_alpha = require("ttxd-alpha"); var import_dotenv = require("dotenv"); (0, import_dotenv.config)(); var userPrivateKey = process.env.PK; if (!userPrivateKey) { throw new Error("Environment variable 'PK' is not set"); } (async () => { try { const result = await (0, import_ttxd_alpha.swapRaydium)({ poolId: "58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2", // Example Pool ID amountIn: 0.01, // Amount in SOL privateKey: userPrivateKey, // Required private key poolType: "amm", rpcUrl: process.env.RPC_URL, priorityFeeSol: 3e-3, tipFeeSol: 0.01 }); console.log(`Swap successful! Transaction ID: ${result.txId}`); } catch (error) { console.error("Swap failed:", error); } })();