ListNodes gRPC Method
Parâmetros
Este método não aceita quaisquer parâmetros
Devoluções
nodes
matriz
Carregando...
morada
objeto
Carregando...
host
cadeia de caracteres
Carregando...
port
número inteiro
Carregando...
erro
objeto
Carregando...
Pedido
1pacote principal23importar (4"contexto"5"crypto/tls"6"encoding/json"7"fmt"89"github.com/fbsobreira/gotron-sdk/pkg/client"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 token = "O_SEU_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324tipo auth estrutura {25token cadeia de caracteres26}2728func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]cadeia de caracteres, erro) {29retornar mapa[string]string{30«x-token»: um.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35retornar false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(credenciais.NewTLS(&tls.Config{})),41grpc.WithPerRPCCredentials(&auth{token}),42}43conn := client.NewGrpcClient(endpoint)44if err := conn.Start(opts...); err != nil {45panic(err)46}4748fmt.Println("Listing network nodes:")49nodes, err := conn.ListNodes()50se err != nil {51fmt.Printf("Error listing nodes: %v\n", err)52return53}5455nodeJSON, err := json.MarshalIndent(nodes, "", " ")56se err != nil {57fmt.Printf("Error marshaling to JSON: %v\n", err)58return59}6061fmt.Println(string(nodeJSON))6263}
1pacote principal23importar (4"contexto"5"crypto/tls"6"encoding/json"7"fmt"89"github.com/fbsobreira/gotron-sdk/pkg/client"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 token = "O_SEU_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324tipo auth estrutura {25token cadeia de caracteres26}2728func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]cadeia de caracteres, erro) {29retornar mapa[string]string{30«x-token»: um.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35retornar false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(credenciais.NewTLS(&tls.Config{})),41grpc.WithPerRPCCredentials(&auth{token}),42}43conn := client.NewGrpcClient(endpoint)44if err := conn.Start(opts...); err != nil {45panic(err)46}4748fmt.Println("Listing network nodes:")49nodes, err := conn.ListNodes()50se err != nil {51fmt.Printf("Error listing nodes: %v\n", err)52return53}5455nodeJSON, err := json.MarshalIndent(nodes, "", " ")56se err != nil {57fmt.Printf("Error marshaling to JSON: %v\n", err)58return59}6061fmt.Println(string(nodeJSON))6263}
Ainda não tem uma conta?
Crieendpoint seuendpoint Quicknode endpoint segundos e comece a desenvolver
Comece gratuitamente