This project contains a TypeScript script to perform an airdrop of SPL tokens on the Solana blockchain. The script reads recipient addresses from a JSON file and transfers a specified amount of tokens to each recipient.
- Node.js and npm installed on your machine. You can download them from nodejs.org
- TypeScript installed globally:
npm install -g typescript
git clone https://github.com/talhamalik883/solana-airdrop.git
cd solana-airdrop
npm install
- Create a
.env
file in the root directory - Add the following required attributes:
ECLIPSE_PRIVATE_KEY=your_base58_encoded_private_key
HELIUS_RPC_URL=https://mainnet.helius-rpc.com/?api-key=your_helius_api_key
- Sign up for an account at Helius
- Get your API key from the dashboard
- Update the
HELIUS_RPC_URL
in your.env
file with your API key
Create an output.json
file in the project root with the following structure:
[
{
"address": "recipient_address",
"mint": "token_mint_address",
"owner": "recipient_public_key",
"amount": 1,
"delegated_amount": 0,
"token_extensions": {
"transfer_fee_amount": {
"withheld_amount": 0
}
},
"frozen": false
}
]
Execute the airdrop script using ts-node:
npx tsx airdrop_script.ts
The script will output the status of each transaction to the console. Watch for any error messages or failed transactions.
solana-airdrop/
├── airdrop_script.ts # Main script for token airdrop
├── tsconfig.json # TypeScript configuration
├── package.json # Project dependencies and scripts
├── .env # Environment variables (ignored by git)
├── .env.exmaple # Environment variables example
├── output.json # Recipient data file (ignored by git)
└── .gitignore # Git ignore rules
- airdrop_script.ts: Contains the main logic for the SPL token airdrop
- output.json: JSON file containing recipient addresses and token amounts
- .env: Configuration file for private keys and RPC URLs
- tsconfig.json: TypeScript compiler configuration
- package.json: NPM package configuration and dependencies
- Script Failures: Check the console logs for detailed error messages
- Invalid Addresses: Verify all recipient addresses in
outp 534B ut.json
are valid Solana addresses - Network Issues:
- Ensure stable internet connection
- Verify Helius RPC URL is correct
- Check Helius API key validity
This project is licensed under the MIT License - see the LICENSE file for details.