• Custodial API
  • Покупка/продажа

Покупка/продажа токена

Сформировать транзакцию для подписи и отправки необходимо через POST запрос REST API вызова

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


В теле запроса передай JSON-струтуру со следующими полями:

  • api_key — Ключ взаимодейсвия с сервисом PumpZone
  • mint — Адрес токена (base58)
  • action — «buy» или «sell»
  • amount_sol — На какое количество SOL купить созданных токенов. Взаимоисключающее поле с amount_tokens
  • amount_percent — Какое количество токенов продать в процентах (от 1 до 100). Взаимоисключающее поле с amount_tokens
  • amount_tokens — Какое количество токенов купить или продать
  • slippage — Процент проскальзывания при покупке. Число от 1 до 100 (по умолчанию 25%)
  • priority_fee — Приоритетная комиссия блокчейна Solana в SOL

Примеры

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 user_keypair = Keypair.fromSecretKey(bs58.decode('Your base58 private key here'));

   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" ]
}