Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a problem #11

Open
596448122 opened this issue Dec 21, 2023 · 5 comments
Open

a problem #11

596448122 opened this issue Dec 21, 2023 · 5 comments

Comments

@596448122
Copy link

596448122 commented Dec 21, 2023

computer has vpn, the idea request times out. But postman succeeded
9611d2c972962070005c18615fc4a99

@Shpota
Copy link
Member

Shpota commented Dec 22, 2023

Hi @596448122
I have double-checked the repository with examples and it worked well. Please note that https://api.devnet.solana.com is a public node and it might be rate limited especially if you are using a VPN. I would suggest you try it without VPN. You can also try your own RPC URL (from Infura or any other provider). Also, I see you are using sol4k in combination with other Solana libraries. It might also cause issues. Could you please try running this example from the sol4k-examples repository itself? Does it error out there as well?

@Shpota
Copy link
Member

Shpota commented Dec 22, 2023

@596448122 make sure to use the latest 0.4.0 version of sol4k. I have just updated examples accordingly.

@hiren-0007
Copy link

RpcException(code=-32002, message=Transaction simulation failed: Attempt to debit an account but found no record of a prior credit., rawResponse={"jsonrpc":"2.0","error":{"code":-32002,"message":"Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.","data":{"accounts":null,"err":"AccountNotFound","innerInstructions":null,"logs":[],"returnData":null,"unitsConsumed":0}},"id":1721106591507} )

Screenshot 2024-07-16 at 10 45 47 AM

how can solve that error

@Shpota
Copy link
Member

Shpota commented Jul 16, 2024

@hiren-0007 could you please share the code as text so that I can try it out?

@hiren-0007
Copy link

public class SolTransfer {
private Connection connection;
private PublicKey receiver;
private Keypair sender;

public SolTransfer() {
    connection = new Connection("https://api.devnet.solana.com");
    receiver = new PublicKey("AUSuwNT7t39rKy3jiRCucycirsCbHBAFB9TtJgU4qcqY");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        sender = Keypair.fromSecretKey(Base64.getDecoder().decode("2WGcYYau2gLu2DUq68SxxXQmCgi77n8hFqqLNbNyg6Xfh2m3tvg8LF5Lgh69CFDux41LUKV1ak1ERHUqiBZnyshz"));
    }
}

public String getLatestBlockhash() {
    return connection.getLatestBlockhash();
}

public String sendSol(long lamports) {
    try {
        String blockhash = getLatestBlockhash();
        if (blockhash == null) {
            throw new RuntimeException("Failed to get blockhash");
        }

        var instruction = new TransferInstruction(sender.getPublicKey(), receiver, lamports);
        var transaction = new Transaction(blockhash, instruction, sender.getPublicKey());
        transaction.sign(sender);

        var signature = connection.sendTransaction(transaction);

        if (signature == null) {
            throw new RuntimeException("Failed to send transaction");
        }

        return signature;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
}
 private fun PrintSignature() {
    val solTransfer = SolTransfer()
    val signature = solTransfer.sendSol(10)
    if (signature != null) {
        println("Transaction => Signature: $signature")
    } else {
        println("Transaction => failed")
    }
}

please check that all time print failed how can solve
@Shpota 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants