SOL Transfer API
Generate SOL transfer transactions for moving funds between Solana wallets. Support for specific amounts, full balance transfers, batch operations, and wallet consolidation strategies.
Endpoints
| Endpoint | Description |
|---|---|
POST /api/transfer | Transfer a specific amount of SOL |
POST /api/transfer-all | Transfer all SOL from wallet |
Transferring a Specific SOL Amount
Send an exact amount of SOL from one wallet to another. Useful for regular payments, automated distributions, or precise fund movements.
Endpoint: POST https://pumpdev.io/api/transfer
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
publicKey | string | Yes | Source wallet public key |
recipient | string | Yes | Destination wallet public key |
amount | number | Yes | Amount in SOL to transfer |
priorityFee | number | No | Priority fee in SOL (default: 0.0005) |
Example
import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js';
import bs58 from 'bs58';
const API_URL = 'https://pumpdev.io';
const RPC_URL = 'https://api.mainnet-beta.solana.com';
const PRIVATE_KEY = 'YourBase58PrivateKey';
async function transferSol() {
const keypair = Keypair.fromSecretKey(bs58.decode(PRIVATE_KEY));
const publicKey = keypair.publicKey.toBase58();
const recipient = 'DestinationWalletAddress';
const amount = 0.1; // Transfer 0.1 SOL
console.log('From:', publicKey);
console.log('To:', recipient);
console.log('Amount:', amount, 'SOL');
// 1. Build transfer transaction
const response = await fetch(`${API_URL}/api/transfer`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: publicKey,
recipient: recipient,
amount: amount
})
});
if (response.status !== 200) {
const error = await response.json();
console.error('API Error:', error);
return;
}
// 2. Deserialize the transaction
const data = await response.arrayBuffer();
const tx = VersionedTransaction.deserialize(new Uint8Array(data));
// 3. Sign with your wallet
tx.sign([keypair]);
// 4. Send to Solana
const connection = new Connection(RPC_URL, 'confirmed');
try {
const signature = await connection.sendTransaction(tx, {
skipPreflight: false,
maxRetries: 3
});
console.log('\nTransaction sent!');
console.log('Signature:', signature);
// Wait for confirmation
const confirmation = await connection.confirmTransaction(signature, 'confirmed');
if (confirmation.value.err) {
console.error('Transaction failed:', confirmation.value.err);
} else {
console.log('Transfer complete!');
}
} catch (err) {
console.error('Send error:', err.message);
}
}
transferSol();
Transferring Entire Wallet Balance
Move all available SOL from a wallet to a destination address. The transaction deducts only the priority fee and base transaction fee, transferring the remaining balance.
Endpoint: POST https://pumpdev.io/api/transfer-all
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
publicKey | string | Yes | Source wallet public key |
recipient | string | Yes | Destination wallet public key |
priorityFee | number | No | Priority fee in SOL (default: 0.0005) |
Response
Unlike /api/transfer (which returns binary), this endpoint returns JSON:
{
"transaction": "base58-encoded-transaction",
"balance": 1.25,
"estimatedAmount": 1.234,
"estimatedFees": 0.0055
}
| Field | Type | Description |
|---|---|---|
transaction | string | Base58-encoded unsigned VersionedTransaction |
balance | number | Current wallet balance in SOL |
estimatedAmount | number | SOL amount that will be transferred (after fees) |
estimatedFees | number | Estimated transaction fees in SOL |
Example
import { VersionedTransaction, Connection, Keypair, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
import bs58 from 'bs58';
const API_URL = 'https://pumpdev.io';
const RPC_URL = 'https://api.mainnet-beta.solana.com';
const PRIVATE_KEY = 'YourBase58PrivateKey';
async function transferAllSol() {
const keypair = Keypair.fromSecretKey(bs58.decode(PRIVATE_KEY));
const publicKey = keypair.publicKey.toBase58();
const recipient = 'DestinationWalletAddress';
const connection = new Connection(RPC_URL, 'confirmed');
// Check current balance
const balance = await connection.getBalance(new PublicKey(publicKey));
console.log('Current balance:', (balance / LAMPORTS_PER_SOL).toFixed(4), 'SOL');
console.log('Transferring all to:', recipient);
// 1. Build transfer-all transaction
const response = await fetch(`${API_URL}/api/transfer-all`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: publicKey,
recipient: recipient
})
});
if (response.status !== 200) {
const error = await response.json();
console.error('API Error:', error);
return;
}
// 2. Parse JSON response and deserialize the base58 transaction
const result = await response.json();
console.log('Estimated transfer:', result.estimatedAmount, 'SOL');
const tx = VersionedTransaction.deserialize(bs58.decode(result.transaction));
tx.sign([keypair]);
// 3. Send to Solana
try {
const signature = await connection.sendTransaction(tx, {
skipPreflight: false,
maxRetries: 3
});
console.log('\nTransaction sent!');
console.log('Signature:', signature);
// Wait for confirmation
await connection.confirmTransaction(signature, 'confirmed');
console.log('Transfer complete!');
// Check final balance
const finalBalance = await connection.getBalance(new PublicKey(publicKey));
console.log('Final balance:', (finalBalance / LAMPORTS_PER_SOL).toFixed(4), 'SOL');
} catch (err) {
console.error('Send error:', err.message);
}
}
transferAllSol();
Executing Batch Transfers
Send SOL to multiple recipient addresses in sequence. Ideal for airdrops, payroll distributions, or managing multiple wallet operations programmatically.
import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js';
import bs58 from 'bs58';
const API_URL = 'https://pumpdev.io';
const RPC_URL = 'https://api.mainnet-beta.solana.com';
const PRIVATE_KEY = 'YourBase58PrivateKey';
const RECIPIENTS = [
{ address: 'Wallet1Address', amount: 0.1 },
{ address: 'Wallet2Address', amount: 0.05 },
{ address: 'Wallet3Address', amount: 0.2 },
];
async function batchTransfer() {
const keypair = Keypair.fromSecretKey(bs58.decode(PRIVATE_KEY));
const publicKey = keypair.publicKey.toBase58();
const connection = new Connection(RPC_URL, 'confirmed');
console.log('Starting batch transfer...');
console.log('From:', publicKey);
for (const rcpt of RECIPIENTS) {
console.log(`\nTransferring ${rcpt.amount} SOL to ${rcpt.address}...`);
try {
// Build transaction
const response = await fetch(`${API_URL}/api/transfer`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: publicKey,
recipient: rcpt.address,
amount: rcpt.amount
})
});
if (response.status !== 200) {
const error = await response.json();
console.log(' Error:', error.error);
continue;
}
// Sign and send
const data = await response.arrayBuffer();
const tx = VersionedTransaction.deserialize(new Uint8Array(data));
tx.sign([keypair]);
const signature = await connection.sendTransaction(tx, {
skipPreflight: false,
maxRetries: 3
});
console.log(' Success:', signature);
// Wait for confirmation before next transfer
await connection.confirmTransaction(signature, 'confirmed');
} catch (err) {
console.log(' Error:', err.message);
}
// Small delay between transfers
await new Promise(resolve => setTimeout(resolve, 500));
}
console.log('\nBatch transfer complete!');
}
batchTransfer();
Consolidating Multiple Wallets
Aggregate SOL balances from multiple source wallets into a single destination wallet. Perfect for managing multiple trading accounts or consolidating funds from various sources.
import { VersionedTransaction, Connection, Keypair, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
import bs58 from 'bs58';
const API_URL = 'https://pumpdev.io';
const RPC_URL = 'https://api.mainnet-beta.solana.com';
// Wallets to consolidate from
const SOURCE_WALLETS = [
'PrivateKeyWallet1',
'PrivateKeyWallet2',
'PrivateKeyWallet3',
];
// Destination wallet
const DESTINATION_WALLET = 'MainWalletPublicKey';
async function consolidateWallets() {
const connection = new Connection(RPC_URL, 'confirmed');
console.log('Consolidating to:', DESTINATION_WALLET);
console.log('---');
let totalTransferred = 0;
for (const privKey of SOURCE_WALLETS) {
const keypair = Keypair.fromSecretKey(bs58.decode(privKey));
const publicKey = keypair.publicKey.toBase58();
// Check balance
const balance = await connection.getBalance(new PublicKey(publicKey));
const balanceSol = balance / LAMPORTS_PER_SOL;
console.log(`\nWallet: ${publicKey.slice(0, 8)}...`);
console.log(`Balance: ${balanceSol.toFixed(4)} SOL`);
if (balanceSol < 0.001) {
console.log('Skipping (too low)');
continue;
}
try {
// Transfer all SOL
const response = await fetch(`${API_URL}/api/transfer-all`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: publicKey,
recipient: DESTINATION_WALLET
})
});
if (response.status !== 200) {
const error = await response.json();
console.log('Error:', error.error);
continue;
}
const data = await response.arrayBuffer();
const tx = VersionedTransaction.deserialize(new Uint8Array(data));
tx.sign([keypair]);
const signature = await connection.sendTransaction(tx, {
skipPreflight: false,
maxRetries: 3
});
await connection.confirmTransaction(signature, 'confirmed');
console.log('Transferred!', signature.slice(0, 16) + '...');
totalTransferred += balanceSol;
} catch (err) {
console.log('Error:', err.message);
}
// Delay between transfers
await new Promise(resolve => setTimeout(resolve, 500));
}
console.log('\n=== COMPLETE ===');
console.log('Total transferred:', totalTransferred.toFixed(4), 'SOL');
}
consolidateWallets();
Error Handling & Troubleshooting
Common API Errors
| Error Message | Cause | Resolution |
|---|---|---|
publicKey is required | Missing source wallet parameter | Include publicKey in request body |
recipient is required | Missing destination wallet parameter | Include recipient in request body |
amount must be a positive number | Missing or invalid transfer amount (for /api/transfer) | Specify a positive amount value |
Account has zero balance | Source wallet has no SOL (for /api/transfer-all) | Fund the wallet before transferring |
Insufficient balance to cover fees | Wallet balance too low to cover transaction fees (for /api/transfer-all) | Add more SOL to cover fees |
Invalid publicKey or recipient address | Malformed Solana wallet address format | Validate address format and ensure correct encoding |
Next Steps
- ⚡ Lightning Trade — One-call buy/sell
- ⚡ Lightning Setup — Create a Lightning wallet
- Trade API — Client-side buy and sell
- Token Creation — Create new tokens
- Fees — Full pricing details