getBlockHeight gRPC Method - Solana gRPC
Solana gRPC está incluido en los planes Scale y Business. En los planes Build y Accelerate, sigue estando disponible a través del complemento Solana gRPC.
Parámetros
Este método no admite ningún parámetro
Devoluciones
Blockheight
cadena
Cargando...
Solicitud
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«registro»8«tiempo»910pb «yellowstone/proto»111213"google.golang.org/grpc"14"google.golang.org/grpc/credentials"15"google.golang.org/grpc/encoding/gzip"16"google.golang.org/grpc/keepalive"17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}22// token will be : abcde1234567892324var (25punto final = "TU_QN_ENDPOINT:10000"26token = "TU_NÚMERO_DE_TOKEN"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Nombre)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(punto de conexión, opts...)38si err != nil {39registro.Fatalf(«Error al conectarse: %v», err)40}41aplazar conn.Cerrar()4243cliente := pb.NewGeyserClient(conn)4445ctx, cancel := contexto.WithTimeout(contexto.Background(), 10*vez.Segundo)46aplazar cancelar()4748blockheight, err := client.GetBlockHeight(ctx, &pb.GetBlockHeightRequest{})49si err != nil {50log.Fatalf("Failed to get block height: %v", err)51}52fmt.Printf(" Block Height: %+v\n", blockheight)5354}
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«registro»8«tiempo»910pb «yellowstone/proto»111213"google.golang.org/grpc"14"google.golang.org/grpc/credentials"15"google.golang.org/grpc/encoding/gzip"16"google.golang.org/grpc/keepalive"17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}22// token will be : abcde1234567892324var (25punto final = "TU_QN_ENDPOINT:10000"26token = "TU_NÚMERO_DE_TOKEN"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Nombre)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(punto de conexión, opts...)38si err != nil {39registro.Fatalf(«Error al conectarse: %v», err)40}41aplazar conn.Cerrar()4243cliente := pb.NewGeyserClient(conn)4445ctx, cancel := contexto.WithTimeout(contexto.Background(), 10*vez.Segundo)46aplazar cancelar()4748blockheight, err := client.GetBlockHeight(ctx, &pb.GetBlockHeightRequest{})49si err != nil {50log.Fatalf("Failed to get block height: %v", err)51}52fmt.Printf(" Block Height: %+v\n", blockheight)5354}
1import Client from "@triton-one/yellowstone-grpc";23// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token4// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde1234567895// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}6// token will be : abcde12345678978const PUNTO FINAL = "TU_QN_ENDPOINT:10000";9const TOKEN = "TU_NÚMERO_DE_TOKEN";1011asíncrono función main() {12const client = new Client(ENDPOINT, TOKEN, {});1314prueba {15const blockheight = await client.getBlockHeight();16console.log(`Latest Blockheight: ${JSON.stringify(blockheight, null, 2)}`);17} catch (error) {18console.error("Error fetching Blockheight:", error);19}20}2122principal()23.captura((err) => {24consola.error(«Error no gestionado:», err);25proceso.salir(1);26});
1import Client from "@triton-one/yellowstone-grpc";23// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token4// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde1234567895// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}6// token will be : abcde12345678978const PUNTO FINAL = "TU_QN_ENDPOINT:10000";9const TOKEN = "TU_NÚMERO_DE_TOKEN";1011asíncrono función main() {12const client = new Client(ENDPOINT, TOKEN, {});1314prueba {15const blockheight = await client.getBlockHeight();16console.log(`Latest Blockheight: ${JSON.stringify(blockheight, null, 2)}`);17} catch (error) {18console.error("Error fetching Blockheight:", error);19}20}2122principal()23.captura((err) => {24consola.error(«Error no gestionado:», err);25proceso.salir(1);26});
¿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