ExchangeList gRPC Method
Parámetros
página
entero
OBLIGATORIO
Cargando...
límite
entero
Cargando...
Devoluciones
exchanges
matriz
Cargando...
exchange_id
entero
Cargando...
creator_address
cadena
Cargando...
create_time
entero
Cargando...
first_token_id
cadena
Cargando...
first_token_balance
entero
Cargando...
second_token_id
cadena
Cargando...
second_token_balance
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)1112// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token13// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678914// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}15// token will be : abcde1234567891617var token = "TU_TOKEN"18var punto final = "TU_PUNTO_DE_ACceso:50051"1920tipo autenticación estructura {21token cadena22}2324func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, error) {25volver mapa[cadena]cadena{26"x-token": a.token,27}, nil28}2930func (a *auth) RequireTransportSecurity() bool {31volver false32}3334func main() {3536opts := []grpc.DialOption{37grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),38grpc.WithPerRPCCredentials(&auth{token}),39}40conn := cliente.NewGrpcClient(punto de conexión)41if err := conn.Start(opts...); err != nil {42panic(err)43}44aplazar conn.Conn.Cerrar()4546fmt.Println("Retrieving all exchange pairs...")4748allExchanges, err := conn.ExchangeList(-1) // Use -1 to get all exchanges4950si err != nil {51fmt.Printf("Error retrieving all exchanges: %v\n", err)52volver53}5455fmt.Printf("Total number of exchanges: %d\n\n", len(allExchanges.Exchanges))5657fmt.Println("Retrieving paginated exchange pairs...")5859page := int64(0) // Page number (starting from 0)60limit := 2 // Number of exchanges per page6162paginatedExchanges, err := conn.ExchangeList(page, limit)6364si err != nil {65fmt.Printf("Error retrieving paginated exchanges: %v\n", err)66volver67}6869fmt.Printf("Page %d (limit %d): Retrieved %d exchanges\n\n",70page, limit, len(paginatedExchanges.Exchanges))7172fmt.Println("Exchange Details:")73for i, exchange := range paginatedExchanges.Exchanges {74fmt.Printf("Exchange #%d:\n", i+1)75fmt.Printf(" ID: %d\n", exchange.ExchangeId)76fmt.Printf(" Creator: %s\n", string(exchange.CreatorAddress))77fmt.Printf(" Creation Time: %d\n", exchange.CreateTime)78fmt.Printf(" First Token ID: %s\n", string(exchange.FirstTokenId))79fmt.Printf(" First Token Balance: %d\n", exchange.FirstTokenBalance)80fmt.Printf(" Second Token ID: %s\n", string(exchange.SecondTokenId))81fmt.Printf(" Second Token Balance: %d\n", exchange.SecondTokenBalance)8283if exchange.FirstTokenBalance > 0 && exchange.SecondTokenBalance > 0 {84rate1 := float64(exchange.SecondTokenBalance) / float64(exchange.FirstTokenBalance)85rate2 := float64(exchange.FirstTokenBalance) / float64(exchange.SecondTokenBalance)86fmt.Printf(" Exchange Rates:\n")87fmt.Printf(" 1 %s = %.6f %s\n", string(exchange.FirstTokenId), rate1, string(exchange.SecondTokenId))88fmt.Printf(" 1 %s = %.6f %s\n", string(exchange.SecondTokenId), rate2, string(exchange.FirstTokenId))89}90fmt.Println()91}92}
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)1112// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token13// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678914// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}15// token will be : abcde1234567891617var token = "TU_TOKEN"18var punto final = "TU_PUNTO_DE_ACceso:50051"1920tipo autenticación estructura {21token cadena22}2324func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...cadena) (mapa[cadena]cadena, error) {25volver mapa[cadena]cadena{26"x-token": a.token,27}, nil28}2930func (a *auth) RequireTransportSecurity() bool {31volver false32}3334func main() {3536opts := []grpc.DialOption{37grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),38grpc.WithPerRPCCredentials(&auth{token}),39}40conn := cliente.NewGrpcClient(punto de conexión)41if err := conn.Start(opts...); err != nil {42panic(err)43}44aplazar conn.Conn.Cerrar()4546fmt.Println("Retrieving all exchange pairs...")4748allExchanges, err := conn.ExchangeList(-1) // Use -1 to get all exchanges4950si err != nil {51fmt.Printf("Error retrieving all exchanges: %v\n", err)52volver53}5455fmt.Printf("Total number of exchanges: %d\n\n", len(allExchanges.Exchanges))5657fmt.Println("Retrieving paginated exchange pairs...")5859page := int64(0) // Page number (starting from 0)60limit := 2 // Number of exchanges per page6162paginatedExchanges, err := conn.ExchangeList(page, limit)6364si err != nil {65fmt.Printf("Error retrieving paginated exchanges: %v\n", err)66volver67}6869fmt.Printf("Page %d (limit %d): Retrieved %d exchanges\n\n",70page, limit, len(paginatedExchanges.Exchanges))7172fmt.Println("Exchange Details:")73for i, exchange := range paginatedExchanges.Exchanges {74fmt.Printf("Exchange #%d:\n", i+1)75fmt.Printf(" ID: %d\n", exchange.ExchangeId)76fmt.Printf(" Creator: %s\n", string(exchange.CreatorAddress))77fmt.Printf(" Creation Time: %d\n", exchange.CreateTime)78fmt.Printf(" First Token ID: %s\n", string(exchange.FirstTokenId))79fmt.Printf(" First Token Balance: %d\n", exchange.FirstTokenBalance)80fmt.Printf(" Second Token ID: %s\n", string(exchange.SecondTokenId))81fmt.Printf(" Second Token Balance: %d\n", exchange.SecondTokenBalance)8283if exchange.FirstTokenBalance > 0 && exchange.SecondTokenBalance > 0 {84rate1 := float64(exchange.SecondTokenBalance) / float64(exchange.FirstTokenBalance)85rate2 := float64(exchange.FirstTokenBalance) / float64(exchange.SecondTokenBalance)86fmt.Printf(" Exchange Rates:\n")87fmt.Printf(" 1 %s = %.6f %s\n", string(exchange.FirstTokenId), rate1, string(exchange.SecondTokenId))88fmt.Printf(" 1 %s = %.6f %s\n", string(exchange.SecondTokenId), rate2, string(exchange.FirstTokenId))89}90fmt.Println()91}92}
¿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