GetFunction gRPC Method
Parámetros
package_id
cadena
OBLIGATORIO
Cargando...
module_name
cadena
OBLIGATORIO
Cargando...
nombre
cadena
OBLIGATORIO
Cargando...
Devoluciones
función
objeto
Cargando...
nombre
cadena
Cargando...
visibility
cadena
Cargando...
isEntry
booleano
Cargando...
typeParameters
matriz
Cargando...
parameters
matriz
Cargando...
reference
cadena
Cargando...
body
objeto
Cargando...
tipo
cadena
Cargando...
typeName
cadena
Cargando...
typeParameterInstantiation
matriz
Cargando...
tipo
cadena
Cargando...
typeParameter
entero
Cargando...
returns
matriz
Cargando...
body
objeto
Cargando...
tipo
cadena
Cargando...
typeName
cadena
Cargando...
typeParameterInstantiation
matriz
Cargando...
tipo
cadena
Cargando...
typeParameter
entero
Cargando...
Solicitud
1grpcurl \2-import-path . \3-proto sui/rpc/v2/move_package_service.proto \4-H "x-token: abcde123456789" \5-d '{6"package_id": "0x2",7"module_name": "coin",8"name": "mint"9}' \10docs-demo.sui-mainnet.quiknode.pro:9000 \11sui.rpc.v2.MovePackageService/GetFunction12
1grpcurl \2-import-path . \3-proto sui/rpc/v2/move_package_service.proto \4-H "x-token: abcde123456789" \5-d '{6"package_id": "0x2",7"module_name": "coin",8"name": "mint"9}' \10docs-demo.sui-mainnet.quiknode.pro:9000 \11sui.rpc.v2.MovePackageService/GetFunction12
1paquete principal23import (4«contexto»5«crypto/tls»6«encoding/json»7«fmt»8«registro»9«tiempo»1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"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 = "TU_NÚMERO_DE_TOKEN"25endpoint = "YOUR_QN_ENDPOINT:9000"26)2728// Auth structure for x-token29tipo autenticación estructura {30token cadena31}3233func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, 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.Con credenciales RPCC(&auth{token}),45}4647conn, err := grpc.Dial(endpoint, opts...)48si err != nil {49registro.Fatalf(«Error al conectarse: %v», err)50}51aplazar conn.Cerrar()5253client := pb.NewMovePackageServiceClient(conn)5455packageID := "0x2"56moduleName := "coin"57functionName := "mint"5859req := &pb.GetFunctionRequest{60PackageId: &packageID,61ModuleName: &moduleName,62Name: &functionName,63}6465ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)66defer cancel()6768resp, err := client.GetFunction(ctx, req)69si err != nil {70log.Fatalf("GetFunction failed: %v", err)71}7273marshaler := protojson.MarshalOptions{74UseProtoNames: true,75EmitUnpopulated: true,76Indent: " ",77}7879jsonBytes, err := marshaler.Marshal(resp)80si err != nil {81log.Fatalf("Failed to marshal: %v", err)82}8384var pretty map[string]interface{}85if err := json.Unmarshal(jsonBytes, &pretty); err != nil {86log.Fatalf("Failed to parse JSON: %v", err)87}8889out, _ := json.MarshalIndent(pretty, "", " ")90fmt.Println(string(out))91}92
1paquete principal23import (4«contexto»5«crypto/tls»6«encoding/json»7«fmt»8«registro»9«tiempo»1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"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 = "TU_NÚMERO_DE_TOKEN"25endpoint = "YOUR_QN_ENDPOINT:9000"26)2728// Auth structure for x-token29tipo autenticación estructura {30token cadena31}3233func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, 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.Con credenciales RPCC(&auth{token}),45}4647conn, err := grpc.Dial(endpoint, opts...)48si err != nil {49registro.Fatalf(«Error al conectarse: %v», err)50}51aplazar conn.Cerrar()5253client := pb.NewMovePackageServiceClient(conn)5455packageID := "0x2"56moduleName := "coin"57functionName := "mint"5859req := &pb.GetFunctionRequest{60PackageId: &packageID,61ModuleName: &moduleName,62Name: &functionName,63}6465ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)66defer cancel()6768resp, err := client.GetFunction(ctx, req)69si err != nil {70log.Fatalf("GetFunction failed: %v", err)71}7273marshaler := protojson.MarshalOptions{74UseProtoNames: true,75EmitUnpopulated: true,76Indent: " ",77}7879jsonBytes, err := marshaler.Marshal(resp)80si err != nil {81log.Fatalf("Failed to marshal: %v", err)82}8384var pretty map[string]interface{}85if err := json.Unmarshal(jsonBytes, &pretty); err != nil {86log.Fatalf("Failed to parse JSON: %v", err)87}8889out, _ := json.MarshalIndent(pretty, "", " ")90fmt.Println(string(out))91}92
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/move_package_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 MovePackageService = proto.sui.rpc.v2.MovePackageService;2829// Create secure client30const client = new MovePackageService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38package_id: '0x2',39module_name: 'coin',40name: 'mint',41};4243// Perform gRPC call44client.GetFunction(request, metadata, (err: grpc.ServiceError | null, response: any) => {45if (err) {46console.error('gRPC Error:', {47code: err.code,48message: err.message,49details: err.details,50});51} else {52console.log('GetFunction Response:');53console.log(JSON.stringify(response, null, 2));54}55});56
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/move_package_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 MovePackageService = proto.sui.rpc.v2.MovePackageService;2829// Create secure client30const client = new MovePackageService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38package_id: '0x2',39module_name: 'coin',40name: 'mint',41};4243// Perform gRPC call44client.GetFunction(request, metadata, (err: grpc.ServiceError | null, response: any) => {45if (err) {46console.error('gRPC Error:', {47code: err.code,48message: err.message,49details: err.details,50});51} else {52console.log('GetFunction Response:');53console.log(JSON.stringify(response, null, 2));54}55});56
1import grpc2import json3from google.protobuf.json_format import MessageToDict4from sui.rpc.v2 import move_package_service_pb2, move_package_service_pb2_grpc567def get_function():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 = move_package_service_pb2_grpc.MovePackageServiceStub(channel)1920package_id = "0x2"21module_name = "coin"22name = "mint"2324request = move_package_service_pb2.GetFunctionRequest(25package_id=package_id,26module_name=module_name,27name=name28)2930metadata = [("x-token", token)]3132return stub.GetFunction(request, metadata=metadata)333435def parse_response_to_json(response):36return json.dumps(37MessageToDict(response, preserving_proto_field_name=True),38indent=239)404142def main():43try:44response = get_function()45print(parse_response_to_json(response))46except grpc.RpcError as e:47print(f"{e.code().name}: {e.details()}")4849if __name__ == "__main__":50main()51
1import grpc2import json3from google.protobuf.json_format import MessageToDict4from sui.rpc.v2 import move_package_service_pb2, move_package_service_pb2_grpc567def get_function():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 = move_package_service_pb2_grpc.MovePackageServiceStub(channel)1920package_id = "0x2"21module_name = "coin"22name = "mint"2324request = move_package_service_pb2.GetFunctionRequest(25package_id=package_id,26module_name=module_name,27name=name28)2930metadata = [("x-token", token)]3132return stub.GetFunction(request, metadata=metadata)333435def parse_response_to_json(response):36return json.dumps(37MessageToDict(response, preserving_proto_field_name=True),38indent=239)404142def main():43try:44response = get_function()45print(parse_response_to_json(response))46except grpc.RpcError as e:47print(f"{e.code().name}: {e.details()}")4849if __name__ == "__main__":50main()51
¿Aún no tienes una cuenta?
Crea tu punto de conexión de Quicknode en cuestión de segundos y empieza a desarrollar
Empieza gratis