[英][Solana / Solana/Web3.js]Unable to Airdrop Sol. Internal Error is thrown
所以這是一個簡單的 Solana / web3.js Airdrop 代碼。 我能夠檢查錢包余額。 但是當我嘗試執行空投時,會拋出內部錯誤。
下面是我的代碼
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()
執行時拋出以下錯誤。
Wallet Balance is 0
Error: airdrop to D6oLiSL2CrJkeEMmPZs2akHzUzoqD2M7yMVJWcB5KUF failed: Internal error
Wallet Balance is 0
請求空投失敗。
請幫我解決這個問題。 謝謝:)
de.net 上空投的當前最大值通常限制為 1 SOL,因此您只需將requestAirdrop
行更改為:
const fromAirDropSignature = await connection.requestAirdrop(publicKey, 1 * LAMPORTS_PER_SOL)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.