Parameters
read_mask
object
Optional. Mask for specifying which parts of the SubscribeCheckpointsResponse should be returned
Returns
cursor
string
The checkpoint sequence number and value of the current cursor into the checkpoint stream
checkpoint
object
The requested data for this checkpoint
sequenceNumber
string
The height of this checkpoint
digest
string
The digest of this Checkpoint's CheckpointSummary
summary
object
The CheckpointSummary for this checkpoint
signature
object
An aggregated quorum signature from the validator committee that certified this checkpoint
contents
object
The CheckpointContents for this checkpoint
transactions
array
List of transactions included in this checkpoint
Request
1grpcurl -proto ./sui/rpc/v2/subscription_service.proto -H "x-token: abcde123456789" -d '{2"read_mask": {3"paths": [4"sequence_number",5"digest",6"network_total_transactions",7"previous_digest",8"epoch_rolling_gas_cost_summary",9"timestamp_ms",10"transactions"11]12}13}' docs-demo.sui-mainnet.quiknode.pro:9000 sui.rpc.v2.SubscriptionService/SubscribeCheckpoints14
1grpcurl -proto ./sui/rpc/v2/subscription_service.proto -H "x-token: abcde123456789" -d '{2"read_mask": {3"paths": [4"sequence_number",5"digest",6"network_total_transactions",7"previous_digest",8"epoch_rolling_gas_cost_summary",9"timestamp_ms",10"transactions"11]12}13}' docs-demo.sui-mainnet.quiknode.pro:9000 sui.rpc.v2.SubscriptionService/SubscribeCheckpoints14
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"io"9"log"10"os"11"os/signal"12"syscall"1314"google.golang.org/grpc"15"google.golang.org/grpc/credentials"16"google.golang.org/protobuf/encoding/protojson"17"google.golang.org/protobuf/types/known/fieldmaskpb"1819pb "sui-grpc/sui/rpc/v2" // Your Generated .pb.go files path20)2122// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token23// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678924// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}25// token will be : abcde1234567892627var (28token = "YOUR_TOKEN_NUMBER"29endpoint = "YOUR_QN_ENDPOINT:9000"30)3132// Auth structure for x-token33type auth struct {34token string35}3637func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {38return map[string]string{"x-token": a.token}, nil39}40func (a *auth) RequireTransportSecurity() bool {41return true42}4344func main() {45creds := credentials.NewTLS(&tls.Config{})46opts := []grpc.DialOption{47grpc.WithTransportCredentials(creds),48grpc.WithPerRPCCredentials(&auth{token}),49}5051conn, err := grpc.Dial(endpoint, opts...)52if err != nil {53log.Fatalf("Failed to connect: %v", err)54}55defer conn.Close()5657client := pb.NewSubscriptionServiceClient(conn)5859// Build request with field mask60req := &pb.SubscribeCheckpointsRequest{61ReadMask: &fieldmaskpb.FieldMask{62Paths: []string{63"sequence_number",64"digest",65"network_total_transactions",66"previous_digest",67"epoch_rolling_gas_cost_summary",68"timestamp_ms",69"transactions",70},71},72}7374ctx, cancel := context.WithCancel(context.Background())75defer cancel()7677stream, err := client.SubscribeCheckpoints(ctx, req)78if err != nil {79log.Fatalf("SubscribeCheckpoints failed: %v", err)80}8182sigChan := make(chan os.Signal, 1)83signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)8485go func() {86<-sigChan87fmt.Println("\nClosing subscription...")88cancel()89}()9091fmt.Println("Subscribing to checkpoints... Press Ctrl+C to stop.")9293marshaler := protojson.MarshalOptions{94UseProtoNames: true,95EmitUnpopulated: true,96Indent: " ",97}9899for {100resp, err := stream.Recv()101if err == io.EOF {102fmt.Println("Stream ended")103break104}105if err != nil {106log.Printf("Stream error: %v", err)107break108}109110// Pretty print the response111jsonBytes, err := marshaler.Marshal(resp)112if err != nil {113log.Printf("Failed to marshal: %v", err)114continue115}116117var pretty map[string]interface{}118if err := json.Unmarshal(jsonBytes, &pretty); err != nil {119log.Printf("Failed to parse JSON: %v", err)120continue121}122123out, _ := json.MarshalIndent(pretty, "", " ")124fmt.Printf("Received checkpoint:\n%s\n", string(out))125}126}127
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"io"9"log"10"os"11"os/signal"12"syscall"1314"google.golang.org/grpc"15"google.golang.org/grpc/credentials"16"google.golang.org/protobuf/encoding/protojson"17"google.golang.org/protobuf/types/known/fieldmaskpb"1819pb "sui-grpc/sui/rpc/v2" // Your Generated .pb.go files path20)2122// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token23// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678924// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}25// token will be : abcde1234567892627var (28token = "YOUR_TOKEN_NUMBER"29endpoint = "YOUR_QN_ENDPOINT:9000"30)3132// Auth structure for x-token33type auth struct {34token string35}3637func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {38return map[string]string{"x-token": a.token}, nil39}40func (a *auth) RequireTransportSecurity() bool {41return true42}4344func main() {45creds := credentials.NewTLS(&tls.Config{})46opts := []grpc.DialOption{47grpc.WithTransportCredentials(creds),48grpc.WithPerRPCCredentials(&auth{token}),49}5051conn, err := grpc.Dial(endpoint, opts...)52if err != nil {53log.Fatalf("Failed to connect: %v", err)54}55defer conn.Close()5657client := pb.NewSubscriptionServiceClient(conn)5859// Build request with field mask60req := &pb.SubscribeCheckpointsRequest{61ReadMask: &fieldmaskpb.FieldMask{62Paths: []string{63"sequence_number",64"digest",65"network_total_transactions",66"previous_digest",67"epoch_rolling_gas_cost_summary",68"timestamp_ms",69"transactions",70},71},72}7374ctx, cancel := context.WithCancel(context.Background())75defer cancel()7677stream, err := client.SubscribeCheckpoints(ctx, req)78if err != nil {79log.Fatalf("SubscribeCheckpoints failed: %v", err)80}8182sigChan := make(chan os.Signal, 1)83signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)8485go func() {86<-sigChan87fmt.Println("\nClosing subscription...")88cancel()89}()9091fmt.Println("Subscribing to checkpoints... Press Ctrl+C to stop.")9293marshaler := protojson.MarshalOptions{94UseProtoNames: true,95EmitUnpopulated: true,96Indent: " ",97}9899for {100resp, err := stream.Recv()101if err == io.EOF {102fmt.Println("Stream ended")103break104}105if err != nil {106log.Printf("Stream error: %v", err)107break108}109110// Pretty print the response111jsonBytes, err := marshaler.Marshal(resp)112if err != nil {113log.Printf("Failed to marshal: %v", err)114continue115}116117var pretty map[string]interface{}118if err := json.Unmarshal(jsonBytes, &pretty); err != nil {119log.Printf("Failed to parse JSON: %v", err)120continue121}122123out, _ := json.MarshalIndent(pretty, "", " ")124fmt.Printf("Received checkpoint:\n%s\n", string(out))125}126}127
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/subscription_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 SubscriptionService = proto.sui.rpc.v2.SubscriptionService;2829// Create secure client30const client = new SubscriptionService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38read_mask: {39paths: [40'sequence_number',41'digest',42'network_total_transactions',43'previous_digest',44'epoch_rolling_gas_cost_summary',45'timestamp_ms',46'transactions',47],48},49};5051const call = client.SubscribeCheckpoints(request, metadata);5253call.on('data', (response: any) => {54console.log('Received checkpoint:', JSON.stringify(response, null, 2));55});5657call.on('error', (error: any) => {58console.error('Stream error:', error);59});6061call.on('end', () => {62console.log('Stream ended');63});6465console.log('Subscribing to checkpoints... Press Ctrl+C to stop.');66process.on('SIGINT', () => {67console.log('Closing subscription...');68call.cancel();69process.exit(0);70});71
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/subscription_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 SubscriptionService = proto.sui.rpc.v2.SubscriptionService;2829// Create secure client30const client = new SubscriptionService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38read_mask: {39paths: [40'sequence_number',41'digest',42'network_total_transactions',43'previous_digest',44'epoch_rolling_gas_cost_summary',45'timestamp_ms',46'transactions',47],48},49};5051const call = client.SubscribeCheckpoints(request, metadata);5253call.on('data', (response: any) => {54console.log('Received checkpoint:', JSON.stringify(response, null, 2));55});5657call.on('error', (error: any) => {58console.error('Stream error:', error);59});6061call.on('end', () => {62console.log('Stream ended');63});6465console.log('Subscribing to checkpoints... Press Ctrl+C to stop.');66process.on('SIGINT', () => {67console.log('Closing subscription...');68call.cancel();69process.exit(0);70});71
1import grpc2import json3import signal4import sys5from google.protobuf.field_mask_pb2 import FieldMask6from google.protobuf.json_format import MessageToDict7from sui.rpc.v2 import subscription_service_pb2, subscription_service_pb2_grpc89def signal_handler(sig, frame):10print('\nClosing subscription...')11sys.exit(0)1213def subscribe_checkpoints():14# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token15# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678916# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}17# token will be : abcde1234567891819endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';20token = 'abcde123456789';2122channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())23stub = subscription_service_pb2_grpc.SubscriptionServiceStub(channel)2425read_mask = FieldMask(paths=[26"sequence_number",27"digest",28"network_total_transactions",29"previous_digest",30"epoch_rolling_gas_cost_summary",31"timestamp_ms",32"transactions"33])3435request = subscription_service_pb2.SubscribeCheckpointsRequest(36read_mask=read_mask37)3839metadata = [("x-token", token)]4041return stub.SubscribeCheckpoints(request, metadata=metadata)4243def parse_response_to_json(response):44return json.dumps(45MessageToDict(response, preserving_proto_field_name=True),46indent=247)4849def main():50signal.signal(signal.SIGINT, signal_handler)51print("Subscribing to checkpoints... Press Ctrl+C to stop.")5253try:54response_stream = subscribe_checkpoints()5556for response in response_stream:57print("Received checkpoint:")58print(parse_response_to_json(response))5960except grpc.RpcError as e:61print(f"{e.code().name}: {e.details()}")62except KeyboardInterrupt:63print("\nSubscription interrupted")6465if __name__ == "__main__":66main()67
1import grpc2import json3import signal4import sys5from google.protobuf.field_mask_pb2 import FieldMask6from google.protobuf.json_format import MessageToDict7from sui.rpc.v2 import subscription_service_pb2, subscription_service_pb2_grpc89def signal_handler(sig, frame):10print('\nClosing subscription...')11sys.exit(0)1213def subscribe_checkpoints():14# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token15# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678916# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}17# token will be : abcde1234567891819endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';20token = 'abcde123456789';2122channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())23stub = subscription_service_pb2_grpc.SubscriptionServiceStub(channel)2425read_mask = FieldMask(paths=[26"sequence_number",27"digest",28"network_total_transactions",29"previous_digest",30"epoch_rolling_gas_cost_summary",31"timestamp_ms",32"transactions"33])3435request = subscription_service_pb2.SubscribeCheckpointsRequest(36read_mask=read_mask37)3839metadata = [("x-token", token)]4041return stub.SubscribeCheckpoints(request, metadata=metadata)4243def parse_response_to_json(response):44return json.dumps(45MessageToDict(response, preserving_proto_field_name=True),46indent=247)4849def main():50signal.signal(signal.SIGINT, signal_handler)51print("Subscribing to checkpoints... Press Ctrl+C to stop.")5253try:54response_stream = subscribe_checkpoints()5556for response in response_stream:57print("Received checkpoint:")58print(parse_response_to_json(response))5960except grpc.RpcError as e:61print(f"{e.code().name}: {e.details()}")62except KeyboardInterrupt:63print("\nSubscription interrupted")6465if __name__ == "__main__":66main()67
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free