> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spire.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Request Status

<Warning>A non-preconf request is not stored therefore an error / no data is returned if queried.</Warning>

## Query request status

Once a **preconf request** has been submitted you may use the hash to query its status to see if it has finished processing and if it has succeeded or failed. Here's an example request querying against the holesky network and using the transaction hash from the [Submit Request](/preconf-rpc/submit-request) results:

<CodeGroup>
  ```bash Curl theme={null}
  curl -X POST 'https://preconf.holesky.spire.dev/v0/' \
    -H "Content-Type: application/json" \
    --data '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "transaction",
      "params": { "tx_hash": "0xYOUR_TX_HASH" }
    }'
  ```

  ```bash Cast theme={null}
  cast rpc --rpc-url https://preconf.holesky.spire.dev/v0/ \
    transaction '{"tx_hash":"0xYOUR_TX_HASH"}'
  ```

  ```rust Rust/Alloy theme={null}
  use alloy::providers::{Provider, ProviderBuilder};
  use alloy::rpc::types::Params;
  use alloy::transport::http::Http;

  let provider = ProviderBuilder::new().connect_http("https://preconf.holesky.spire.dev/v0/")?;

  let tx_hash = "0xYOUR_TX_HASH";
  let tx_status = provider.request("transaction", Params::Array(vec![serde_json::json!({ "tx_hash": tx_hash })])).await?;

  println!("Transaction status: {:?}", tx_status);
  ```

  ```go Go theme={null}
  client, err := ethclient.Dial("https://preconf.holesky.spire.dev/v0/")
  if err != nil {
      log.Fatal(err)
  }

  // ---- Query Status ----
  var statusResult map[string]interface{}
  err = client.CallContext(context.Background(), &statusResult, "transaction", map[string]string{
  	"tx_hash": txHash,
  })
  if err != nil {
  	log.Fatalf("Error calling transaction: %v", err)
  }
  fmt.Println("Status:", statusResult)
  ```

  ```javascript JS/Ethers theme={null}
  import { ethers } from 'ethers';

  const provider = new ethers.JsonRpcProvider(
    "https://preconf.holesky.spire.dev/v0/"
  );

  const txHash = "0xYOUR_TX_HASH";

  const status = await provider.send("transaction", [{ tx_hash: txHash }]);
  console.log("Status:", status);
  ```

  ```python Python/Web3 theme={null}
  from web3 import Web3

  w3 = Web3(Web3.HTTPProvider(
      "https://preconf.holesky.spire.dev/v0/"
  ))

  tx_hash = "0xYOUR_TX_HASH"

  # Query status
  status = w3.manager.request_blocking("transaction", [{"tx_hash": tx_hash}])
  print("Status:", status)
  ```
</CodeGroup>

A valid request that successfully received a preconf commitment will respond with something like:

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tx_hash": "0x...",
    "query": {"deadline":3,"fallback":true,"preconf":true},
    "status": "Success",
    "timestamp_unix_seconds": "1749219302",
    "request_id": 1
  }
}
```

The request result status has four possible values:

* **`Submitted`** - Initial value when the router stores the request
* **`Pending`** - Awaiting a response from preconf providers
* **`Success`** - a pre-confirmation commitment was received within the `deadline` or in the case that the request had the `fallback` parameter set to `true` the request was forwarded as a standard request
* **`Failure`** - Any other scenario

## Query commitment

If in the previous stage the `status` contained `Success` then we may attempt to query the commitment.
<Warning>A request may have a `Success` status if it failed to gain a commitment but successfully forwarded the request to an RPC provider. In this case querying for a commitment will result in an error response.</Warning>

<CodeGroup>
  ```bash Curl theme={null}
  curl -X POST 'https://preconf.holesky.spire.dev/v0/' \
    -H "Content-Type: application/json" \
    --data '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "commitment",
      "params": { "tx_hash": "0xYOUR_TX_HASH" }
    }'
  ```

  ```bash Cast theme={null}
  cast rpc --rpc-url https://preconf.holesky.spire.dev/v0/ \
    commitment '{"tx_hash":"0xYOUR_TX_HASH"}'
  ```

  ```rust Rust/Alloy theme={null}
  use alloy::providers::{Provider, ProviderBuilder};
  use alloy::rpc::types::Params;
  use alloy::transport::http::Http;

  let provider = ProviderBuilder::new().connect_http("https://preconf.holesky.spire.dev/v0/")?;

  let tx_hash = "0xYOUR_TX_HASH";
  let commitment = provider.request("commitment", Params::Array(vec![serde_json::json!({ "tx_hash": tx_hash })])).await?;

  println!("Commitment: {:?}", commitment);
  ```

  ```go Go theme={null}
  client, err := ethclient.Dial("https://preconf.holesky.spire.dev/v0/")
  if err != nil {
      log.Fatal(err)
  }

  // ---- Query Commitment ----
  var commitmentResult map[string]interface{}
  err = client.CallContext(context.Background(), &commitmentResult, "commitment", map[string]string{
  	"tx_hash": txHash,
  })
  if err != nil {
  	log.Printf("Commitment query failed (might be no commitment): %v", err)
  } else {
  	fmt.Println("Commitment:", commitmentResult)
  }
  ```

  ```javascript JS/Ethers theme={null}
  import { ethers } from 'ethers';

  const provider = new ethers.JsonRpcProvider(
    "https://preconf.holesky.spire.dev/v0/"
  );

  const txHash = "0xYOUR_TX_HASH";

  const commitment = await provider.send("commitment", [{ tx_hash: txHash }]);
  console.log("Commitment:", commitment);
  ```

  ```python Python/Web3 theme={null}
  from web3 import Web3

  w3 = Web3(Web3.HTTPProvider(
      "https://preconf.holesky.spire.dev/v0/"
  ))

  tx_hash = "0xYOUR_TX_HASH"

  # Query status
  commitment = w3.manager.request_blocking("commitment", [{"tx_hash": tx_hash}])
  print("Commitment:", commitment)
  ```
</CodeGroup>

If a commitment has been acquired then a valid request will respond with something like

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tx_hash": "0x...",
    "signature": "0x...",
    "slot": 42,
    "preconfer": "uuid",
    "timestamp_unix_seconds": "1749219302"
  }
}
```
