GetWitnessBrokerage gRPC Method
參數
witness
字串
必填
載入中...
退貨
brokerage
數字
載入中...
錯誤
物件
載入中...
請求
1套件 主函式23匯入 (4"上下文"5"crypto/tls"6"fmt"78"github.com/fbsobreira/gotron-sdk/pkg/client"9"google.golang.grpc"10"google.golang.grpc"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 代幣 = "您的_代幣"20var endpoint = "YOUR_ENDPOINT:50051"2122類型 auth 結構體 {23代幣 字串24}2526func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字串) (map[字串]字串, 錯誤) {27返回 地圖[字串]字串{28「x-token」: a.token,29}, nil30}3132func (a *auth) RequireTransportSecurity() bool {33返回 false34}3536func main() {37opts := []grpc.DialOption{38grpc.WithTransportCredentials(憑證.NewTLS(&tls.Config{})),39grpc.WithPerRPC憑證(&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)50如果 err != nil {51fmt.Printf("Error fetching witness brokerage: %v\n", err)52return53}5455fmt.Printf("Witness brokerage: %.0f%%\n", brokerage)5657}
1套件 主函式23匯入 (4"上下文"5"crypto/tls"6"fmt"78"github.com/fbsobreira/gotron-sdk/pkg/client"9"google.golang.grpc"10"google.golang.grpc"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 代幣 = "您的_代幣"20var endpoint = "YOUR_ENDPOINT:50051"2122類型 auth 結構體 {23代幣 字串24}2526func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字串) (map[字串]字串, 錯誤) {27返回 地圖[字串]字串{28「x-token」: a.token,29}, nil30}3132func (a *auth) RequireTransportSecurity() bool {33返回 false34}3536func main() {37opts := []grpc.DialOption{38grpc.WithTransportCredentials(憑證.NewTLS(&tls.Config{})),39grpc.WithPerRPC憑證(&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)50如果 err != nil {51fmt.Printf("Error fetching witness brokerage: %v\n", err)52return53}5455fmt.Printf("Witness brokerage: %.0f%%\n", brokerage)5657}