InterfaceAccount<'info, T>
and Interface<'info, T>
and Anchor accounts types
Would love to know more about them, where I should use them and what differentiates the two.
InterfaceAccount<'info, T>
and Interface<'info, T>
and Anchor accounts types
Would love to know more about them, where I should use them and what differentiates the two.
The Anchor account types documentation says:
Interface: Type validating that the account is one of a set of given Programs
This just means that the given account is one of a set. For example, if your program can use either SPL Token or SPL Token 2022, then your program can specify an "interface", so that anchor checks if the program id is one of those.
InterfaceAccount: Account container that checks ownership on deserialization
This is the account version of "interface". Anchor will check that the account is owned by one of the programs specified in the interface. In the token example, it'll check that the account is owned by SPL Token or SPL Token 2022, and return an error if it's owned by some other program.