Kit
Functions

isLamports

isLamports(putativeLamports): putativeLamports is Lamports

This is a type guard that accepts a bigint as input. It will both return true if the integer conforms to the Lamports type and will refine the type for use in your program.

Parameters

ParameterType
putativeLamportsbigint

Returns

putativeLamports is Lamports

Example

import { isLamports } from '@solana/rpc-types';
 
if (isLamports(lamports)) {
    // At this point, `lamports` has been refined to a
    // `Lamports` that can be used anywhere Lamports are expected.
    await transfer(fromAddress, toAddress, lamports);
} else {
    setError(`${lamports} is not a quantity of Lamports`);
}

On this page