pub fn startstuffoff(ctx: Context<StartStuffOff>) -> Result<()> {
let base_account = &mut ctx.accounts.base_account;
base_account.total_gifs = 0;
Ok(())
}
pub fn add_gif(ctx: Context<AddGif>) -> Result<()> {
let base_account = &mut ctx.accounts.base_account;
base_account.total_gifs += 1;
Ok(())
}
>#[derive(Accounts)]<br>
pub struct StartStuffOff<'info> {<br>
#[account(init, payer = user, space = 10000)]<br>
pub base_account: Account<'info, BaseAccount>,<br>
#[account(mut)]<br>
pub user: Signer<'info>,<br>
pub system_program: Program <'info, System>,<br>
}<br>
>#[derive(Accounts)]<br>
pub struct AddGif<'info>{<br>
#[account(mut)]<br>
pub base_account: Account<'info, BaseAccount>,<br>
}<br>
>#[account]<br>
pub struct BaseAccount{<br>
pub total_gifs: u64,<br>
}<br>
I have followed the build space tutorial which is quite good. I'm just confused about the aspect where I need to use Signer, Account and base account and how it will be able to grant permission to our specific users to allow them to increment Gif counter in accounts.
Questions
- What's the difference between a Signer and Accounts?
- Where and when should they be used?
- What happens if I use one instead of the other?