GetCoinInfo gRPC Method
パラメータ
coin_type
文字列
必須
読み込み中...
返します
coinType
文字列
読み込み中...
メタデータ
オブジェクト
読み込み中...
id
文字列
読み込み中...
decimals
整数
読み込み中...
名前
文字列
読み込み中...
symbol
文字列
読み込み中...
説明
文字列
読み込み中...
iconUrl
文字列
読み込み中...
metadataCapId
文字列
読み込み中...
treasury
オブジェクト
読み込み中...
id
文字列
読み込み中...
totalSupply
文字列
読み込み中...
supplyState
文字列
読み込み中...
regulatedMetadata
オブジェクト
読み込み中...
id
文字列
読み込み中...
coinMetadataObject
文字列
読み込み中...
denyCapObject
文字列
読み込み中...
リクエスト
1grpcurl -proto ./sui/rpc/v2/state_service.proto -H "x-token: abcde123456789" -d '{2"coin_type": "0x2::sui::SUI"3}' docs-demo.sui-mainnet.quiknode.pro:9000 sui.rpc.v2.StateService/GetCoinInfo4
1grpcurl -proto ./sui/rpc/v2/state_service.proto -H "x-token: abcde123456789" -d '{2"coin_type": "0x2::sui::SUI"3}' docs-demo.sui-mainnet.quiknode.pro:9000 sui.rpc.v2.StateService/GetCoinInfo4
1パッケージ main23インポート (4「文脈」5"crypto/tls"6"encoding/json"7"fmt"8「ログ」9「時間」1011"google.golang.grpc"12"google.golang.grpc"13"google.golang.org/protobuf/encoding/protojson"1415pb "sui-grpc/sui/rpc/v2" // 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-token29タイプ auth 構造体 {30トークン 文字列31}3233func (a *auth) GetRequestMetadata(ctx コンテキスト.Context, uri ...文字列) (map[文字列]文字列, エラー) {34return map[string]string{"x-token": a.token}, nil35}36func (a *auth) RequireTransportSecurity(auth) 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...)48もし err != nil {49log.Fatalf("Failed to connect: %v", err)50}51延期 conn.閉じる()5253client := pb.NewStateServiceClient(conn)5455coinType := "0x2::sui::SUI"5657// Build request with field mask58req := &pb.GetCoinInfoRequest{59CoinType: &coinType,60}6162ctx, cancel := context.WithTimeout)(コンテキスト.Background(), 10*時間.2番目)63延期 延期()6465resp, err := client.GetCoinInfo(ctx, req)66もし 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)78もし 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
1パッケージ main23インポート (4「文脈」5"crypto/tls"6"encoding/json"7"fmt"8「ログ」9「時間」1011"google.golang.grpc"12"google.golang.grpc"13"google.golang.org/protobuf/encoding/protojson"1415pb "sui-grpc/sui/rpc/v2" // 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-token29タイプ auth 構造体 {30トークン 文字列31}3233func (a *auth) GetRequestMetadata(ctx コンテキスト.Context, uri ...文字列) (map[文字列]文字列, エラー) {34return map[string]string{"x-token": a.token}, nil35}36func (a *auth) RequireTransportSecurity(auth) 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...)48もし err != nil {49log.Fatalf("Failed to connect: %v", err)50}51延期 conn.閉じる()5253client := pb.NewStateServiceClient(conn)5455coinType := "0x2::sui::SUI"5657// Build request with field mask58req := &pb.GetCoinInfoRequest{59CoinType: &coinType,60}6162ctx, cancel := context.WithTimeout)(コンテキスト.Background(), 10*時間.2番目)63延期 延期()6465resp, err := client.GetCoinInfo(ctx, req)66もし 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)78もし 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/v2/state_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 StateService = proto.sui.rpc.v2.StateService;2829// Create secure client30const client = new StateService(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/v2/state_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 StateService = proto.sui.rpc.v2.StateService;2829// Create secure client30const client = new StateService(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.v2 import state_service_pb2, state_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 = state_service_pb2_grpc.StateServiceStub(channel)1920coin_type = "0x2::sui::SUI"2122request = state_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.v2 import state_service_pb2, state_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 = state_service_pb2_grpc.StateServiceStub(channel)1920coin_type = "0x2::sui::SUI"2122request = state_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