espresso-cash-public
espresso-cash-public copied to clipboard
When I'm calling sendTransaction method not getting signature.
I'm swapping tokens by using Jupiter swap for Solana. And, It's working fine I'm getting swapped serialized transactions for a particular route. But after that when I'm trying to get a signature by using these serialized transactions received by Jupiter swap. I'm using sendTransaction method of the Solana flutter package at that time I'm getting the below error logs.
Program logic: Instruction: Set Token Ledger
Program log: AnchorError caused by account: token_account. Error Code: AccountNotInitialized. Error Number: 3012. Error Message: The program expected this account to be already initialized.
To Reproduce Steps to reproduce the behaviour:
- I'm calling Jupiter v1/quote
- After that I'm calling Jupiter v1/swap
- than Using the below method to get a signature.
Future<String?> maybeExecuteTx({
required String? tx,
required ValueSetter<SwapException> onError,
}) async {
try {
if (tx == null) return null;
final decoded = base64Decode(tx);
final byteArray = ByteArray(decoded);
final compiled = CompiledMessage.fromSignedTransaction(byteArray);
final message = Message.decompile(compiled);
final recent = await client.rpcClient.getRecentBlockhash();
final recompiled = message.compile(recentBlockhash: recent.blockhash);
final walletDetails = wallet;
final signedTx = SignedTx(
messageBytes: recompiled.data,
signatures: [await walletDetails.sign(recompiled.data)]);
final transaction = signedTx.encode();
final signature = await client.rpcClient.sendTransaction(
transaction,
preflightCommitment: Commitment.confirmed,
);
await client.waitForSignatureStatus(
signature,
status: Commitment.confirmed,
timeout: const Duration(minutes: 1),
);
return signature;
} on SwapException catch (e) {
onError(e);
}
return null;
}
- See an error I attached a screenshot of it.
Expected behaviour As expected behaviour, I will get a signature for this transaction.
Thanks