2

For vault_ata_make, how does anchor know how much space is needed since we didn't specify any space at all ?

#[account(
        init,
        payer = maker,
        //Anchor descr is needed because of InitSpace
        space = 8 + Escrow::INIT_SPACE,
        seeds = [b"escrow",maker.key().as_ref(), seed.to_le_bytes().as_ref()],
        bump
    )]
    pub escrow: Account<'info, Escrow>,
    
    #[account(
        init,
        payer =maker,
        associated_token::mint = mint_to_make,
        associated_token::authority = escrow,
    )]
    pub vault_ata_make: InterfaceAccount<'info, TokenAccount>,
1
  • 2
    The ATA program determines the space required for it here defined here
    – Jimii
    Commented Aug 14 at 17:15

1 Answer 1

3

Anchor has special constraints for the some SPL token programs. In the case of your vault_ata_make, it's using the Associated Token program (ATP) constraints. Since the init constraint is being used with the ATP constraints, Anchor under the hood invokes the ATP here. Ultimately the ATP determines space needed here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.