CHALLENGES
Standalone coding challenges to sharpen your Solana skills.
Associated Token Constraint
Ensure a given token account is the valid ATA for a user.
Associated Token Constraint
Ensure a given token account is the valid ATA for a user.
Custom Errors
Define custom error codes using Anchor's error! macro.
Account Discriminator Checking
Anchor checks 8-byte discriminators automatically to stop type cosplay. How do you do it manually?
Keccak256 Hash
Hash arbitrary data on-chain using Keccak256.
CPI Signer Seeds
Sign a CPI call with a PDA.
Non-Transferable Mint
Create soulbound tokens that cannot be sent to others.
Immutable Owner Extension
Prevent token account ownership from being transferred.
Token-2022 Memo Transfer
Require all token transfers to include a memo.
Set Return Data
Return arbitrary bytes to the caller of your program.
Fallback Instruction
Handle unknown instruction discriminators dynamically.
System Transfer CPI
Transfer native SOL via System Program.
Token Burn CPI
Burn SPL tokens via CPI.
Token Mint CPI
Mint new SPL tokens via CPI.
Token Transfer CPI
Transfer SPL tokens via Cross-Program Invocation.
Mint Constraint
Verify specific properties of a Token Mint account.
Owner Constraint
Verify that an account is owned by a specific program.
Address Constraint
Hardcode a specific required public key for an account.
Has One Constraint
Ensure an account field matches another passed-in account.
PDA Bump Constraint
Store and verify the bump seed on an initialized PDA.
PDA Seeds
Derive a Program Derived Address using static strings.
Realloc Constraint
Dynamically increase the size of an existing account.
Init Constraint
Initialize a brand new account.
Signer Constraint
Ensure a transaction was signed by a specific account.
Mut Constraint
Mark an account as mutable so state changes persist.
Unchecked Accounts
Safely declare accounts where you manually verify properties.
Account Loader
Load zero-copy accounts using AccountLoader.
Zero Copy Deserialization
Bypass Borsh serialization constraints for massive accounts by reading bytes directly.
Box Large Accounts
Prevent stack overflow errors on huge accounts by boxing them.
Init Space: Vector
Calculate space for a Vec of u64s.
Init Space: String
Calculate space for a String of known maximum length.
Init Space: u64
Calculate exact account size for an account storing a u64.
Init Space: Pubkey
Calculate exact account size for an account storing a single Pubkey.
Epoch Schedule Sysvar
Fetch information about the current epoch schedule.
Rent Sysvar (Exemption)
Calculate minimum balance for rent exemption programmatically.
Clock Sysvar (Time)
Read the current network timestamp directly inside your instruction.
Error Macro Return
Return an error early using the err! macro.
Message Macro Logging
Log messages and variables to the Solana program logs.
Require Greater Than or Equal
Assert one value is greater than or equal to another.
Require Greater Than
Assert one value is strictly greater than another.
Require Equal Values
Assert two numeric values are equal.
Require Keys Not Equal
Assert two pubkeys are strictly different using Anchor's macro.
Require Keys Equal
Assert two pubkeys are identical using Anchor's built-in macro.
Checked Math: Division
Prevent divide-by-zero panics using checked division.
Checked Math: Multiplication
Prevent integer overflow using checked multiplication.
Checked Math: Subtraction
Prevent integer underflow vulnerabilities using checked subtraction.
Checked Math: Addition
Prevent integer overflow vulnerabilities by using checked math instead of standard addition.
Create Associated Token Account
Create an Associated Token Account (ATA) for a user using Anchor's init_if_needed. ATAs are the standard way to hold tokens on Solana.
Prevent Close Account Attack
Fix a vulnerable close_account instruction that doesn't properly zero out account data. Apply the secure closing pattern to prevent state reuse attacks.
Emit Anchor Events
Add structured event emission to an Anchor program using the emit! macro. Events are the primary way to index on-chain activity for frontends and analytics.
Token-2022 Transfer Fee Extension
Configure a Token-2022 mint with a transfer fee extension. Every time tokens move, a percentage goes to the fee authority. The foundation of protocol revenue on Solana.