Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 1.6 KB

README.md

File metadata and controls

33 lines (24 loc) · 1.6 KB

Day 19: Creating “mappings” and “nested mapping” in Solana

Day 19 of RareSkills Solana Course.

Setup

  1. Configure Solana to run on localhost: solana config set --url localhost
  2. Run the test validator node on another terminal: solana-test-validator --reset
  3. Run Solana logs on another terminal: solana logs
  4. Build Anchor program: anchor build
  5. Sync program_id with Anchor key: anchor keys sync
  6. Run tests: anchor test --skip-local-validator

Note: to retest the programs and avoid failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0 error, comment out the initialize function call.

// await program.methods.initialize().accounts(...).rpc();

Notes

  • seeds=[] in init macro behave as keys that can be used for mappings.
    • keys that are used by init macro need to be in an instruction macro.
  • seeds=[] can have as many keys as the compute limit can support.
  • to_le_bytes() means to little endian bytes.
  • to_be_bytes() means to big endian bytes.

References