Kit
Functions

isAddress

isAddress(putativeAddress): putativeAddress is Address<string>

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

Parameters

ParameterType
putativeAddressstring

Returns

putativeAddress is Address<string>

Example

import { isAddress } from '@solana/addresses';
 
if (isAddress(ownerAddress)) {
    // At this point, `ownerAddress` has been refined to a
    // `Address` that can be used with the RPC.
    const { value: lamports } = await rpc.getBalance(ownerAddress).send();
    setBalanceLamports(lamports);
} else {
    setError(`${ownerAddress} is not an address`);
}

On this page