简体   繁体   English

[Solana / Solana/Web3.js]无法空投 Sol。 抛出内部错误

[英][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)

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.内部错误意味着,solana 团队可能在您执行代码期间进行维护,或者当时请求太多,这是水龙头的常见问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM