isBlockhashValid gRPC Method - Solana gRPC
Solana gRPC is included with Scale plans and up. Learn more on our pricing page.
Parameters
blockhash
string
REQUIRED
Loading...
commitment
string
Loading...
PROCESSED
string
Loading...
CONFIRMED
string
Loading...
FINALIZED
string
Loading...
Returns
valid
boolean
Loading...
slot
string
Loading...
Request
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"8"time"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:443 {443 is the port number for gRPC}22// token will be : abcde1234567892324var (25endpoint = "YOUR_QN_ENDPOINT:443"26token = "YOUR_TOKEN_NUMBER"27)2829var kacp = keepalive.ClientParameters{30Time: 10 * time.Second,31Timeout: time.Second,32PermitWithoutStream: true,33}3435type tokenAuth struct {36token string37}3839func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {40return map[string]string{41"x-token": t.token,42}, nil43}4445func (tokenAuth) RequireTransportSecurity() bool {46return true47}4849func main() {50opts := []grpc.DialOption{51grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),52grpc.WithKeepaliveParams(kacp),53grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Name)),54grpc.WithPerRPCCredentials(tokenAuth{token: token}),55}5657conn, err := grpc.NewClient(endpoint, opts...)58if err != nil {59log.Fatalf("Failed to connect: %v", err)60}61defer conn.Close()6263client := pb.NewGeyserClient(conn)6465ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)66defer cancel()6768const BLOCKHASH_TO_CHECK = "FJcV9hJycVRkyHWf3P8qjxE2vLs6dF38RTZzZBNvNM1z"6970isBlockhashValid, err := client.IsBlockhashValid(ctx, &pb.IsBlockhashValidRequest{71Blockhash: BLOCKHASH_TO_CHECK,72})73if err != nil {74log.Fatalf("Failed to check blockhash validity: %v", err)75}767778fmt.Printf("Slot: %d\n", isBlockhashValid.Slot)79fmt.Printf("Valid: %v\n", isBlockhashValid.Valid)808182}83
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"8"time"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:443 {443 is the port number for gRPC}22// token will be : abcde1234567892324var (25endpoint = "YOUR_QN_ENDPOINT:443"26token = "YOUR_TOKEN_NUMBER"27)2829var kacp = keepalive.ClientParameters{30Time: 10 * time.Second,31Timeout: time.Second,32PermitWithoutStream: true,33}3435type tokenAuth struct {36token string37}3839func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {40return map[string]string{41"x-token": t.token,42}, nil43}4445func (tokenAuth) RequireTransportSecurity() bool {46return true47}4849func main() {50opts := []grpc.DialOption{51grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),52grpc.WithKeepaliveParams(kacp),53grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Name)),54grpc.WithPerRPCCredentials(tokenAuth{token: token}),55}5657conn, err := grpc.NewClient(endpoint, opts...)58if err != nil {59log.Fatalf("Failed to connect: %v", err)60}61defer conn.Close()6263client := pb.NewGeyserClient(conn)6465ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)66defer cancel()6768const BLOCKHASH_TO_CHECK = "FJcV9hJycVRkyHWf3P8qjxE2vLs6dF38RTZzZBNvNM1z"6970isBlockhashValid, err := client.IsBlockhashValid(ctx, &pb.IsBlockhashValidRequest{71Blockhash: BLOCKHASH_TO_CHECK,72})73if err != nil {74log.Fatalf("Failed to check blockhash validity: %v", err)75}767778fmt.Printf("Slot: %d\n", isBlockhashValid.Slot)79fmt.Printf("Valid: %v\n", isBlockhashValid.Valid)808182}83
1import Client, { CommitmentLevel } 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 = "YOUR_TOKEN_NUMBER";1011const BLOCKHASH_TO_CHECK = "FJcV9hJycVRkyHWf3P8qjxE2vLs6dF38RTZzZBNvNM1z";1213async function main() {14const client = new Client(ENDPOINT, TOKEN, {15grpcDefaultCompressionAlgorithm: 0, // 0 = gzip, 1 = zstd16});17await client.connect();1819const commitment = CommitmentLevel.CONFIRMED;2021try {22const result = await client.isBlockhashValid(BLOCKHASH_TO_CHECK, commitment);23console.log(`Blockhash validity check for ${BLOCKHASH_TO_CHECK}:`);24console.log(JSON.stringify(result, null, 2));2526} catch (error) {27console.error("Error checking blockhash validity:", error);28}29}3031main()32.catch((err) => {33console.error("Unhandled error:", err);34process.exit(1);35});36
1import Client, { CommitmentLevel } 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 = "YOUR_TOKEN_NUMBER";1011const BLOCKHASH_TO_CHECK = "FJcV9hJycVRkyHWf3P8qjxE2vLs6dF38RTZzZBNvNM1z";1213async function main() {14const client = new Client(ENDPOINT, TOKEN, {15grpcDefaultCompressionAlgorithm: 0, // 0 = gzip, 1 = zstd16});17await client.connect();1819const commitment = CommitmentLevel.CONFIRMED;2021try {22const result = await client.isBlockhashValid(BLOCKHASH_TO_CHECK, commitment);23console.log(`Blockhash validity check for ${BLOCKHASH_TO_CHECK}:`);24console.log(JSON.stringify(result, null, 2));2526} catch (error) {27console.error("Error checking blockhash validity:", error);28}29}3031main()32.catch((err) => {33console.error("Unhandled error:", err);34process.exit(1);35});36
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free