getBlockHeight gRPC Method - Solana gRPC
Solana gRPC ist in den Tarifen „Scale“ und „Business“ enthalten. In den Tarifen „Build“ und „Accelerate“ ist es weiterhin über das Solana gRPC-Add-on verfügbar.
Parameter
Diese Methode akzeptiert keine Parameter.
Rücksendungen
Blockheight
Zeichenkette
Wird geladen...
Anfrage
1Paket Hauptteil23import (4„Kontext“5„crypto/tls“6„fmt“7„log“8„Zeit“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 (25Endpunkt = "YOUR_QN_ENDPOINT:10000"26Token = "IHRE_TOKEN-NUMMER"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(Anmeldedaten.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Name)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(Endpunkt, opts...)38wenn err != nil {39Protokoll.Fatalf(„Verbindung konnte nicht hergestellt werden: %v“, err)40}41aufschieben conn.Schließen()4243Client := pb.NewGeyserClient(conn)4445ctx, abbrechen := Kontext.WithTimeout(Kontext.Hintergrund(), 10*Zeit.Zweite)46aufschieben abbrechen()4748blockheight, err := client.GetBlockHeight(ctx, &pb.GetBlockHeightRequest{})49wenn err != nil {50log.Fatalf("Failed to get block height: %v", err)51}52fmt.Printf(" Block Height: %+v\n", blockheight)5354}
1Paket Hauptteil23import (4„Kontext“5„crypto/tls“6„fmt“7„log“8„Zeit“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 (25Endpunkt = "YOUR_QN_ENDPOINT:10000"26Token = "IHRE_TOKEN-NUMMER"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(Anmeldedaten.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Name)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(Endpunkt, opts...)38wenn err != nil {39Protokoll.Fatalf(„Verbindung konnte nicht hergestellt werden: %v“, err)40}41aufschieben conn.Schließen()4243Client := pb.NewGeyserClient(conn)4445ctx, abbrechen := Kontext.WithTimeout(Kontext.Hintergrund(), 10*Zeit.Zweite)46aufschieben abbrechen()4748blockheight, err := client.GetBlockHeight(ctx, &pb.GetBlockHeightRequest{})49wenn 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 ENDPOINT = "YOUR_QN_ENDPOINT:10000";9const TOKEN = "IHRE_TOKEN-NUMMER";1011async Funktion main() {12const client = new Client(ENDPOINT, TOKEN, {});1314versuchen {15const blockheight = await client.getBlockHeight();16console.log(`Latest Blockheight: ${JSON.stringify(blockheight, null, 2)}`);17} catch (Fehler) {18console.error("Error fetching Blockheight:", error);19}20}2122Hauptseite()23.catch((err) => {24Konsole.Fehler(„Unbehandelter Fehler:“, err);25Prozess.Beenden(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 ENDPOINT = "YOUR_QN_ENDPOINT:10000";9const TOKEN = "IHRE_TOKEN-NUMMER";1011async Funktion main() {12const client = new Client(ENDPOINT, TOKEN, {});1314versuchen {15const blockheight = await client.getBlockHeight();16console.log(`Latest Blockheight: ${JSON.stringify(blockheight, null, 2)}`);17} catch (Fehler) {18console.error("Error fetching Blockheight:", error);19}20}2122Hauptseite()23.catch((err) => {24Konsole.Fehler(„Unbehandelter Fehler:“, err);25Prozess.Beenden(1);26});
Haben Sie noch kein Konto?
Erstellen Sie Ihren Quicknode-Endpunkt in Sekundenschnelle und legen Sie los
Kostenlos loslegen