SubscriptionService/SubscribeCheckpoints - SUI
Example code for the SubscriptionService/SubscribeCheckpoints gRPC method. Complete guide on how to use SubscriptionService/SubscribeCheckpoints gRPC method in GetBlock Web3 documentation.
Request Fields
Field
Type
Required
Description
Request Example
# Clone the official proto files first (one-time setup):
# git clone https://github.com/MystenLabs/sui-apis.git && cd sui-apis
# This is a server-side STREAMING method — grpcurl will keep printing
# responses until you interrupt with Ctrl+C.
grpcurl \
-import-path proto \
-proto sui/rpc/v2/subscription_service.proto \
-H "x-grpc-web: 1" \
-d '{
"read_mask": {
"paths": [
"checkpoint.sequence_number",
"checkpoint.digest",
"checkpoint.summary.timestamp_ms"
]
}
}' \
go.getblock.io:443/<ACCESS-TOKEN> \
sui.rpc.v2.SubscriptionService/SubscribeCheckpointsimport * 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/subscription_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.SubscriptionService;
const metadata = new grpc.Metadata();
metadata.add('authorization', `Bearer ${ACCESS_TOKEN}`);
const client = new ServiceClient('go.getblock.io:443', grpc.credentials.createSsl());
const request = {
"read_mask": {
"paths": [
"checkpoint.sequence_number",
"checkpoint.digest",
"checkpoint.summary.timestamp_ms"
]
}
};
const call = client.SubscribeCheckpoints(request, metadata);
call.on('data', (response: any) => {
console.log('Received:', JSON.stringify(response, null, 2));
});
call.on('end', () => console.log('Stream ended.'));
call.on('error', (err: any) => console.error('Stream error:', err));Response Example
Response Fields
Field
Type
Description
Use Cases
Error Handling
Status Code
Numeric
Cause
SDK Integration
Last updated
Was this helpful?