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 | ConnectionThe connection object to the Solana blockchain. | |
wallet | SignerWalletThe wallet object of the sender. | |
mint | stringThe mint address of the token being airdropped. | |
recipients | AirdropRecipient[]Array of recipients (unlimited for large safe airdrop). | |
config | AirdropInBatchesConfigConfiguration for the large-scale airdrop operation. | |
AirdropInBatchesConfig
| Name | Type | Default |
|---|---|---|
batchSize | numberNumber of recipients per batch (max 20). | |
batchDelayMs | numberDelay between batches in milliseconds (min 2000). | |
maxBatchRetries | numberMaximum retry attempts per batch. | |
preflightValidation | booleanEnable comprehensive preflight validation. | |
networkStabilityCheck | booleanCheck network stability before execution. | |
progressCallback | (progress: AirdropProgress) => voidCallback function for progress updates. | |
pauseOnError | booleanPause execution on repeated batch failures. | |
dryRun | booleanSimulate the operation without sending transactions. | |
confirmationStrategy | 'processed' | 'confirmed' | 'finalized'Transaction confirmation level. | |
priorityFee | numberPriority fee in micro-lamports. | |
createRecipientAccount | booleanAutomatically create recipient token accounts. | |
AirdropProgress
| Name | Type | Default |
|---|---|---|
totalBatches | numberTotal number of batches to process. | |
completedBatches | numberNumber of batches completed successfully. | |
failedBatches | numberNumber of batches that failed. | |
totalRecipients | numberTotal number of recipients. | |
processedRecipients | numberNumber of recipients processed successfully. | |
failedRecipients | numberNumber of recipients that failed. | |
currentBatch | number | undefinedCurrently processing batch number. | |
estimatedTimeRemaining | number | undefinedEstimated time remaining in milliseconds. | |
lastTransactionId | string | undefinedLast successful transaction ID. | |
Response (Large Safe Airdrop)
| Name | Type | Default |
|---|---|---|
success | booleanWhether the overall airdrop operation was successful. | |
transactionId | string | undefinedThe first transaction ID (for compatibility). | |
transactionIds | string[] | undefinedArray of all transaction IDs from successful batches. | |
estimatedFee | numberEstimated total fee in lamports. | |
actualFee | numberActual total fee paid in lamports. | |
confirmationTime | numberTotal time taken for the operation in milliseconds. | |
recipientsProcessed | numberNumber of recipients successfully processed. | |
recipientsFailed | number | undefinedNumber of recipients that failed. | |
accountsCreated | numberTotal number of token accounts created. | |
totalAmountSent | stringTotal amount of tokens sent (in raw token units). | |
batchCount | number | undefinedTotal number of batches processed. | |
successfulBatches | number | undefinedNumber of batches completed successfully. | |
failedBatches | number | undefinedNumber of batches that failed. | |
successRate | number | undefinedSuccess rate as a percentage (0-100). | |
error | string | undefinedError message if the operation failed. | |
Last updated on