GetCoinInfo gRPC Method
Parameters
coinType
string
REQUIRED
Loading...
Returns
coinType
string
Loading...
metadata
object
Loading...
id
string
Loading...
decimals
integer
Loading...
name
string
Loading...
symbol
string
Loading...
description
string
Loading...
iconUrl
string
Loading...
metadataCapId
string
Loading...
treasury
object
Loading...
id
string
Loading...
totalSupply
string
Loading...
supplyState
string
Loading...
regulatedMetadata
object
Loading...
id
string
Loading...
coinMetadataObject
string
Loading...
denyCapObject
string
Loading...
Request
1grpcurl -proto ./sui/rpc/v2beta2/live_data_service.proto -H "x-token: abcde123456789" -d '{2"coin_type": "0x2::sui::SUI"3}' docs-demo.sui-mainnet.quiknode.pro:9000 sui.rpc.v2beta2.LiveDataService/GetCoinInfo4
1grpcurl -proto ./sui/rpc/v2beta2/live_data_service.proto -H "x-token: abcde123456789" -d '{2"coin_type": "0x2::sui::SUI"3}' docs-demo.sui-mainnet.quiknode.pro:9000 sui.rpc.v2beta2.LiveDataService/GetCoinInfo4
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"log"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"13"google.golang.org/protobuf/encoding/protojson"1415pb "sui-grpc/sui/rpc/v2beta2" // Your Generated .pb.go files path16)1718// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token19// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678920// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}21// token will be : abcde1234567892223var (24token = "YOUR_TOKEN_NUMBER"25endpoint = "YOUR_QN_ENDPOINT:9000"26)2728// Auth structure for x-token29type auth struct {30token string31}3233func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {34return map[string]string{"x-token": a.token}, nil35}36func (a *auth) RequireTransportSecurity() bool {37return true38}3940func main() {41creds := credentials.NewTLS(&tls.Config{})42opts := []grpc.DialOption{43grpc.WithTransportCredentials(creds),44grpc.WithPerRPCCredentials(&auth{token}),45}4647conn, err := grpc.Dial(endpoint, opts...)48if err != nil {49log.Fatalf("Failed to connect: %v", err)50}51defer conn.Close()5253client := pb.NewLiveDataServiceClient(conn)5455coinType := "0x2::sui::SUI"5657// Build request with field mask58req := &pb.GetCoinInfoRequest{59CoinType: &coinType,60}6162ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)63defer cancel()6465resp, err := client.GetCoinInfo(ctx, req)66if err != nil {67log.Fatalf("GetCoinInfo failed: %v", err)68}6970// Pretty print the response71marshaler := protojson.MarshalOptions{72UseProtoNames: true,73EmitUnpopulated: true,74Indent: " ",75}7677jsonBytes, err := marshaler.Marshal(resp)78if err != nil {79log.Fatalf("Failed to marshal: %v", err)80}8182var pretty map[string]interface{}83if err := json.Unmarshal(jsonBytes, &pretty); err != nil {84log.Fatalf("Failed to parse JSON: %v", err)85}8687out, _ := json.MarshalIndent(pretty, "", " ")88fmt.Println(string(out))89}90
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"log"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"13"google.golang.org/protobuf/encoding/protojson"1415pb "sui-grpc/sui/rpc/v2beta2" // Your Generated .pb.go files path16)1718// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token19// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678920// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}21// token will be : abcde1234567892223var (24token = "YOUR_TOKEN_NUMBER"25endpoint = "YOUR_QN_ENDPOINT:9000"26)2728// Auth structure for x-token29type auth struct {30token string31}3233func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {34return map[string]string{"x-token": a.token}, nil35}36func (a *auth) RequireTransportSecurity() bool {37return true38}3940func main() {41creds := credentials.NewTLS(&tls.Config{})42opts := []grpc.DialOption{43grpc.WithTransportCredentials(creds),44grpc.WithPerRPCCredentials(&auth{token}),45}4647conn, err := grpc.Dial(endpoint, opts...)48if err != nil {49log.Fatalf("Failed to connect: %v", err)50}51defer conn.Close()5253client := pb.NewLiveDataServiceClient(conn)5455coinType := "0x2::sui::SUI"5657// Build request with field mask58req := &pb.GetCoinInfoRequest{59CoinType: &coinType,60}6162ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)63defer cancel()6465resp, err := client.GetCoinInfo(ctx, req)66if err != nil {67log.Fatalf("GetCoinInfo failed: %v", err)68}6970// Pretty print the response71marshaler := protojson.MarshalOptions{72UseProtoNames: true,73EmitUnpopulated: true,74Indent: " ",75}7677jsonBytes, err := marshaler.Marshal(resp)78if err != nil {79log.Fatalf("Failed to marshal: %v", err)80}8182var pretty map[string]interface{}83if err := json.Unmarshal(jsonBytes, &pretty); err != nil {84log.Fatalf("Failed to parse JSON: %v", err)85}8687out, _ := json.MarshalIndent(pretty, "", " ")88fmt.Println(string(out))89}90
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/v2beta2/live_data_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 LiveDataService = proto.sui.rpc.v2beta2.LiveDataService;2829// Create secure client30const client = new LiveDataService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38coin_type: '0x2::sui::SUI',39};4041// Perform gRPC call42client.GetCoinInfo(request, metadata, (err: grpc.ServiceError | null, response: any) => {43if (err) {44console.error('gRPC Error:', {45code: err.code,46message: err.message,47details: err.details,48});49} else {50console.log('GetCoinInfo Response:');51console.log(JSON.stringify(response, null, 2));52}53});54
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/v2beta2/live_data_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 LiveDataService = proto.sui.rpc.v2beta2.LiveDataService;2829// Create secure client30const client = new LiveDataService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38coin_type: '0x2::sui::SUI',39};4041// Perform gRPC call42client.GetCoinInfo(request, metadata, (err: grpc.ServiceError | null, response: any) => {43if (err) {44console.error('gRPC Error:', {45code: err.code,46message: err.message,47details: err.details,48});49} else {50console.log('GetCoinInfo Response:');51console.log(JSON.stringify(response, null, 2));52}53});54
1import grpc2import json3from google.protobuf.json_format import MessageToDict4from sui.rpc.v2beta2 import live_data_service_pb2, live_data_service_pb2_grpc567def get_coin_info():89# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token10# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678911# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}12# token will be : abcde1234567891314endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';15token = 'abcde123456789';1617channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())18stub = live_data_service_pb2_grpc.LiveDataServiceStub(channel)1920coin_type = "0x2::sui::SUI"2122request = live_data_service_pb2.GetCoinInfoRequest(23coin_type=coin_type24)2526metadata = [("x-token", token)]2728return stub.GetCoinInfo(request, metadata=metadata)293031def parse_response_to_json(response):32return json.dumps(33MessageToDict(response, preserving_proto_field_name=True),34indent=235)363738def main():39try:40response = get_coin_info()41print(parse_response_to_json(response))42except grpc.RpcError as e:43print(f"{e.code().name}: {e.details()}")444546if __name__ == "__main__":47main()48
1import grpc2import json3from google.protobuf.json_format import MessageToDict4from sui.rpc.v2beta2 import live_data_service_pb2, live_data_service_pb2_grpc567def get_coin_info():89# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token10# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678911# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}12# token will be : abcde1234567891314endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';15token = 'abcde123456789';1617channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())18stub = live_data_service_pb2_grpc.LiveDataServiceStub(channel)1920coin_type = "0x2::sui::SUI"2122request = live_data_service_pb2.GetCoinInfoRequest(23coin_type=coin_type24)2526metadata = [("x-token", token)]2728return stub.GetCoinInfo(request, metadata=metadata)293031def parse_response_to_json(response):32return json.dumps(33MessageToDict(response, preserving_proto_field_name=True),34indent=235)363738def main():39try:40response = get_coin_info()41print(parse_response_to_json(response))42except grpc.RpcError as e:43print(f"{e.code().name}: {e.details()}")444546if __name__ == "__main__":47main()48
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free