Skip to content

Checking Transaction Status with Eidolon

In this example, we’ll demonstrate how to use the Provider class from Eidolon to check the status of a blockchain transaction using its hash. This functionality is essential for monitoring the success or failure of transactions on the blockchain.

Let’s walk through the process step by step.

Prerequisites

Before you begin, make sure you have the Eidolon SDK integrated into your project, and you have a valid transaction hash that you want to check.

Code Example

using System;
using System.Threading.Tasks;
using System.Numerics;
using UnityEngine;
public class TransactionStatusChecker : MonoBehaviour
{
// Instantiate RPC with default project settings RPC
JsonRpcProvider provider = new JsonRpcProvider();
private async void Start()
{
string transactionHash = "0xYourTransactionHashHere";
try
{
// Call the Provider method to get the transaction status
string status = await provider.GetTransactionStatus(transactionHash);
// Output the transaction status to the Unity console
Debug.Log($"Transaction Status: {status}");
if (status == "Success")
{
Debug.Log("Transaction Successful!")
}
else
{
Debug.Log("Transaction Failed!")
}
}
catch (Exception ex)
{
Debug.LogError($"An error occurred: {ex.Message}");
}
}
}

In this example, we create a TransactionStatusChecker script that fetches the status of a transaction using its hash. Replace "0xYourTransactionHashHere" with the actual transaction hash you want to check.

Explanation

  • We use the Provider.GetTransactionStatus(transactionHash) method provided by Eidolon to retrieve the transaction status.
  • The status can be one of the following:
    • Success: The transaction succeeded.
    • Failed: The transaction failed.
    • ”Transaction Receipt Not Found or Status Unknown”: The transaction receipt was not found, or its status is unknown.