ListNodes gRPC Method
Paramètres
Cette méthode n'accepte aucun paramètre
Retours
nodes
tableau
Chargement en cours...
adresse
objet
Chargement en cours...
host
chaîne de caractères
Chargement en cours...
port
entier
Chargement en cours...
erreur
objet
Chargement en cours...
Demande
1paquet principal23import (4« contexte »5« crypto/tls »6« encoding/json »7« fmt »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}4748fmt.Println("Listing network nodes:")49nodes, err := conn.ListNodes()50si err != nil {51fmt.Printf("Error listing nodes: %v\n", err)52retour53}5455nodeJSON, err := json.MarshalIndent(nodes, "", " ")56si err != nil {57fmt.Printf("Erreur de conversion vers JSON : %v\n", err)58retour59}6061fmt.Println(string(nodeJSON))6263}
1paquet principal23import (4« contexte »5« crypto/tls »6« encoding/json »7« fmt »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}4748fmt.Println("Listing network nodes:")49nodes, err := conn.ListNodes()50si err != nil {51fmt.Printf("Error listing nodes: %v\n", err)52retour53}5455nodeJSON, err := json.MarshalIndent(nodes, "", " ")56si err != nil {57fmt.Printf("Erreur de conversion vers JSON : %v\n", err)58retour59}6061fmt.Println(string(nodeJSON))6263}
Vous n'avez pas encore de compte ?
Créez votreendpoint Quicknode endpoint quelques secondes et commencez à développer
Commencez gratuitement