2

I want to build a nice ui that shows the current status of a transaction counting up the confirmations up to 31.

For some reason I am not getting a result. Any ideas what I am doing wrong?

The json I am sending to the RPC.

{"method":"getSignatureStatuses","params":[["3EKVxNaGsuZBm24Kb33exdbB3uy3XTGv5GbuLYhmmZifrQpEka3PEhNZs2m8gbLWBHo3TLMLsxM8QjabW3tuDkXs"]],"jsonrpc":"2.0","id":0}

The result I am getting

{"jsonrpc":"2.0","result":{"context":{"apiVersion":"1.10.29","slot":141942914},"value":[null]},"id":0}

I can use getSignaturesForAddress, which works, but it seems a bit of a waste and does not show me the confirmations either.

2 Answers 2

2

getSignatureStatus(es) only searches the so-called StatusCache by default. This cache contains all processed transactions that have not yet been finalized. This default behavior is intended to provided the quickest reply to the request.

The methods can optionally request that transaction "history" be searched, which will look in both the local ledger, and if available a deep ledger history store like BigTable.

Something like this should work, assuming the block including the transaction has not been pruned from the local ledger or deep history is available.

{
  "method":"getSignatureStatuses",
  "params":[
    [
      "3EKVxNaGsuZBm24Kb33exdbB3uy3XTGv5GbuLYhmmZifrQpEka3PEhNZs2m8gbLWBHo3TLMLsxM8QjabW3tuDkXs"
    ],
    {
      "searchTransactionHistory":true
    }
  ],
  "jsonrpc":"2.0",
  "id":0
}
1
  • Ah thank you very much, that was it. And confirmations is just not set when its already finalized thats why i always got that null pointer there :D
    – Jonas H.
    Jul 17, 2022 at 17:54
0

Here is the C# code to show progress of a transaction for who is interested in the the working result. It nicely counts up the confirmation until the transaction is finalized.

private async Task CheckSignatureStatus(string signature)
{
    NftService nftService = ServiceFactory.Instance.Resolve<NftService>();
    MessageRouter messageRouter = ServiceFactory.Instance.Resolve<MessageRouter>();

    bool transactionFinalized = false;

    while (!transactionFinalized)
    {
        RequestResult<ResponseValue<List<SignatureStatusInfo>>> signatureResult =
            await nftService.GarblesRpcClient.GetSignatureStatusesAsync(new List<string>() {signature}, true);

        if (signatureResult.Result == null)
        {
            messageRouter.RaiseMessage(new BlimpSystem.ShowBlimpMessage($"There is no transaction for Signature: {signature}."));
            return;
        }

        foreach (var signatureStatusInfo in signatureResult.Result.Value)
        {
            if (signatureStatusInfo == null)
            {
                messageRouter.RaiseMessage(
                    new BlimpSystem.ShowBlimpMessage("Signature is not yet processed. Retry in 2 seconds."));
            }
            else
            {
                if (signatureStatusInfo.ConfirmationStatus == nameof(TransactionResult.finalized))
                {
                    transactionFinalized = true;
                    messageRouter.RaiseMessage(new BlimpSystem.ShowBlimpMessage("Transaction finalized"));
                }
                else
                {
                    messageRouter.RaiseMessage(
                        new BlimpSystem.ShowBlimpMessage($"Signature result {signatureStatusInfo.Confirmations}/31"));
                }
            }
        }

        if (!transactionFinalized)
        {
            await Task.Delay(2000);
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.