Github & NPM

Solana Swap Package

This package allows you to perform token swaps on Solana, including Jito integration for faster transactions.

Jito is now supported by the Swap API and is integrated in the NPM package, you can now send your transactions with Jito.

GitHub Repository

Our codebase is open-source and available on GitHub. You can find it at:

https://github.com/solxtence/solana-swap (opens in a new tab)

In our GitHub repository, you'll find:

  • Source code for the Solana Swap package
  • Examples of how to use the package

Feel free to ⭐️ the repository if you find it useful!

NPM Package

To install our package using NPM, run the following command in your project directory:

npm i @solxtence/solana-swap

More information about our npm package at:

https://www.npmjs.com/package/@solxtence/solana-swap (opens in a new tab)

Quick Start

Here's a quick example of how to use the package:

const { Keypair } = require("@solana/web3.js");
const bs58 = require("bs58");
const { SolanaSwap } = require("@solxtence/solana-swap");
 
async function performSwap() {
  const keypair = Keypair.fromSecretKey(bs58.decode("YOUR_PRIVATE_KEY"));
  const solanaSwap = new SolanaSwap(
    keypair,
    "https://api.mainnet-beta.solana.com"
  );
 
  const swapResponse = await solanaSwap.getSwapInstructions(
    "FROM_TOKEN_ADDRESS",
    "TO_TOKEN_ADDRESS",
    AMOUNT_TO_SWAP,
    SLIPPAGE_TOLERANCE,
    keypair.publicKey.toBase58(),
    PRIORITY_FEE
  );
 
  const txid = await solanaSwap.performSwap(swapResponse);
  console.log("Transaction ID:", txid);
}
 
performSwap();

Remember to replace YOUR_PRIVATE_KEY, FROM_TOKEN_ADDRESS, TO_TOKEN_ADDRESS, AMOUNT_TO_SWAP, SLIPPAGE_TOLERANCE, and PRIORITY_FEE with your actual values.

Support

If you encounter any issues or have questions, please don't hesitate to:

  1. Check our FAQ section
  2. Open an issue on our GitHub repository (opens in a new tab)