Open 596448122 opened 10 months ago
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?
@596448122 make sure to use the latest 0.4.0 version of sol4k. I have just updated examples accordingly.
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} )
how can solve that error
@hiren-0007 could you please share the code as text so that I can try it out?
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
computer has vpn, the idea request times out. But postman succeeded