For the complete documentation index, see llms.txt. This page is also available as Markdown.

LedgerService/GetTransaction - SUI

Example code for the LedgerService/GetTransaction gRPC method. Complete guide on how to use LedgerService/GetTransaction gRPC method in GetBlock Web3 documentation.

Returns a transaction by its digest, including the full effects, events emitted, and inputs/outputs. The optional read_mask lets you fetch just the parts you need — for example, requesting only effects.status is significantly cheaper than fetching the full transaction body.

Service: sui.rpc.v2.LedgerService Proto file: sui/rpc/v2/ledger_service.proto Full method path: sui.rpc.v2.LedgerService/GetTransaction

Request Fields

Field
Type
Required
Description

digest

string

Yes

Transaction digest (Base58)

read_mask

FieldMask

No

Field paths — e.g. ["digest", "effects", "events"]. Use ["*"] for all fields

Request Example

# Clone the official proto files first (one-time setup):
#   git clone https://github.com/MystenLabs/sui-apis.git && cd sui-apis

grpcurl \
  -import-path proto \
  -proto sui/rpc/v2/ledger_service.proto \
  -H "x-grpc-web: 1" \
  -d '{
    "digest": "8WmKqcRkV5JZw8gEjGyzVxRYHnDvKmJsxLBp7t6vNqrA",
    "read_mask": {
        "paths": [
            "*"
        ]
    }
}' \
  go.getblock.io:443/<ACCESS-TOKEN> \
  sui.rpc.v2.LedgerService/GetTransaction
import * as grpc from '@grpc/grpc-js';
import * as protoLoader from '@grpc/proto-loader';
import * as path from 'path';

const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/ledger_service.proto');
const ACCESS_TOKEN = '<ACCESS-TOKEN>';

const packageDef = protoLoader.loadSync(PROTO_PATH, {
    includeDirs: [path.join(__dirname, 'protos/proto')],
    keepCase: true, longs: String, enums: String, defaults: true,
});
const proto = grpc.loadPackageDefinition(packageDef) as any;
const ServiceClient = proto.sui.rpc.v2.LedgerService;

const metadata = new grpc.Metadata();
metadata.add('authorization', `Bearer ${ACCESS_TOKEN}`);

const client = new ServiceClient('go.getblock.io:443', grpc.credentials.createSsl());

const request = {
    "digest": "8WmKqcRkV5JZw8gEjGyzVxRYHnDvKmJsxLBp7t6vNqrA",
    "read_mask": {
        "paths": [
            "*"
        ]
    }
};

client.GetTransaction(request, metadata, (err: any, response: any) => {
    if (err) {
        console.error('Error:', err);
        return;
    }
    console.log(JSON.stringify(response, null, 2));
});

Response Example

Responses are encoded in Protocol Buffers binary format on the wire. The example below shows the protobuf JSON encoding for readability.

Response Fields

Field
Type
Description

transaction.digest

string

Transaction digest (echoed)

transaction.transaction.data

TransactionData

The transaction body — sender, gas, kind

transaction.effects.status

ExecutionStatus

success: true or error with details

transaction.effects.gas_used

GasCostSummary

Computation cost, storage cost, and storage rebate (all in MIST)

transaction.effects.mutated

repeated ObjectRef

Objects modified by this transaction

transaction.events

repeated Event

Move-level events emitted by the transaction

transaction.checkpoint

string

Checkpoint sequence number containing this transaction

transaction.timestamp_ms

string

Block timestamp in milliseconds

Use Cases

  • Confirming a submitted transaction succeeded after broadcast

  • Reading emitted events for indexers

  • Computing actual gas cost for accounting

  • Building transaction detail views in explorers

Error Handling

gRPC uses status codes rather than JSON-RPC numeric error codes. The most relevant for this method:

Status Code
Numeric
Cause

UNAUTHENTICATED

16

Missing or invalid <ACCESS-TOKEN> in the URL path

INVALID_ARGUMENT

3

Request fields are missing, malformed, or fail validation

UNAVAILABLE

14

Node is overloaded or temporarily unable to handle the request — retry with backoff

DEADLINE_EXCEEDED

4

Request did not complete within the timeout window

RESOURCE_EXHAUSTED

8

Rate limit exceeded for your plan

NOT_FOUND

5

No transaction exists at the requested digest, or it has been pruned from this node

SDK Integration

Was this helpful?