Skip to main content
3 of 3
Code formatting.
steveluscher
  • 3.2k
  • 8
  • 38

Looks like they did not include the creation of the counter in the program but instead are handling it on the Client side using System Program. Take a look at the tests:

const allocIx: TransactionInstruction = SystemProgram.createAccount({
  fromPubkey: payer,
  newAccountPubkey: counter,
  lamports: await connection.getMinimumBalanceForRentExemption(
    COUNTER_ACCOUNT_SIZE
  ),
  space: COUNTER_ACCOUNT_SIZE,
  programId: PROGRAM_ID,
});

This is a little different than how they've implemented in the anchor example, where they've explicitly created an initialize function in the program:

pub fn initialize_counter(_ctx: Context<InitializeCounter>) -> Result<()> {
    Ok(())
}
AMilz
  • 1.9k
  • 3
  • 11