2

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.

1 Answer 1

3

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.

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.