GetWitnessBrokerage gRPC Method
Parameters
witness
string
REQUIRED
Loading...
Returns
brokerage
number
Loading...
error
object
Loading...
Request
1package main23import (4"context"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 endpoint = "YOUR_ENDPOINT:50051"2122type auth struct {23token string24}2526func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {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}
1package main23import (4"context"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 endpoint = "YOUR_ENDPOINT:50051"2122type auth struct {23token string24}2526func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {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}
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free