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

    Type Parameters

    • TAddress extends string = string

    Parameters

    Returns Address<TAddress>

    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'>;