'[Solana / Solana/Web3.js]Unable to Airdrop Sol. Internal Error is thrown
So this is a simple Solana / web3.js Airdrop code. I was able to check the wallet balance. But when I tried to perform an airdrop, internal error is thrown.
Below is my code
const{
Connection,
PublicKey,
clusterApiUrl,
Keypair,
LAMPORTS_PER_SOL
} = require("@solana/web3.js")
const wallet = new Keypair()
const publicKey = new PublicKey(wallet._keypair.publicKey)
const secretKey = wallet._keypair.secretKey
const getWalletBalance = async() => {
try{
const connection = new Connection(clusterApiUrl('devnet'),'confirmed')
const walletBalance = await connection.getBalance(publicKey)
console.log(`Wallet Balance is ${walletBalance}`)
}
catch(er){
console.log(er)
}
}
const airDropSol = async() =>{
try{
const connection = new Connection(clusterApiUrl('devnet'),'confirmed')
const fromAirDropSignature = await connection.requestAirdrop(publicKey, 2 * LAMPORTS_PER_SOL)
await connection.confirmTransaction(fromAirDropSignature)
}catch(er){
console.log('Error Here: '+er)
}
}
const main = async() =>{
await getWalletBalance()
await airDropSol()
await getWalletBalance()
}
main()
Below Error is thrown when executed.
Wallet Balance is 0
Error: airdrop to D6oLiSL2CrJkeEMmPZs2akHzUzoqD2M7yMVJWcB5KUF failed: Internal error
Wallet Balance is 0
Request Airdrop failed.
Kindly help me to resolve this. Thanks :)
Solution 1:[1]
I tested your code and it is working:
Internal error means, solana team might be doing maintenance during you execute your code or there were too many requests at that time which is a common problem for faucets.
Solution 2:[2]
The current maximum for airdrops on devnet is usually limited to 1 SOL, so you can just change the requestAirdrop line to:
const fromAirDropSignature = await connection.requestAirdrop(publicKey, 1 * LAMPORTS_PER_SOL)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yilmaz |
| Solution 2 | Pang |

