GetWitnessBrokerage gRPC Method
Parâmetros
witness
cadeia de caracteres
OBRIGATÓRIO
A carregar...
Devoluções
brokerage
número
A carregar...
erro
objeto
A carregar...
Pedido
1pacote principal23importar (4"contexto"5"crypto/tls"6"fmt"78"github.com/fbsobreira/gotron-sdk/pkg/client"9"google.golang.org/grpc"10"google.golang.org/grpc/credentials"11)121314// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token15// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678916// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}17// token will be : abcde1234567891819var token = "YOUR_TOKEN"20var ponto final = "O_SEU_PONTO_DE_ACESSO:50051"2122tipo auth estrutura {23token string24}2526func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]string, erro) {27return map[string]string{28"x-token": a.token,29}, nil30}3132func (a *auth) RequireTransportSecurity() bool {33return false34}3536func main() {37opts := []grpc.DialOption{38grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),39grpc.WithPerRPCCredentials(&auth{token}),40}41conn := client.NewGrpcClient(endpoint)42if err := conn.Start(opts...); err != nil {43panic(err)44}4546witnessAddr := "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U"4748fmt.Printf("Getting brokerage for witness: %s\n", witnessAddr)49brokerage, err := conn.GetWitnessBrokerage(witnessAddr)50if err != nil {51fmt.Printf("Error fetching witness brokerage: %v\n", err)52return53}5455fmt.Printf("Witness brokerage: %.0f%%\n", brokerage)5657}
1pacote principal23importar (4"contexto"5"crypto/tls"6"fmt"78"github.com/fbsobreira/gotron-sdk/pkg/client"9"google.golang.org/grpc"10"google.golang.org/grpc/credentials"11)121314// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token15// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678916// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}17// token will be : abcde1234567891819var token = "YOUR_TOKEN"20var ponto final = "O_SEU_PONTO_DE_ACESSO:50051"2122tipo auth estrutura {23token string24}2526func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]string, erro) {27return map[string]string{28"x-token": a.token,29}, nil30}3132func (a *auth) RequireTransportSecurity() bool {33return false34}3536func main() {37opts := []grpc.DialOption{38grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),39grpc.WithPerRPCCredentials(&auth{token}),40}41conn := client.NewGrpcClient(endpoint)42if err := conn.Start(opts...); err != nil {43panic(err)44}4546witnessAddr := "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U"4748fmt.Printf("Getting brokerage for witness: %s\n", witnessAddr)49brokerage, err := conn.GetWitnessBrokerage(witnessAddr)50if err != nil {51fmt.Printf("Error fetching witness brokerage: %v\n", err)52return53}5455fmt.Printf("Witness brokerage: %.0f%%\n", brokerage)5657}
Ainda não tem uma conta?
Crie o seu ponto de extremidade Quicknode em segundos e comece a desenvolver
Comece gratuitamente