ListWitnesses gRPC Method
매개변수
이 메서드는 매개변수를 받지 않습니다.
반품
witnesses
배열
로딩 중...
주소
문자열
로딩 중...
voteCount
정수
로딩 중...
pubKey
문자열
로딩 중...
url
문자열
로딩 중...
totalProduced
정수
로딩 중...
totalMissed
정수
로딩 중...
latestBlockNum
정수
로딩 중...
latestSlotNum
정수
로딩 중...
isJobs
부울
로딩 중...
오류
객체
로딩 중...
요청
1패키지 main23import (4"문맥"5"crypto/tls"6"encoding/json"7"fmt"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.org/grpc"11"google.golang.org/grpc/credentials"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 = "YOUR_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324type auth struct {25token string26}2728func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {29return map[string]string{30"x-token": a.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(credentials.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 witnesses (super representatives):")49witnesses, err := conn.ListWitnesses()50만약 err != nil {51fmt.Printf("Error listing witnesses: %v\n", err)52반환53}5455witnessesJSON, err := json.MarshalIndent(witnesses, "", " ")56만약 err != nil {57fmt.Printf("Error marshaling to JSON: %v\n", err)58반환59}60fmt.Println(string(witnessesJSON))6162}
1패키지 main23import (4"문맥"5"crypto/tls"6"encoding/json"7"fmt"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.org/grpc"11"google.golang.org/grpc/credentials"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 = "YOUR_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324type auth struct {25token string26}2728func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {29return map[string]string{30"x-token": a.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(credentials.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 witnesses (super representatives):")49witnesses, err := conn.ListWitnesses()50만약 err != nil {51fmt.Printf("Error listing witnesses: %v\n", err)52반환53}5455witnessesJSON, err := json.MarshalIndent(witnesses, "", " ")56만약 err != nil {57fmt.Printf("Error marshaling to JSON: %v\n", err)58반환59}60fmt.Println(string(witnessesJSON))6162}