Transaction API Docs
To get a transaction for signing and sending with a custom RPC, send a POST request to
https://pumpportal.fun/api/trade-local
Your request body must contain the following options:
publicKey
: Your wallet public keyaction
: "buy" or "sell"mint
: The contract address of the token you want to trade (this is the text after the '/' in the pump.fun url for the token.)amount
: The amount of SOL or tokens to trade. If selling, amount can be a percentage of tokens in your wallet (ex. amount: "100%")denominatedInSol
: "true" if amount is SOL, "false" if amount is tokensslippage
: The percent slippage allowedpriorityFee
: Amount to use as priority feepool
: (optional) Currently 'pump' and 'raydium' are supported options. Default is 'pump'.
If your parameters are valid, you will receive a serialized transaction in response. See the examples below for how to send this transaction with Python (Solders) or JavaScript (Web3.js).
Examples
- Python
- JavaScript
import requests
from solders.transaction import VersionedTransaction
from solders.keypair import Keypair
from solders.commitment_config import CommitmentLevel
from solders.rpc.requests import SendVersionedTransaction
from solders.rpc.config import RpcSendTransactionConfig
response = requests.post(url="https://pumpportal.fun/api/trade-local", data={
"publicKey": "Your public key here",
"action": "buy", # "buy" or "sell"
"mint": "token CA here", # contract address of the token you want to trade
"amount": 100000, # amount of SOL or tokens to trade
"denominatedInSol": "false", # "true" if amount is amount of SOL, "false" if amount is number of tokens
"slippage": 10, # percent slippage allowed
"priorityFee": 0.005, # amount to use as priority fee
"pool": "pump" # exchange to trade on. "pump" or "raydium"
})
keypair = Keypair.from_base58_string("Your base 58 private key here")
tx = VersionedTransaction(VersionedTransaction.from_bytes(response.content).message, [keypair])
commitment = CommitmentLevel.Confirmed
config = RpcSendTransactionConfig(preflight_commitment=commitment)
txPayload = SendVersionedTransaction(tx, config)
response = requests.post(
url="Your RPC Endpoint here - Eg: https://api.mainnet-beta.solana.com/",
headers={"Content-Type": "application/json"},
data=SendVersionedTransaction(tx, config).to_json()
)
txSignature = response.json()['result']
print(f'Transaction: https://solscan.io/tx/{txSignature}')
import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js';
import bs58 from "bs58";
const RPC_ENDPOINT = "Your RPC Endpoint";
const web3Connection = new Connection(
RPC_ENDPOINT,
'confirmed',
);
async function sendPortalTransaction(){
const response = await fetch(`https://pumpportal.fun/api/trade-local`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"publicKey": "your-public-key", // Your wallet public key
"action": "buy", // "buy" or "sell"
"mint": "token-ca-here", // contract address of the token you want to trade
"denominatedInSol": "false", // "true" if amount is amount of SOL, "false" if amount is number of tokens
"amount": 1000, // amount of SOL or tokens
"slippage": 10, // percent slippage allowed
"priorityFee": 0.00001, // priority fee
"pool": "pump" // exchange to trade on. "pump" or "raydium"
})
});
if(response.status === 200){ // successfully generated transaction
const data = await response.arrayBuffer();
const tx = VersionedTransaction.deserialize(new Uint8Array(data));
const signerKeyPair = Keypair.fromSecretKey(bs58.decode("your-wallet-private-key"));
tx.sign([signerKeyPair]);
const signature = await web3Connection.sendTransaction(tx)
console.log("Transaction: https://solscan.io/tx/" + signature);
} else {
console.log(response.statusText); // log error
}
}
sendPortalTransaction();