ListTransactions gRPC Method
Parameters
start_checkpoint
string
Loading...
end_checkpoint
string
Loading...
read_mask
object
Loading...
paths
array<string>
Loading...
filter
object
Loading...
terms
array
Loading...
options
object
Loading...
limit
integer
Loading...
after
string
Loading...
before
string
Loading...
ordering
string
Loading...
Returns
transaction
object
Loading...
digest
string
Loading...
transaction
object
Loading...
effects
object
Loading...
watermark
object
Loading...
cursor
string
Loading...
checkpoint
string
Loading...
end
object
Loading...
reason
string
Loading...
Request
1grpcurl \2-import-path . \3-proto sui/rpc/v2/ledger_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"start_checkpoint": "306133070",7"read_mask": {8"paths": [9"digest",10"transaction"11]12},13"options": {14"limit": 215}16}' \17docs-demo.sui-mainnet.quiknode.pro:9000 \18sui.rpc.v2.LedgerService/ListTransactions19
1grpcurl \2-import-path . \3-proto sui/rpc/v2/ledger_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"start_checkpoint": "306133070",7"read_mask": {8"paths": [9"digest",10"transaction"11]12},13"options": {14"limit": 215}16}' \17docs-demo.sui-mainnet.quiknode.pro:9000 \18sui.rpc.v2.LedgerService/ListTransactions19
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"io"9"log"10"time"1112"google.golang.org/grpc"13"google.golang.org/grpc/credentials"14"google.golang.org/protobuf/encoding/protojson"15"google.golang.org/protobuf/types/known/fieldmaskpb"1617pb "sui-grpc/sui/rpc/v2" // Your Generated .pb.go files path18)1920// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token21// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678922// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}23// token will be : abcde1234567892425var (26token = "YOUR_TOKEN_NUMBER"27endpoint = "YOUR_QN_ENDPOINT:9000"28)2930// Auth structure for x-token31type auth struct {32token string33}3435func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {36return map[string]string{"x-token": a.token}, nil37}38func (a *auth) RequireTransportSecurity() bool {39return true40}4142func main() {43creds := credentials.NewTLS(&tls.Config{})44opts := []grpc.DialOption{45grpc.WithTransportCredentials(creds),46grpc.WithPerRPCCredentials(&auth{token}),47}4849conn, err := grpc.Dial(endpoint, opts...)50if err != nil {51log.Fatalf("Failed to connect: %v", err)52}53defer conn.Close()5455client := pb.NewLedgerServiceClient(conn)5657startCheckpoint := uint64(306133070)58limit := uint32(2)5960req := &pb.ListTransactionsRequest{61StartCheckpoint: &startCheckpoint,62ReadMask: &fieldmaskpb.FieldMask{63Paths: []string{"digest", "transaction"},64},65Options: &pb.QueryOptions{66Limit: &limit,67},68}6970// ListTransactions is bounded by start/end checkpoint and options.limit, so the71// stream terminates on its own once the QueryEnd frame is sent.72ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)73defer cancel()7475stream, err := client.ListTransactions(ctx, req)76if err != nil {77log.Fatalf("ListTransactions failed: %v", err)78}7980marshaler := protojson.MarshalOptions{81UseProtoNames: true,82EmitUnpopulated: true,83Indent: " ",84}8586fmt.Println("Streaming transactions...")8788for {89resp, err := stream.Recv()90if err == io.EOF {91fmt.Println("Stream ended")92break93}94if err != nil {95log.Fatalf("Stream error: %v", err)96}9798jsonBytes, err := marshaler.Marshal(resp)99if err != nil {100log.Printf("Failed to marshal: %v", err)101continue102}103104var pretty map[string]interface{}105if err := json.Unmarshal(jsonBytes, &pretty); err != nil {106log.Printf("Failed to parse JSON: %v", err)107continue108}109110out, _ := json.MarshalIndent(pretty, "", " ")111fmt.Printf("Received frame:\n%s\n", string(out))112113if resp.GetEnd() != nil {114fmt.Printf("Query ended: %s\n", resp.GetEnd().GetReason())115}116}117}118
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"io"9"log"10"time"1112"google.golang.org/grpc"13"google.golang.org/grpc/credentials"14"google.golang.org/protobuf/encoding/protojson"15"google.golang.org/protobuf/types/known/fieldmaskpb"1617pb "sui-grpc/sui/rpc/v2" // Your Generated .pb.go files path18)1920// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token21// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678922// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}23// token will be : abcde1234567892425var (26token = "YOUR_TOKEN_NUMBER"27endpoint = "YOUR_QN_ENDPOINT:9000"28)2930// Auth structure for x-token31type auth struct {32token string33}3435func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {36return map[string]string{"x-token": a.token}, nil37}38func (a *auth) RequireTransportSecurity() bool {39return true40}4142func main() {43creds := credentials.NewTLS(&tls.Config{})44opts := []grpc.DialOption{45grpc.WithTransportCredentials(creds),46grpc.WithPerRPCCredentials(&auth{token}),47}4849conn, err := grpc.Dial(endpoint, opts...)50if err != nil {51log.Fatalf("Failed to connect: %v", err)52}53defer conn.Close()5455client := pb.NewLedgerServiceClient(conn)5657startCheckpoint := uint64(306133070)58limit := uint32(2)5960req := &pb.ListTransactionsRequest{61StartCheckpoint: &startCheckpoint,62ReadMask: &fieldmaskpb.FieldMask{63Paths: []string{"digest", "transaction"},64},65Options: &pb.QueryOptions{66Limit: &limit,67},68}6970// ListTransactions is bounded by start/end checkpoint and options.limit, so the71// stream terminates on its own once the QueryEnd frame is sent.72ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)73defer cancel()7475stream, err := client.ListTransactions(ctx, req)76if err != nil {77log.Fatalf("ListTransactions failed: %v", err)78}7980marshaler := protojson.MarshalOptions{81UseProtoNames: true,82EmitUnpopulated: true,83Indent: " ",84}8586fmt.Println("Streaming transactions...")8788for {89resp, err := stream.Recv()90if err == io.EOF {91fmt.Println("Stream ended")92break93}94if err != nil {95log.Fatalf("Stream error: %v", err)96}9798jsonBytes, err := marshaler.Marshal(resp)99if err != nil {100log.Printf("Failed to marshal: %v", err)101continue102}103104var pretty map[string]interface{}105if err := json.Unmarshal(jsonBytes, &pretty); err != nil {106log.Printf("Failed to parse JSON: %v", err)107continue108}109110out, _ := json.MarshalIndent(pretty, "", " ")111fmt.Printf("Received frame:\n%s\n", string(out))112113if resp.GetEnd() != nil {114fmt.Printf("Query ended: %s\n", resp.GetEnd().GetReason())115}116}117}118
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';45// Configuration6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/ledger_service.proto');78// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11// token will be : abcde1234567891213const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';14const token = 'abcde123456789';1516// Load protobuf definitions17const packageDefinition = protoLoader.loadSync(PROTO_PATH, {18keepCase: true,19longs: String,20enums: String,21defaults: true,22oneofs: true,23includeDirs: [path.join(__dirname, 'protos/proto')],24});2526const proto = grpc.loadPackageDefinition(packageDefinition) as any;27const LedgerService = proto.sui.rpc.v2.LedgerService;2829// Create secure client30const client = new LedgerService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37// ListTransactions is bounded by start/end_checkpoint and options.limit, so the38// stream ends on its own — no Ctrl+C handling needed.39const request = {40start_checkpoint: '306133070',41read_mask: {42paths: ['digest', 'transaction'],43},44options: {45limit: 2,46},47};4849const call = client.ListTransactions(request, metadata);5051console.log('Streaming transactions...');5253call.on('data', (response: any) => {54console.log('Received frame:', JSON.stringify(response, null, 2));55if (response.end) {56console.log('Query ended:', response.end.reason);57}58});5960call.on('error', (error: any) => {61console.error('Stream error:', error);62});6364call.on('end', () => {65console.log('Stream ended');66});67
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';45// Configuration6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/ledger_service.proto');78// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11// token will be : abcde1234567891213const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';14const token = 'abcde123456789';1516// Load protobuf definitions17const packageDefinition = protoLoader.loadSync(PROTO_PATH, {18keepCase: true,19longs: String,20enums: String,21defaults: true,22oneofs: true,23includeDirs: [path.join(__dirname, 'protos/proto')],24});2526const proto = grpc.loadPackageDefinition(packageDefinition) as any;27const LedgerService = proto.sui.rpc.v2.LedgerService;2829// Create secure client30const client = new LedgerService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37// ListTransactions is bounded by start/end_checkpoint and options.limit, so the38// stream ends on its own — no Ctrl+C handling needed.39const request = {40start_checkpoint: '306133070',41read_mask: {42paths: ['digest', 'transaction'],43},44options: {45limit: 2,46},47};4849const call = client.ListTransactions(request, metadata);5051console.log('Streaming transactions...');5253call.on('data', (response: any) => {54console.log('Received frame:', JSON.stringify(response, null, 2));55if (response.end) {56console.log('Query ended:', response.end.reason);57}58});5960call.on('error', (error: any) => {61console.error('Stream error:', error);62});6364call.on('end', () => {65console.log('Stream ended');66});67
1import grpc2import json3from google.protobuf.field_mask_pb2 import FieldMask4from google.protobuf.json_format import MessageToDict5from sui.rpc.v2 import ledger_service_pb2, ledger_service_pb2_grpc, query_options_pb267def list_transactions():8# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11# token will be : abcde1234567891213endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';14token = 'abcde123456789';1516channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())17stub = ledger_service_pb2_grpc.LedgerServiceStub(channel)1819read_mask = FieldMask(paths=["digest", "transaction"])2021# ListTransactions is bounded by start/end_checkpoint and options.limit, so22# the stream ends on its own once the server sends the QueryEnd frame.23request = ledger_service_pb2.ListTransactionsRequest(24start_checkpoint=306133070,25read_mask=read_mask,26options=query_options_pb2.QueryOptions(limit=2)27)2829metadata = [("x-token", token)]3031return stub.ListTransactions(request, metadata=metadata)3233def parse_response_to_json(response):34return json.dumps(35MessageToDict(response, preserving_proto_field_name=True),36indent=237)3839def main():40print("Streaming transactions...")4142try:43response_stream = list_transactions()4445for response in response_stream:46print("Received frame:")47print(parse_response_to_json(response))48if response.HasField("end"):49reason = query_options_pb2.QueryEndReason.Name(response.end.reason)50print(f"Query ended: {reason}")5152print("Stream ended")5354except grpc.RpcError as e:55print(f"{e.code().name}: {e.details()}")5657if __name__ == "__main__":58main()59
1import grpc2import json3from google.protobuf.field_mask_pb2 import FieldMask4from google.protobuf.json_format import MessageToDict5from sui.rpc.v2 import ledger_service_pb2, ledger_service_pb2_grpc, query_options_pb267def list_transactions():8# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11# token will be : abcde1234567891213endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';14token = 'abcde123456789';1516channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())17stub = ledger_service_pb2_grpc.LedgerServiceStub(channel)1819read_mask = FieldMask(paths=["digest", "transaction"])2021# ListTransactions is bounded by start/end_checkpoint and options.limit, so22# the stream ends on its own once the server sends the QueryEnd frame.23request = ledger_service_pb2.ListTransactionsRequest(24start_checkpoint=306133070,25read_mask=read_mask,26options=query_options_pb2.QueryOptions(limit=2)27)2829metadata = [("x-token", token)]3031return stub.ListTransactions(request, metadata=metadata)3233def parse_response_to_json(response):34return json.dumps(35MessageToDict(response, preserving_proto_field_name=True),36indent=237)3839def main():40print("Streaming transactions...")4142try:43response_stream = list_transactions()4445for response in response_stream:46print("Received frame:")47print(parse_response_to_json(response))48if response.HasField("end"):49reason = query_options_pb2.QueryEndReason.Name(response.end.reason)50print(f"Query ended: {reason}")5152print("Stream ended")5354except grpc.RpcError as e:55print(f"{e.code().name}: {e.details()}")5657if __name__ == "__main__":58main()59
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free