airdropTokensBatch
This function performs large-scale airdrops using a batched approach.
Usage
page.tsx
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import { airdropTokensBatch } from "@okito/sdk";
const {connection} = useConnection();
const wallet = useWallet();
const mintAddress = ""; // mint address for the token
const recipients = [
{ address: "recipient1Address", amount: 100 },
{ address: "recipient2Address", amount: 200 },
// ... thousands more recipients
];
const config = {
batchSize: 15,
batchDelayMs: 3000,
progressCallback: (progress) => {
console.log(`Progress: ${progress.completedBatches}/${progress.totalBatches} batches completed`);
}
};
const airdropResult = await airdropTokensBatch(connection, wallet, mintAddress, recipients, config);
Capabilities
- Handles large recipient lists in batches
- Optional progress callback for UI feedback
- Per-batch retries with delays
Parameters
Name | Type | Default |
---|---|---|
connection | Connection The connection object to the Solana blockchain. |
|
wallet | SignerWallet The wallet object of the sender. |
|
mint | string The mint address of the token being airdropped. |
|
recipients | AirdropRecipient[] Array of recipients (unlimited for large safe airdrop). |
|
config | AirdropInBatchesConfig Configuration for the large-scale airdrop operation. |
|
AirdropInBatchesConfig
Name | Type | Default |
---|---|---|
batchSize | number Number of recipients per batch (max 20). |
|
batchDelayMs | number Delay between batches in milliseconds (min 2000). |
|
maxBatchRetries | number Maximum retry attempts per batch. |
|
preflightValidation | boolean Enable comprehensive preflight validation. |
|
networkStabilityCheck | boolean Check network stability before execution. |
|
progressCallback | (progress: AirdropProgress) => void Callback function for progress updates. |
|
pauseOnError | boolean Pause execution on repeated batch failures. |
|
dryRun | boolean Simulate the operation without sending transactions. |
|
confirmationStrategy | 'processed' | 'confirmed' | 'finalized' Transaction confirmation level. |
|
priorityFee | number Priority fee in micro-lamports. |
|
createRecipientAccount | boolean Automatically create recipient token accounts. |
|
AirdropProgress
Name | Type | Default |
---|---|---|
totalBatches | number Total number of batches to process. |
|
completedBatches | number Number of batches completed successfully. |
|
failedBatches | number Number of batches that failed. |
|
totalRecipients | number Total number of recipients. |
|
processedRecipients | number Number of recipients processed successfully. |
|
failedRecipients | number Number of recipients that failed. |
|
currentBatch | number | undefined Currently processing batch number. |
|
estimatedTimeRemaining | number | undefined Estimated time remaining in milliseconds. |
|
lastTransactionId | string | undefined Last successful transaction ID. |
|
Response (Large Safe Airdrop)
Name | Type | Default |
---|---|---|
success | boolean Whether the overall airdrop operation was successful. |
|
transactionId | string | undefined The first transaction ID (for compatibility). |
|
transactionIds | string[] | undefined Array of all transaction IDs from successful batches. |
|
estimatedFee | number Estimated total fee in lamports. |
|
actualFee | number Actual total fee paid in lamports. |
|
confirmationTime | number Total time taken for the operation in milliseconds. |
|
recipientsProcessed | number Number of recipients successfully processed. |
|
recipientsFailed | number | undefined Number of recipients that failed. |
|
accountsCreated | number Total number of token accounts created. |
|
totalAmountSent | string Total amount of tokens sent (in raw token units). |
|
batchCount | number | undefined Total number of batches processed. |
|
successfulBatches | number | undefined Number of batches completed successfully. |
|
failedBatches | number | undefined Number of batches that failed. |
|
successRate | number | undefined Success rate as a percentage (0-100). |
|
error | string | undefined Error message if the operation failed. |
|
Last updated on