[英][Solana / Solana/Web3.js]Unable to Airdrop Sol. Internal Error is thrown
So this is a simple Solana / web3.js Airdrop code.所以这是一个简单的 Solana / web3.js Airdrop 代码。 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:)
谢谢:)
The current maximum for airdrops on de.net is usually limited to 1 SOL, so you can just change the requestAirdrop
line to: de.net 上空投的当前最大值通常限制为 1 SOL,因此您只需将
requestAirdrop
行更改为:
const fromAirDropSignature = await connection.requestAirdrop(publicKey, 1 * LAMPORTS_PER_SOL)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.