ListEvents 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
event
object
Loading...
packageId
string
Loading...
module
string
Loading...
sender
string
Loading...
eventType
string
Loading...
json
object
Loading...
checkpoint
string
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": "306133000",7"end_checkpoint": "306133070",8"read_mask": {9"paths": [10"package_id",11"module",12"sender",13"event_type",14"json",15"checkpoint"16]17},18"options": {19"limit": 220}21}' \22docs-demo.sui-mainnet.quiknode.pro:9000 \23sui.rpc.v2.LedgerService/ListEvents24
1grpcurl \2-import-path . \3-proto sui/rpc/v2/ledger_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"start_checkpoint": "306133000",7"end_checkpoint": "306133070",8"read_mask": {9"paths": [10"package_id",11"module",12"sender",13"event_type",14"json",15"checkpoint"16]17},18"options": {19"limit": 220}21}' \22docs-demo.sui-mainnet.quiknode.pro:9000 \23sui.rpc.v2.LedgerService/ListEvents24
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(306133000)58endCheckpoint := uint64(306133070)59limit := uint32(2)6061req := &pb.ListEventsRequest{62StartCheckpoint: &startCheckpoint,63EndCheckpoint: &endCheckpoint,64ReadMask: &fieldmaskpb.FieldMask{65Paths: []string{"package_id", "module", "sender", "event_type", "json", "checkpoint"},66},67Options: &pb.QueryOptions{68Limit: &limit,69},70}7172// ListEvents is bounded by start/end checkpoint and options.limit, so the73// stream terminates on its own once the QueryEnd frame is sent.74ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)75defer cancel()7677stream, err := client.ListEvents(ctx, req)78if err != nil {79log.Fatalf("ListEvents failed: %v", err)80}8182marshaler := protojson.MarshalOptions{83UseProtoNames: true,84EmitUnpopulated: true,85Indent: " ",86}8788fmt.Println("Streaming events...")8990for {91resp, err := stream.Recv()92if err == io.EOF {93fmt.Println("Stream ended")94break95}96if err != nil {97log.Fatalf("Stream error: %v", err)98}99100jsonBytes, err := marshaler.Marshal(resp)101if err != nil {102log.Printf("Failed to marshal: %v", err)103continue104}105106var pretty map[string]interface{}107if err := json.Unmarshal(jsonBytes, &pretty); err != nil {108log.Printf("Failed to parse JSON: %v", err)109continue110}111112out, _ := json.MarshalIndent(pretty, "", " ")113fmt.Printf("Received frame:\n%s\n", string(out))114115if resp.GetEnd() != nil {116fmt.Printf("Query ended: %s\n", resp.GetEnd().GetReason())117}118}119}120
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(306133000)58endCheckpoint := uint64(306133070)59limit := uint32(2)6061req := &pb.ListEventsRequest{62StartCheckpoint: &startCheckpoint,63EndCheckpoint: &endCheckpoint,64ReadMask: &fieldmaskpb.FieldMask{65Paths: []string{"package_id", "module", "sender", "event_type", "json", "checkpoint"},66},67Options: &pb.QueryOptions{68Limit: &limit,69},70}7172// ListEvents is bounded by start/end checkpoint and options.limit, so the73// stream terminates on its own once the QueryEnd frame is sent.74ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)75defer cancel()7677stream, err := client.ListEvents(ctx, req)78if err != nil {79log.Fatalf("ListEvents failed: %v", err)80}8182marshaler := protojson.MarshalOptions{83UseProtoNames: true,84EmitUnpopulated: true,85Indent: " ",86}8788fmt.Println("Streaming events...")8990for {91resp, err := stream.Recv()92if err == io.EOF {93fmt.Println("Stream ended")94break95}96if err != nil {97log.Fatalf("Stream error: %v", err)98}99100jsonBytes, err := marshaler.Marshal(resp)101if err != nil {102log.Printf("Failed to marshal: %v", err)103continue104}105106var pretty map[string]interface{}107if err := json.Unmarshal(jsonBytes, &pretty); err != nil {108log.Printf("Failed to parse JSON: %v", err)109continue110}111112out, _ := json.MarshalIndent(pretty, "", " ")113fmt.Printf("Received frame:\n%s\n", string(out))114115if resp.GetEnd() != nil {116fmt.Printf("Query ended: %s\n", resp.GetEnd().GetReason())117}118}119}120
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// ListEvents 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: '306133000',41end_checkpoint: '306133070',42read_mask: {43paths: ['package_id', 'module', 'sender', 'event_type', 'json', 'checkpoint'],44},45options: {46limit: 2,47},48};4950const call = client.ListEvents(request, metadata);5152console.log('Streaming events...');5354call.on('data', (response: any) => {55console.log('Received frame:', JSON.stringify(response, null, 2));56if (response.end) {57console.log('Query ended:', response.end.reason);58}59});6061call.on('error', (error: any) => {62console.error('Stream error:', error);63});6465call.on('end', () => {66console.log('Stream ended');67});68
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// ListEvents 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: '306133000',41end_checkpoint: '306133070',42read_mask: {43paths: ['package_id', 'module', 'sender', 'event_type', 'json', 'checkpoint'],44},45options: {46limit: 2,47},48};4950const call = client.ListEvents(request, metadata);5152console.log('Streaming events...');5354call.on('data', (response: any) => {55console.log('Received frame:', JSON.stringify(response, null, 2));56if (response.end) {57console.log('Query ended:', response.end.reason);58}59});6061call.on('error', (error: any) => {62console.error('Stream error:', error);63});6465call.on('end', () => {66console.log('Stream ended');67});68
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_events():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=["package_id", "module", "sender", "event_type", "json", "checkpoint"])2021# ListEvents is bounded by start/end_checkpoint and options.limit, so the22# stream ends on its own once the server sends the QueryEnd frame.23request = ledger_service_pb2.ListEventsRequest(24start_checkpoint=306133000,25end_checkpoint=306133070,26read_mask=read_mask,27options=query_options_pb2.QueryOptions(limit=2)28)2930metadata = [("x-token", token)]3132return stub.ListEvents(request, metadata=metadata)3334def parse_response_to_json(response):35return json.dumps(36MessageToDict(response, preserving_proto_field_name=True),37indent=238)3940def main():41print("Streaming events...")4243try:44response_stream = list_events()4546for response in response_stream:47print("Received frame:")48print(parse_response_to_json(response))49if response.HasField("end"):50reason = query_options_pb2.QueryEndReason.Name(response.end.reason)51print(f"Query ended: {reason}")5253print("Stream ended")5455except grpc.RpcError as e:56print(f"{e.code().name}: {e.details()}")5758if __name__ == "__main__":59main()60
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_events():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=["package_id", "module", "sender", "event_type", "json", "checkpoint"])2021# ListEvents is bounded by start/end_checkpoint and options.limit, so the22# stream ends on its own once the server sends the QueryEnd frame.23request = ledger_service_pb2.ListEventsRequest(24start_checkpoint=306133000,25end_checkpoint=306133070,26read_mask=read_mask,27options=query_options_pb2.QueryOptions(limit=2)28)2930metadata = [("x-token", token)]3132return stub.ListEvents(request, metadata=metadata)3334def parse_response_to_json(response):35return json.dumps(36MessageToDict(response, preserving_proto_field_name=True),37indent=238)3940def main():41print("Streaming events...")4243try:44response_stream = list_events()4546for response in response_stream:47print("Received frame:")48print(parse_response_to_json(response))49if response.HasField("end"):50reason = query_options_pb2.QueryEndReason.Name(response.end.reason)51print(f"Query ended: {reason}")5253print("Stream ended")5455except grpc.RpcError as e:56print(f"{e.code().name}: {e.details()}")5758if __name__ == "__main__":59main()60
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free