View Source Signet.Solana.ATA (Signet v1.6.0)
Associated Token Account (ATA) utilities for Solana.
An ATA is the canonical token account for a (wallet, mint) pair. It is
a PDA derived with seeds [wallet, token_program_id, mint] under the
Associated Token Account Program.
Examples
iex> {pub, _} = Signet.Solana.Keys.from_seed(<<1::256>>)
iex> mint = Signet.Solana.Programs.wrapped_sol_mint()
iex> {ata, bump} = Signet.Solana.ATA.find_address(pub, mint)
iex> byte_size(ata) == 32 and bump >= 0 and bump <= 255
true
Summary
Functions
Build an instruction to create an ATA. Fails if it already exists.
Build an instruction to create an ATA, succeeding even if it already exists.
Derive the associated token account address for a wallet + mint.
Functions
@spec create(<<_::256>>, <<_::256>>, <<_::256>>, keyword()) :: Signet.Solana.Transaction.Instruction.t()
Build an instruction to create an ATA. Fails if it already exists.
Options
:token_program- Override the token program (default: SPL Token Program).
@spec create_idempotent(<<_::256>>, <<_::256>>, <<_::256>>, keyword()) :: Signet.Solana.Transaction.Instruction.t()
Build an instruction to create an ATA, succeeding even if it already exists.
This is the preferred variant for most use cases - it is a no-op if the ATA already exists.
Options
:token_program- Override the token program (default: SPL Token Program).
@spec find_address(<<_::256>>, <<_::256>>, keyword()) :: {<<_::256>>, non_neg_integer()}
Derive the associated token account address for a wallet + mint.
Pure computation (no RPC call). Returns {ata_address, bump_seed}.
Options
:token_program- Override the token program (default: SPL Token Program). PassPrograms.token_2022_program()for Token-2022 mints.