mocha
and@project-serum/anchor
must be globally installed vianpm i -g mocha @project-serum/anchor
. Local installation doesn't work.- Run a local Solana node using
solana-test-validator
. Kill the validator and reuse the terminal for anchor commands.
- Create project using
anchor init t1_basics
- Build project and generate IDL using
anchor build
- Deploy using
anchor deploy
- Add new program to workspace using
anchor new program_name
A test script is automatically created in tests folder.
- Run all tests using
anchor test
- Run specific test using
anchor test tests/t2_accounts.js
Data is stored on Solana in two ways:
-
Accounts:
- They hold persistent arbitary data, similar to files in Linux.
- Also contain metadata, which controls write access.
- Accounts need to pay a rent otherwise they are purged. Paying tokens above an amount makes the account rent exempt.
- Design pattern: Store user data on accounts. Try to keep programs stateless.