associatedTokenAccount static method
ProgramDerivedAddress
associatedTokenAccount({
- required SolAddress mint,
- required SolAddress owner,
- SolAddress programId = AssociatedTokenAccountProgramConst.associatedTokenProgramId,
- SolAddress tokenProgramId = SPLTokenProgramConst.tokenProgramId,
- bool allowOwnerOffCurve = false,
Finds the address of the Associated Token Account.
Implementation
static ProgramDerivedAddress associatedTokenAccount({
required SolAddress mint,
required SolAddress owner,
SolAddress programId =
AssociatedTokenAccountProgramConst.associatedTokenProgramId,
SolAddress tokenProgramId = SPLTokenProgramConst.tokenProgramId,
bool allowOwnerOffCurve = false,
}) {
if (!allowOwnerOffCurve && !owner.isOnCurve) {
throw MessageException("Public key address is not valid on the curve.");
}
return ProgramDerivedAddress.find(
seedBytes: [owner.toBytes(), tokenProgramId.toBytes(), mint.toBytes()],
programId: programId);
}