sui_getTransactionBlock{deprecated} - Sui

This method retrieves detailed information about a transaction block for a specified digest on the SUI network, including inputs, effects, events, object changes, and balance changes.

This method is deprecated

Parameters

ParameterTypeRequiredDescriptionDefault/Supported Values
digeststringYesThe transaction digest (Base58 encoded hash)Valid transaction digest string
optionsobjectNoOptions specifying which data to includeSee TransactionBlockResponseOptions

TransactionBlockResponseOptions

FieldTypeDefaultDescription
showInputbooleanfalseInclude transaction input data
showRawInputbooleanfalseInclude raw transaction bytes
showEffectsbooleanfalseInclude execution effects
showEventsbooleanfalseInclude emitted events
showObjectChangesbooleanfalseInclude object modifications
showBalanceChangesbooleanfalseInclude balance changes

Request Example

bashcurl --location --request POST https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/ \
--header 'Content-Type: application/json' \
--data-raw '{
  "jsonrpc": "2.0",
  "method": "sui_getTransactionBlock",
  "params": [
    "5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv",
    {
      "showInput": true,
      "showEffects": true,
      "showEvents": true,
      "showObjectChanges": true,
      "showBalanceChanges": true
    }
  ],
  "id": "getblock.io"
}'

main.rs

rustuse reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "id": "getblock.io",
        "method": "sui_getTransactionBlock",
        "params": [
            "5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv",
            {
                "showInput": true,
                "showEffects": true,
                "showEvents": true
            }
        ]
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    println!("Response: {:?}", response.text().await?);
    Ok(())
}

get_transaction.js

javascriptconst axios = require('axios');

const url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/";
const payload = {
  jsonrpc: "2.0",
  method: "sui_getTransactionBlock",
  params: [
    "5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv",
    {
      showInput: true,
      showEffects: true,
      showEvents: true
    }
  ],
  id: "getblock.io"
};

axios.post(url, payload, {
  headers: { "Content-Type": "application/json" }
})
.then(response => {
  console.log("Result:", response.data.result);
})
.catch(error => {
  console.error("Error:", error.response?.status, error.response?.data);
});

get_transaction.py

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"
headers = {"Content-Type": "application/json"}

payload = {
    "jsonrpc": "2.0",
    "method": "sui_getTransactionBlock",
    "params": [
        "5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv",
        {
            "showInput": True,
            "showEffects": True,
            "showEvents": True
        }
    ],
    "id": "getblock.io"
}

response = requests.post(url, headers=headers, data=json.dumps(payload))

if response.status_code == 200:
    print("Result:", response.json().get("result"))
else:
    print("Error:", response.status_code, response.text)

Response

json{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": {
    "digest": "5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv",
    "transaction": {
      "data": {
        "messageVersion": "v1",
        "transaction": {
          "kind": "ProgrammableTransaction",
          "inputs": [],
          "commands": []
        },
        "sender": "0xc8ec1d5b84dd6289e193b9f88de4a994358c9f856135236c3e75a925e1c77ac3",
        "gasData": {
          "payment": [],
          "owner": "0xc8ec1d5b84dd6289e193b9f88de4a994358c9f856135236c3e75a925e1c77ac3",
          "price": "1000",
          "budget": "10000000"
        }
      }
    },
    "effects": {
      "messageVersion": "v1",
      "status": {"status": "success"},
      "executedEpoch": "0",
      "gasUsed": {
        "computationCost": "1000000",
        "storageCost": "2000000",
        "storageRebate": "500000"
      }
    },
    "events": [],
    "objectChanges": [],
    "balanceChanges": [],
    "timestampMs": "1676911928000",
    "checkpoint": "1000"
  }
}

Repsonse Parameters

ParameterTypeDescription
result.digeststringTransaction digest (unique identifier)
result.transactionobjectTransaction input data including sender and gas info
result.effectsobjectExecution results, status, and gas usage
result.eventsarrayEvents emitted during execution
result.objectChangesarrayObjects created, mutated, or deleted
result.balanceChangesarrayBalance changes per affected address
result.timestampMsstringTransaction timestamp in milliseconds
result.checkpointstringCheckpoint sequence number

Use Cases

  1. Transaction Verification: Verify transaction execution status and results, confirming successful completion or diagnosing failures in dApp workflows.
  2. Block Explorer Development: Build block explorer functionality by displaying comprehensive transaction details, including inputs, effects, and state changes.
  3. Event Monitoring: Track smart contract events emitted during transaction execution for real-time monitoring and notifications.

Error Handling

CodeDescriptionSolution
-32700The transaction digest is malformedEnsure the digest is a valid Base58 encoded string
-32602Transaction not foundVerify the digest is correct and the transaction exists
Network SyncNode not fully syncedWait for node synchronization or try another endpoint

SDK Integration

sui-client.ts

typescriptimport { SuiClient } from '@mysten/sui/client';

const client = new SuiClient({ url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' });

const tx = await client.getTransactionBlock({
  digest: '5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv',
  options: {
    showInput: true,
    showEffects: true,
    showEvents: true,
  },
});

console.log(tx);

sui_sdk_example.rs

rustuse sui_sdk::SuiClientBuilder;
use sui_types::digests::TransactionDigest;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let sui = SuiClientBuilder::default()
        .build("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .await?;
    
    let digest: TransactionDigest = "5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv".parse()?;
    let tx = sui.read_api().get_transaction_with_options(digest, None).await?;
    
    println!("{:?}", tx);
    Ok(())
}