Kit
Functions

isBlockhash

isBlockhash(putativeBlockhash): putativeBlockhash is Blockhash

A type guard that returns true if the input string conforms to the Blockhash type, and refines its type for use in your program.

Parameters

ParameterType
putativeBlockhashstring

Returns

putativeBlockhash is Blockhash

Example

import { isBlockhash } from '@solana/rpc-types';
 
if (isBlockhash(blockhash)) {
    // At this point, `blockhash` has been refined to a
    // `Blockhash` that can be used with the RPC.
    const { value: isValid } = await rpc.isBlockhashValid(blockhash).send();
    setBlockhashIsFresh(isValid);
} else {
    setError(`${blockhash} is not a blockhash`);
}

On this page