ParseTRC20NumericProperty gRPC Method
Paramètres
données
chaîne de caractères
OBLIGATOIRE
Chargement en cours...
Retours
valeur
chaîne de caractères
Chargement en cours...
erreur
objet
Chargement en cours...
Demande
1paquet principal23import (4« contexte »5« crypto/tls »6« fmt »7"encoding/hex"89« github.sdk »10« google.golang.grpc »11« google.golang.grpc »12)131415// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token16// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678917// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}18// token will be : abcde1234567891920var jeton = "VOTRE_TOKEN"21var endpoint = "VOTRE_POINT_DE_FIN :50051"222324type auth struct {25jeton chaîne de caractères26}2728func (a *auth) GetRequestMetadata(ctx contexte.Context, uri ...chaîne) (carte[chaîne]chaîne, erreur) {29retour carte[chaîne]chaîne{30« x-token »: un.jeton,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35retour false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(informations d'authentification.NewTLS(&tls.Config{})),41grpc.Avec les identifiants RPCC(&auth{token}),42}43conn := client.NewGrpcClient(endpoint)44if err := conn.Start(opts...); err != nil {45panique(erreur)46}47reporter conn.Conn.Fermer()4849ownerAddress := "THPvaUhoh2Qn2y9THCZML3H815hhFhn5YC"50contractAddress := "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"51method := "totalSupply()"52jsonParams := ""5354response, err := conn.TriggerConstantContract(55ownerAddress,56contractAddress,57method,58jsonParams,59)60si err != nil {61fmt.Printf("Error calling TriggerConstantContract: %v\n", err)62retour63}6465if len(response.ConstantResult) == 0 {66fmt.Println("No result returned from contract call")67retour68}6970hexData := hex.EncodeToString(response.ConstantResult[0])7172numericValue, err := conn.ParseTRC20NumericProperty(hexData)73si err != nil {74fmt.Printf("Error parsing numeric property: %v\n", err)75retour76}7778fmt.Printf("Parsed numeric value: %s\n", numericValue.String())7980}
1paquet principal23import (4« contexte »5« crypto/tls »6« fmt »7"encoding/hex"89« github.sdk »10« google.golang.grpc »11« google.golang.grpc »12)131415// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token16// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678917// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}18// token will be : abcde1234567891920var jeton = "VOTRE_TOKEN"21var endpoint = "VOTRE_POINT_DE_FIN :50051"222324type auth struct {25jeton chaîne de caractères26}2728func (a *auth) GetRequestMetadata(ctx contexte.Context, uri ...chaîne) (carte[chaîne]chaîne, erreur) {29retour carte[chaîne]chaîne{30« x-token »: un.jeton,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35retour false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(informations d'authentification.NewTLS(&tls.Config{})),41grpc.Avec les identifiants RPCC(&auth{token}),42}43conn := client.NewGrpcClient(endpoint)44if err := conn.Start(opts...); err != nil {45panique(erreur)46}47reporter conn.Conn.Fermer()4849ownerAddress := "THPvaUhoh2Qn2y9THCZML3H815hhFhn5YC"50contractAddress := "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"51method := "totalSupply()"52jsonParams := ""5354response, err := conn.TriggerConstantContract(55ownerAddress,56contractAddress,57method,58jsonParams,59)60si err != nil {61fmt.Printf("Error calling TriggerConstantContract: %v\n", err)62retour63}6465if len(response.ConstantResult) == 0 {66fmt.Println("No result returned from contract call")67retour68}6970hexData := hex.EncodeToString(response.ConstantResult[0])7172numericValue, err := conn.ParseTRC20NumericProperty(hexData)73si err != nil {74fmt.Printf("Error parsing numeric property: %v\n", err)75retour76}7778fmt.Printf("Parsed numeric value: %s\n", numericValue.String())7980}
Vous n'avez pas encore de compte ?
Créez votreendpoint Quicknode endpoint quelques secondes et commencez à développer
Commencez gratuitement