2

The docs.rs page mentions:

Consider using the Signer type if you would only have this constraint on the account.

What would be some examples where you would want to use the #[account(signer)] constraint instead of the Signer account type?

For example, when would you use something like this:

#[account(signer, <other constraints>)]
pub signer: SystemAccount<'info> // what other account types would require signing? maybe PDAs?

vs:

#[account(<other constraints>)]
pub signer: Signer<'info>

1 Answer 1

3

I think it's a style preference since both do the same thing.

With #[account(signer)] and AccountInfo you will also have to include the CHECK: rustdoc comment to explain why you're using an unsigned account. But it makes things easier when I have to get the account info later in my program.

Rather than having a Signer Account type, I'll have to perform a to_account_info and clone the account in order to use/check account information. This also improves DX since I instantly know that this is the signer.

P.S this is prior to anchor 0.29.0

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.