GetServiceInfo gRPC Method
Parameters
This method does not accept any parameters
Returns
chainId
string
Loading...
chain
string
Loading...
epoch
string
Loading...
checkpointHeight
string
Loading...
timestamp
string
Loading...
lowestAvailableCheckpoint
string
Loading...
lowestAvailableCheckpointObjects
string
Loading...
server
string
Loading...
Request
grpcurl \ -import-path . \ -proto sui/rpc/v2beta2/ledger_service.proto \ -H "x-token: YOUR_TOKEN_VALUE" \ -d '{}' \ docs-demo.sui-mainnet.quiknode.pro:9000 \ sui.rpc.v2beta2.LedgerService/GetServiceInfo
package main import ( "context" "crypto/tls" "encoding/json" "fmt" "log" "time" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/metadata" "google.golang.org/protobuf/encoding/protojson" pb "sui-grpc/sui/rpc/v2beta2" // Your Generated .pb.go files path ) // QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token // For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde123456789 // endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC} // token will be : abcde123456789 var ( token = "YOUR_TOKEN_NUMBER" endpoint = "YOUR_QN_ENDPOINT:9000" ) func main() { creds := credentials.NewTLS(&tls.Config{}) conn, err := grpc.Dial(endpoint, grpc.WithTransportCredentials(creds)) if err != nil { log.Fatalf("Failed to connect: %v", err) } defer conn.Close() client := pb.NewLedgerServiceClient(conn) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() ctx = metadata.AppendToOutgoingContext(ctx, "x-token", token) req := &pb.GetServiceInfoRequest{} resp, err := client.GetServiceInfo(ctx, req) if err != nil { log.Fatalf("GetServiceInfo failed: %v", err) } marshaler := protojson.MarshalOptions{ UseProtoNames: true, EmitUnpopulated: true, Indent: " ", } jsonBytes, err := marshaler.Marshal(resp) if err != nil { log.Fatalf("Failed to marshal response to JSON: %v", err) } var prettyJSON map[string]interface{} if err := json.Unmarshal(jsonBytes, &prettyJSON); err != nil { log.Fatalf("Failed to unmarshal JSON: %v", err) } prettyJSONBytes, err := json.MarshalIndent(prettyJSON, "", " ") if err != nil { log.Fatalf("Failed to format JSON: %v", err) } fmt.Println(string(prettyJSONBytes)) }
import * as grpc from '@grpc/grpc-js'; import * as protoLoader from '@grpc/proto-loader'; import * as path from 'path'; // Path to proto file const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2beta2/ledger_service.proto'); // Load proto definitions const packageDefinition = protoLoader.loadSync(PROTO_PATH, { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true, includeDirs: [path.join(__dirname, 'protos/proto')], }); const proto = grpc.loadPackageDefinition(packageDefinition) as any; const LedgerService = proto.sui.rpc.v2beta2.LedgerService; // QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token // For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde123456789 // endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC} // token will be : abcde123456789 const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000'; const token = 'abcde123456789'; // Create gRPC client with TLS const client = new LedgerService(endpoint, grpc.credentials.createSsl()); // Metadata with token const metadata = new grpc.Metadata(); metadata.add('x-token', token); // Empty request for GetServiceInfo const request = {}; // Make the gRPC call client.GetServiceInfo({}, metadata, (err: grpc.ServiceError | null, response: any) => { if (err) { console.error('gRPC Error:', { code: err.code, message: err.message, details: err.details, }); return; } console.log('Service Info:'); console.log(JSON.stringify(response, null, 2)); });
import grpc import json from google.protobuf.field_mask_pb2 import FieldMask from google.protobuf.json_format import MessageToDict from sui.rpc.v2beta2 import ledger_service_pb2, ledger_service_pb2_grpc def get_service_info(): # QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token # For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde123456789 # endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC} # token will be: abcde123456789 endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000'; token = 'abcde123456789'; channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials()) stub = ledger_service_pb2_grpc.LedgerServiceStub(channel) # GetServiceInfo doesn't require any specific parameters request = ledger_service_pb2.GetServiceInfoRequest() metadata = [("x-token", token)] return stub.GetServiceInfo(request, metadata=metadata) def parse_response_to_json(response): return json.dumps( MessageToDict(response, preserving_proto_field_name=True), indent=2 ) def main(): try: response = get_service_info() print(parse_response_to_json(response)) except grpc.RpcError as e: print(f"{e.code().name}: {e.details()}") if __name__ == "__main__": main()
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free