My attempt at learning Solana program (smart contract) development through RareSkill's Solana course.
Originally, I was trying to create a single anchor project and add the daily exercises under
programs
(programs/day_1
,programs/day_2
,programs/day_x
), but this made following along with the tutorial harder (longer running tests, Anchor not supporting deployment/testing of individual programs out of the box).
- Day 1: Hello World (and troubleshooting Solana installation)
- Day 2: Function arguments, math, and arithmetic overflow
- Day 3: Anchor function magic and the Interface Definition Language
- Day 4: Solana reverts, errors, and basic access control
- Day 5: Where is the constructor? About anchor deploy
- Day 6: Solidity Translations to Rust and Solana
- Day 7: The unusual syntax of Rust
- Day 8: Understanding function-like macros in Rust
- Day 9: Rust Structs and Attribute-like and Custom Derive Macros
- Day 10: Translating Solidity function visibility and contract inheritance to Solana
- Day 11: Block variables in Solana: block.timestamp and block.number and others
- Day 12: Beyond the block: Sysvars
- Day 13: Native Programs: Sysvars
- Day 14: tx.origin, msg.sender, and onlyOwner in Solana
- Day 15: Transaction fees and compute units
- Day 16: Accounts in Solana
- Day 17: Writing to storage
- Day 18: Reading Accounts from Typescript — an alternative to public variables and view functions
For the initial setup of dependencies required for Solana program development, follow the day 1 tutorial.
Then for creating a new Anchor project:
- Initialize a project:
anchor init day_x
- Go to folder:
cd day_x
- Remove git repository:
rm -rf .git
(since60-days-of-solana
is the main git repository) - Follow the tutorial for each day
Here is a list of common issues that I've encountered while going through the tutorials and how to resolve them.
-
Error: Deploying program failed: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: account data too small for instruction
To resolve this:
- Delete
day_x/target/deploy
- Build Anchor program:
anchor build
- Sync keys:
anchor keys sync
- Redeploy or retest:
anchor deploy
oranchor test
- Delete