https://github.com/secretshardul/solana-anchor-tutorial
https://github.com/secretshardul/solana-anchor-tutorial
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/secretshardul/solana-anchor-tutorial
- Owner: secretshardul
- Created: 2021-05-22T08:39:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-22T08:41:48.000Z (about 5 years ago)
- Last Synced: 2025-12-12T21:35:04.878Z (7 months ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# solana-anchor-tutorial
## Setup and CLI usage
### 1. Prerequisites
- `mocha` and `@project-serum/anchor` must be globally installed via `npm 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.
### 2. Intializing project
1. Create project using `anchor init t1_basics`
2. Build project and generate IDL using `anchor build`
3. Deploy using `anchor deploy`
4. Add new program to workspace using `anchor new program_name`
### 3. Testing
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`
## Program structure
```
```
## Solala basics
### Data storage
Data is stored on Solana in two ways:
1. 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.
2.