GetRewardsInfo gRPC Method
Parámetros
dirección
cadena
OBLIGATORIO
Cargando...
Devoluciones
rewardsInfo
entero
Cargando...
Solicitud
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7"github.com/fbsobreira/gotron-sdk/pkg/client"8"google.golang.org/grpc"9"google.golang.org/grpc/credentials"10«registro»11)1213// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token14// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678915// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}16// token will be : abcde1234567891718var token = "TU_TOKEN"19var punto final = "TU_PUNTO_DE_ACceso:50051"2021tipo autenticación estructura {22token cadena23}2425func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, error) {26volver mapa[cadena]cadena{27«x-token»: un.token,28}, nil29}3031func (a *auth) RequireTransportSecurity() bool {32volver false33}3435func main() {3637opts := []grpc.DialOption{38grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),39grpc.Con credenciales RPCC(&auth{token}),40}41conn := cliente.NewGrpcClient(punto de conexión)42if err := conn.Start(opts...); err != nil {43pánico(error)44}45aplazar conn.Conn.Cerrar()4647addr := "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g"48fmt.Printf("Fetching rewards info for address: %s\n", addr)49rewardsInfo, err := conn.GetRewardsInfo(addr)50si err != nil {51log.Fatalf("Error getting rewards info: %v\n", err)52}5354fmt.Println("\nRewards Information:")55rewards := rewardsInfo56// Convert from SUN to TRX for better readability (1 TRX = 1,000,000 SUN)57rewardsTRX := float64(rewards) / 1000000.058fmt.Printf("Total Rewards: %d SUN (%.6f TRX)\n", rewards, rewardsTRX)5960if rewards > 0 {61fmt.Println("\nThese rewards are accumulated from:")62fmt.Println("- Block production (for Super Representatives)")63fmt.Println("- Voting for Super Representatives")64fmt.Println("- Other network incentives")65fmt.Println("\nRewards can be withdrawn using the withdrawal function.")66} else {67fmt.Println("\nNo rewards available for this address.")68fmt.Println("Rewards can be earned by:")69fmt.Println("- Voting for Super Representatives")70fmt.Println("- Becoming a Super Representative")71}72}
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7"github.com/fbsobreira/gotron-sdk/pkg/client"8"google.golang.org/grpc"9"google.golang.org/grpc/credentials"10«registro»11)1213// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token14// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678915// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}16// token will be : abcde1234567891718var token = "TU_TOKEN"19var punto final = "TU_PUNTO_DE_ACceso:50051"2021tipo autenticación estructura {22token cadena23}2425func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, error) {26volver mapa[cadena]cadena{27«x-token»: un.token,28}, nil29}3031func (a *auth) RequireTransportSecurity() bool {32volver false33}3435func main() {3637opts := []grpc.DialOption{38grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),39grpc.Con credenciales RPCC(&auth{token}),40}41conn := cliente.NewGrpcClient(punto de conexión)42if err := conn.Start(opts...); err != nil {43pánico(error)44}45aplazar conn.Conn.Cerrar()4647addr := "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g"48fmt.Printf("Fetching rewards info for address: %s\n", addr)49rewardsInfo, err := conn.GetRewardsInfo(addr)50si err != nil {51log.Fatalf("Error getting rewards info: %v\n", err)52}5354fmt.Println("\nRewards Information:")55rewards := rewardsInfo56// Convert from SUN to TRX for better readability (1 TRX = 1,000,000 SUN)57rewardsTRX := float64(rewards) / 1000000.058fmt.Printf("Total Rewards: %d SUN (%.6f TRX)\n", rewards, rewardsTRX)5960if rewards > 0 {61fmt.Println("\nThese rewards are accumulated from:")62fmt.Println("- Block production (for Super Representatives)")63fmt.Println("- Voting for Super Representatives")64fmt.Println("- Other network incentives")65fmt.Println("\nRewards can be withdrawn using the withdrawal function.")66} else {67fmt.Println("\nNo rewards available for this address.")68fmt.Println("Rewards can be earned by:")69fmt.Println("- Voting for Super Representatives")70fmt.Println("- Becoming a Super Representative")71}72}
¿Aún no tienes una cuenta?
Crea tu punto de conexión de Quicknode en cuestión de segundos y empieza a desarrollar
Empieza gratis