isBlockhashValid gRPC Method - Yellowstone
Please note that this RPC method requires the Yellowstone gRPC add-on enabled on your QuickNode endpoint.
Parameters
blockhash
bytes
REQUIRED
Loading...
Returns
valid
boolean
Loading...
slot
string
Loading...
Request
package main import ( "context" "crypto/tls" "fmt" "log" "time" pb "yellowstone/proto" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/encoding/gzip" "google.golang.org/grpc/keepalive" ) // QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token // For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde123456789 // endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC} // token will be : abcde123456789 var ( endpoint = "YOUR_QN_ENDPOINT:10000" token = "YOUR_TOKEN_NUMBER" ) func main() { opts := []grpc.DialOption{ grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), grpc.WithKeepaliveParams(kacp), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Name)), grpc.WithPerRPCCredentials(tokenAuth{token: token}), } conn, err := grpc.NewClient(endpoint, opts...) if err != nil { log.Fatalf("Failed to connect: %v", err) } defer conn.Close() client := pb.NewGeyserClient(conn) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() const BLOCKHASH_TO_CHECK = "FJcV9hJycVRkyHWf3P8qjxE2vLs6dF38RTZzZBNvNM1z" isBlockhashValid, err := client.IsBlockhashValid(ctx, &pb.IsBlockhashValidRequest{ Blockhash: BLOCKHASH_TO_CHECK, }) if err != nil { log.Fatalf("Failed to check blockhash validity: %v", err) } fmt.Printf("Slot: %d\n", isBlockhashValid.Slot) fmt.Printf("Valid: %v\n", isBlockhashValid.Valid) }
import Client, { CommitmentLevel } from "@triton-one/yellowstone-grpc"; // QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token // For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde123456789 // endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC} // token will be : abcde123456789 const ENDPOINT = "YOUR_QN_ENDPOINT:10000"; const TOKEN = "YOUR_TOKEN_NUMBER"; const BLOCKHASH_TO_CHECK = "FJcV9hJycVRkyHWf3P8qjxE2vLs6dF38RTZzZBNvNM1z"; async function main() { const client = new Client(ENDPOINT, TOKEN, {}); const commitment = CommitmentLevel.CONFIRMED; try { const result = await client.isBlockhashValid(BLOCKHASH_TO_CHECK, commitment); console.log(`Blockhash validity check for ${BLOCKHASH_TO_CHECK}:`); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error("Error checking blockhash validity:", error); } } main() .catch((err) => { console.error("Unhandled error:", err); process.exit(1); });
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free