associatedTokenAccount static method

ProgramDerivedAddress associatedTokenAccount({
  1. required SolAddress mint,
  2. required SolAddress owner,
  3. SolAddress programId = AssociatedTokenAccountProgramConst.associatedTokenProgramId,
  4. SolAddress tokenProgramId = SPLTokenProgramConst.tokenProgramId,
  5. 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);
}