getBlockHeight gRPC Method - Solana gRPC
Solana gRPC is included with Scale plans and up. Learn more on our pricing page.
Parámetros
commitment
cadena
Cargando...
PROCESSED
cadena
Cargando...
CONFIRMED
cadena
Cargando...
FINALIZED
cadena
Cargando...
Devoluciones
blockHeight
cadena
Cargando...
Solicitud
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«registro»8«tiempo»910pb «yellowstone»111213"google.golang.grpc"14"google.golang.grpc"15"google.golang.grpc"16"google.golang.grpc"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:443 {443 is the port number for gRPC}22// token will be : abcde1234567892324var (25endpoint = "YOUR_QN_ENDPOINT:443"26token = "TU_NÚMERO_DE_TOKEN"27)2829var kacp = keepalive.ClientParameters{30Time: 10 * time.Second,31Timeout: time.Second,32PermitWithoutStream: true,33}3435type tokenAuth struct {36token cadena37}3839func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {40volver mapa[cadena]cadena{41"x-token": t.token,42}, nil43}4445func (tokenAuth) RequireTransportSecurity() bool {46return true47}4849func main() {50opts := []grpc.DialOption{51grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),52grpc.WithKeepaliveParams(kacp),53grpc.WithDefaultCallOptions((grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Nombre)),54grpc.WithPerRPCCredentials(tokenAuth{token: token}),55}5657conn, err := grpc.NewClient(endpoint, opts...)58si err != nil {59registro.Fatalf(«Error al conectarse: %v», err)60}61aplazar conn.Cerrar()6263cliente := pb.NewGeyserClient(conn)6465ctx, cancel := contexto.WithTimeout(contexto.Background(), 10*vez.Segunda)66aplazar cancelar()6768blockheight, err := client.GetBlockHeight(ctx, &pb.GetBlockHeightRequest{})69si err != nil {70log.Fatalf("Failed to get block height: %v", err)71}72fmt.Printf(" Block Height: %+v\n", blockheight)7374}75
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«registro»8«tiempo»910pb «yellowstone»111213"google.golang.grpc"14"google.golang.grpc"15"google.golang.grpc"16"google.golang.grpc"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:443 {443 is the port number for gRPC}22// token will be : abcde1234567892324var (25endpoint = "YOUR_QN_ENDPOINT:443"26token = "TU_NÚMERO_DE_TOKEN"27)2829var kacp = keepalive.ClientParameters{30Time: 10 * time.Second,31Timeout: time.Second,32PermitWithoutStream: true,33}3435type tokenAuth struct {36token cadena37}3839func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {40volver mapa[cadena]cadena{41"x-token": t.token,42}, nil43}4445func (tokenAuth) RequireTransportSecurity() bool {46return true47}4849func main() {50opts := []grpc.DialOption{51grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),52grpc.WithKeepaliveParams(kacp),53grpc.WithDefaultCallOptions((grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Nombre)),54grpc.WithPerRPCCredentials(tokenAuth{token: token}),55}5657conn, err := grpc.NewClient(endpoint, opts...)58si err != nil {59registro.Fatalf(«Error al conectarse: %v», err)60}61aplazar conn.Cerrar()6263cliente := pb.NewGeyserClient(conn)6465ctx, cancel := contexto.WithTimeout(contexto.Background(), 10*vez.Segunda)66aplazar cancelar()6768blockheight, err := client.GetBlockHeight(ctx, &pb.GetBlockHeightRequest{})69si err != nil {70log.Fatalf("Failed to get block height: %v", err)71}72fmt.Printf(" Block Height: %+v\n", blockheight)7374}75
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: https://docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}6// token will be : abcde12345678978const ENDPOINT = "https://YOUR_QN_ENDPOINT:443";9const TOKEN = "TU_NÚMERO_DE_TOKEN";1011asíncrono función main() {12const client = new Client(ENDPOINT, TOKEN, {13grpcDefaultCompressionAlgorithm: 0, // 0 = gzip, 1 = zstd14});15await client.connect();1617prueba {18const blockheight = await client.getBlockHeight();19console.log(`Latest Blockheight: ${JSON.stringify(blockheight, null, 2)}`);20} catch (error) {21console.error("Error fetching Blockheight:", error);22}23}2425principal()26.captura((err) => {27consola.error(«Error no gestionado:», err);28proceso.salir(1);29});30
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: https://docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}6// token will be : abcde12345678978const ENDPOINT = "https://YOUR_QN_ENDPOINT:443";9const TOKEN = "TU_NÚMERO_DE_TOKEN";1011asíncrono función main() {12const client = new Client(ENDPOINT, TOKEN, {13grpcDefaultCompressionAlgorithm: 0, // 0 = gzip, 1 = zstd14});15await client.connect();1617prueba {18const blockheight = await client.getBlockHeight();19console.log(`Latest Blockheight: ${JSON.stringify(blockheight, null, 2)}`);20} catch (error) {21console.error("Error fetching Blockheight:", error);22}23}2425principal()26.captura((err) => {27consola.error(«Error no gestionado:», err);28proceso.salir(1);29});30
¿Aún no tienes una cuenta?
Crea tuendpoint Quicknode endpoint segundos y empieza a desarrollar
Empieza gratis