Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 1.39 KB

README.md

File metadata and controls

30 lines (22 loc) · 1.39 KB

Day 3: Solana Anchor Program IDL

Day 3 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
  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: anchor build only affects lib.rs file.

To test the IDL output of non-empty-account.rs, replace the contents of lib.rs with the contents from non-empty-account.rs.

Notes

  • The Interface Definition Language (IDL) is a JSON file that describes how to interact with a Solana program.
  • The IDL is automatically generated by the Anchor framework.
  • An IDL file in Solana is similar to an ABI file in Solidity.
  • Rust functions are snake_cased, but Anchor formats the functions to camelCased for JavaScript.
  • Initialize is the default naming of the struct by Anchor, but you can rename it.
  • #[derive(Accounts)] adds accounts from the struct to the IDL accounts key.

References