I know what procedural macros are. They are like decorators, they add new functionality or properties into the decorated code.

pub base_account:Account<'info,BaseAccount>,

I can understand above code that is initializing a new account. (Although I don't know what exactly the account do)

However, I do not understand this:

pub user:Signer<'info>,

I cannot interpret anything and mut is extra confusing.

1 Answer 1


mut is one of many constraints that go with the #[account()] attribute. It specifies that the instruction be allowed to modify the account's data. If an account isn't given the mut attribute in a validator then it won't be modifiable in the instruction, either to change its custom data or token balance. Here it's used because the user account pays for the initialization of base_account

Here's a full list of anchor_lang's constraints.

  • 1
    Nice, I would like to add that the reasoning behind having mut and non-mut accounts, is a hint for Solana to know which accounts can be processed in parallel. If something is read only there is no need of mutexes etc.. And as to why a payer is mut as Ademola said it's because your user account is the payer and so its lamports field need to be mutable.
    – mwrites
    Aug 30, 2022 at 22:54

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.