Kit
Functions

address

address<TAddress>(putativeAddress): Address<TAddress>

Combines asserting that a string is an address with coercing it to the Address type. It's most useful with untrusted input.

Type Parameters

Type ParameterDefault type
TAddress extends stringstring

Parameters

ParameterType
putativeAddressTAddress

Returns

Address<TAddress>

Example

import { address } from '@solana/addresses';
 
await transfer(address(fromAddress), address(toAddress), lamports(100000n));

[!TIP] When starting from a known-good address as a string, it's more efficient to typecast it rather than to use the address helper, because the helper unconditionally performs validation on its input.

import { Address } from '@solana/addresses';
 
const MEMO_PROGRAM_ADDRESS =
    'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr' as Address<'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'>;

On this page