Voltar
+20 XP
8/16
Challenge: Wire Up Initialize
This challenge is different. The starter code has a deliberate bug — it won't compile.
Your job:
- Click Build to see the compiler error
- Read the error message carefully
- Fix the code
- Build again until it compiles
The Bug
The Initialize struct uses #[account(init, ...)] to create a Counter PDA, but it's missing a required account. When Anchor generates the account creation code, it needs the System Program to execute the create_account instruction.
What You'll Learn
This is the most common Anchor compile error you'll encounter in the wild. Learning to diagnose it now saves you hours of debugging later.
Requirements
- Read the compiler error output
- Add the missing account to
Initialize - Make sure
initializesetscounter.count = 0andcounter.authority = ctx.accounts.user.key()
Casos de Teste
Program compiles successfully
Entrada:
Esperado: trueInitialize struct includes system_program
Entrada:
Esperado: true