espresso-cash-public icon indicating copy to clipboard operation
espresso-cash-public copied to clipboard

When I'm calling sendTransaction method not getting signature.

Open parth22 opened this issue 2 years ago • 0 comments

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:

  1. I'm calling Jupiter v1/quote
  2. After that I'm calling Jupiter v1/swap
  3. 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;
  }
  1. See an error I attached a screenshot of it. Screenshot 2022-09-13 at 6 37 04 PM

Expected behaviour As expected behaviour, I will get a signature for this transaction.

Thanks

parth22 avatar Sep 14 '22 06:09 parth22