Skip to main content

Local Trade API

The non-custodial way to trade Solana memecoins through an API. Your wallet stays on your computer - we never see your private key. You submit your trade through your own RPC.

What you need

  • A Solana wallet - its private key in base58. (Phantom: Settings → Show Secret Recovery Phrase → Show Private Key.)
  • Some SOL in that wallet - enough for the trade plus a small amount of network fees.
  • A Solana RPC endpoint to actually submit the trade. The public one (https://api.mainnet-beta.solana.com) works for testing but gets rate-limited; for real use grab a free or paid RPC from Helius, Triton, QuickNode, or similar.
  • Node.js or Python installed if you want to run the snippet below as-is.

Example

import { Connection, Keypair, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";

const conn = new Connection("https://api.mainnet-beta.solana.com"); // your own RPC
const wallet = Keypair.fromSecretKey(bs58.decode(process.env.WALLET_SECRET));

// 1. Ask pumpdata to build an unsigned transaction.
const res = await fetch("https://api.pumpdata.fun/api/local-trade", {
method: "POST",
headers: { "content-type": "application/json", "accept": "application/json" },
body: JSON.stringify({
action: "buy", // "buy" or "sell"
publicKey: wallet.publicKey.toBase58(),
mint: "<token mint>", // base58 token mint
amount: 0.01, // SOL when amountInSol=true, tokens otherwise
amountInSol: true, // true → amount is SOL; false → tokens
slippage: 10, // percent
priorityFee: 0.0001, // SOL
pool: "pump", // dex selector
}),
});
const { tx } = await res.json();

// 2. Sign locally - your private key never leaves this script.
const txObj = VersionedTransaction.deserialize(Buffer.from(tx, "base64"));
txObj.sign([wallet]);

// 3. Submit via your own RPC.
const sig = await conn.sendRawTransaction(txObj.serialize());
console.log("https://solscan.io/tx/" + sig);

How it works

  1. You ask pumpdata for a trade. We build an unsigned transaction.
  2. You sign the transaction on your machine, with your own wallet.
  3. You submit the signed transaction through your own RPC.

If something goes wrong

You'll get a response like { "error": "..." } with a short message. Usual causes: a wrong wallet address, a wrong token mint, or not enough SOL.

If you want pumpdata to sign and submit on your behalf, see the Lightning Transactions page - that's the managed-wallet flow with one-click execution.