Jito Bundles
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
The request body contains an array of JSON payloads, each of them is describing its own transaction. You can create up to 5 transactions in one array
Examples
import requests
import base58
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
user_keypairs = [
Keypair.from_base58_string('Your base58 private key here'), # First
Keypair.from_base58_string('Your base58 private key here'), # Second
]
res = requests.post('https://pumpzone.fun/api/v2/trade',
headers = {"Content-Type": "application/json"},
json = [
{
'pub_key' : str(user_keypairs[0].pubkey()),
'mint' : '6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF', # Token address
'action' : 'buy', # 'buy', 'sell' or 'create'
'amount_sol' : 0.5, # The amount of SOL
# 'amount_tokens' : 10**6, # or the amount of tokens to buy
'slippage' : 25, # The percent slippage allowed (1 .. 100)
'priority_fee' : 0.0005 # Amount to use as priority fee
},
{
'pub_key' : str(user_keypairs[1].pubkey()),
'mint' : '6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF', # Token address
'action' : 'sell', # 'buy', 'sell' or 'create'
'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
},
# ...
# Up to 5 transactions
]
)
if res.status_code != 200:
print(res.text)
exit()
response = res.json()
txs = []
for idx, result in enumerate(response['result']):
msg = from_bytes_versioned(bytes(result['message']))
txs.append(base58.b58encode(bytes(VersionedTransaction(message = msg, keypairs = [user_keypairs[idx]]))).decode('utf-8'))
res = requests.post(
"https://mainnet.block-engine.jito.wtf/api/v1/bundles",
headers = {"Content-Type": "application/json"},
json = {
"jsonrpc": "2.0",
"id": 1,
"method": "sendBundle",
"params": [ txs ]
}
)
import { VersionedTransaction, Connection, Keypair, MessageV0 } from '@solana/web3.js';
import bs58 from 'bs58';
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 noncustodial_jito() {
const user_keypairs = [
Keypair.fromSecretKey(bs58.decode('Your base58 private key here')), // First
Keypair.fromSecretKey(bs58.decode('Your base58 private key here')), // Second
]
var res = await axios.post('https://pumpzone.fun/api/v2/trade',
JSON.stringify([
{
pub_key : user_keypairs[0].publicKey.toString(),
mint : '6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF', // Token address
action : 'buy', // 'buy', 'sell' or 'create'
amount_sol : 0.5, // The amount of SOL
// amount_tokens : 10**6, // or the amount of tokens to buy
slippage : 25, // The percent slippage allowed (1 .. 100)
priority_fee : 0.0005, // Amount to use as priority fee
},
{
pub_key : user_keypairs[1].publicKey.toString(),
mint : '6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF', // Token address
action : 'sell', // 'buy', 'sell' or 'create'
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
},
// ...
// Up to 5 transactions
]),
{headers: { 'Content-Type': 'application/json' }}
);
if(res.status != 200) {
console.log(res.data);
return;
}
var txs = [];
for(let idx = 0; idx < res.data.result.length; idx ++) {
const message = MessageV0.deserialize(new Uint8Array(res.data.result[idx].message));
const tx = new VersionedTransaction(message);
tx.sign([user_keypairs[idx]]);
txs.push(bs58.encode(tx.serialize()));
}
res = await axios.post('https://mainnet.block-engine.jito.wtf/api/v1/bundles',
JSON.stringify({
jsonrpc : "2.0",
id : 1,
method : sendBundle,
params : [ txs ]
}),
{headers: { 'Content-Type': 'application/json' }}
);
}
# status_code == 200
{
"version" : "v2",
"result" : [
{
"mint" : "6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF ",
"message" : [ byte array... ],
},
{
"mint" : "6WsLDhrc3hURPx5Rn3e12rBoRiXnj4F13K27uVn6stMF ",
"message" : [ byte array... ],
},
]
}
# status_code != 200
{
"version" : "v2",
"errors" : [ "Internal error, service is unavailable at now moment" ]
}