PumpFun Swap Endpoint
POST /api/v1/pumpfun/swap
Request Body
Parameter | Type | Description |
---|---|---|
userAddress | string | The Solana wallet address of the user executing the swap. |
tokenAddress | string | The address of the token to swap (also called mint or CA) |
creatorAddress | string | The address of the creator of the token. From bonding curve account data, or (with 99.9% chance) - the signer of the mint tx. |
tokenAmount | number | The amount of tokens to buy. |
solThreshold | number | The maximum Sol amount threshold for the swap, needed for buys only. Multiply by a coefficient to make it work as a slippage tolerance. Sells use minimal threshold of 1 lamport, which means that a sell tx will not fail due to price slippage. |
isBuy | boolean | Whether this is a buy (true ) or sell (false ) operation |
skipAccountCheck | boolean | Optional, default: false. Whether to skip the account existence check for the user. |
computePrice | number | Optional. Sets total compute limit to be allocated for all instructions within the created tx. |
computeLimit | number | Optional. Sets compute price in Lamports to be included as a part of the tx, known as priority fee. |
Examples
js
const swapData = {
userAddress: "dafs3GGvJoUYjTmxRXhkqCj3ULa9bvKmX7EDDMTwVFE",
tokenAddress: "D7oBwaR4qmvTv5sS9oxcBoxPawTuviNNVN9yXbakpump",
creatorAddress: '7RcPz6R9myjoFmfANPnhEQKvKwrsEnxA5UMwoEKrHnvG',
solThreshold: 0.1,
tokenAmount: 100000,
isBuy: false,
skipAccountCheck: true
};
async function getSwapTX() {
try {
const response = await fetch('https://api.degen.ing/api/v1/pumpfun/swap', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(swapData)
});
const result = await response.json();
console.log('Swap tx base64:', result.transaction.content);
} catch (error) {
console.error('Error requesting swap tx:', error);
}
}
bash
curl -X 'POST' \
-H 'Content-Type: application/json' \
'https://api.degen.ing/api/v1/pumpfun/swap' \
-d '{
"userAddress": "dafs3GGvJoUYjTmxRXhkqCj3ULa9bvKmX7EDDMTwVFE",
"tokenAddress": "D7oBwaR4qmvTv5sS9oxcBoxPawTuviNNVN9yXbakpump",
"creatorAddress": "7RcPz6R9myjoFmfANPnhEQKvKwrsEnxA5UMwoEKrHnvG",
"tokenAmount": 100000,
"solThreshold": 0.1,
"isBuy": true
}'
Response
json
{"transaction": { "content": "<base64 encoded transaction>" } }