• Custodial API
  • Trade Token

Trade Token

To get a transaction for signing and sending, you need to make a POST request to the REST API entry point

https://pumpzone.fun/api/v2/trade


Include a JSON payload in the body of your request:

  • api_key — Your API key
  • mint — Token addressа (base58)
  • action — «buy» or «sell»
  • amount_sol — The amount of SOL to buy a token. It's mutually exclusive with the amount_tokens field
  • amount_percent — The amount of tokens to sell in percent. It's mutually exclusive with the amount_tokens field
  • amount_tokens — The amount of tokens to buy/sell
  • slippage — The percent slippage allowed in percent (by default 25%)
  • priority_fee — Amount used to enhance transaction speed

Примеры

import requests

from solders.keypair import Keypair
from solders.transaction import VersionedTransaction
from solders.message import from_bytes_versioned
from solders.commitment_config import CommitmentLevel
from solders.rpc.requests import SendVersionedTransaction
from solders.rpc.config import RpcSendTransactionConfig

res = requests.post('https://pumpzone.fun/api/v2/trade',
    headers = {"Content-Type": "application/json"},
    json = {
        'api_key'       : 'Your API key here',
        'mint'          : '6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF',   # Token address
        'action'        : 'sell',                                           # 'buy' or 'sell'
        'amount_tokens' : 10**6,                                            # The amount of tokens to sell
        # 'amount_percent' : 30,                                            # or a percentage of tokens
        'slippage'      : 25,                                               # The percent slippage allowed (1 .. 100)
        'priority_fee'  : 0.0005,                                           # Amount to use as priority fee
})

if res.status_code != 200:
    print(res.text)
    exit()

response = res.json()
print('mint: ', response['result']['mint'])
print('signature: ', response['result']['signature'])
print('signature url:', response['result']['signature_url'])
import { VersionedTransaction, Connection, Keypair, MessageV0 } from '@solana/web3.js';
import axios from 'axios';

const RPC_ENDPOINT = "https://api.mainnet-beta.solana.com"; // Your RPC entrypoint
const rpc_client = new Connection(
    RPC_ENDPOINT,
    'confirmed',
);

async function custodial_trade() {
   const res = await axios.post('https://pumpzone.fun/api/v2/trade',
      JSON.stringify({
         api_key       : 'Your API key here',
         mint          : '6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF',   // Token address
         action        : 'sell',                                           // 'buy' or 'sell'
         amount_tokens : 10**6,                                            // The amount of tokens to sell
         // amount_percent : 30,                                           // or a percentage of tokens
         slippage      : 25,                                               // The percent slippage allowed (1 .. 100)
         priority_fee  : 0.0005,                                           // Amount to use as priority fee
      }),
      {headers: { 'Content-Type': 'application/json' }}
   );

   if(res.status != 200) {
      console.log(res.data);
      return;
   }

   console.log('mint: ', res.data.result.mint);
   console.log('signature: ', res.data.result.signature);
   console.log('signature url: ', res.data.result.signature_url);
}
# status_code == 200
{
  "version" : "v2",
  "result"  : {
    "mint" : "6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF",
    "signature" : "3nYzkvjpGrmLfGYx4r8rWS3AJcWXZV5Xh3gjbeTbKxyFHpSrHFk5guQwLXUSmBh8jUMnFNoETPVr64SRk6dEZBxR",
    "signurure_url" : "https://solscan.io/tx/3nYzkvjpGrmLfGYx4r8rWS3AJcWXZV5Xh3gjbeTbKxyFHpSrHFk5guQwLXUSmBh8jUMnFNoETPVr64SRk6dEZBxR"
  }
}

# status_code != 200
{
  "version" : "v2",
  "errors"  : [ "Internal error, service is unavailable at now moment" ]
}