Day 12 of RareSkills Solana Course.
- Configure Solana to run on localhost:
solana config set --url localhost
- Run the test validator node on another terminal:
solana-test-validator
- Run Solana logs on another terminal:
solana logs
- Build Anchor program:
anchor build
- Sync program_id with Anchor key:
anchor keys sync
- Run tests:
anchor test --skip-local-validator
sysvars
areread-only system accounts
that giveSolana programs
access to theblockchain state
, as well asnetwork information
.- in
Anchor programs
, sysvars can be accessed in two ways:- using
Anchor's
get method wrapper. - treating it as an account in the
#[Derive(Accounts)]
using its public address.
- using
- Here are a list of
sysvars
:Clock:
Used for time-related operations like getting the current time or slot number.EpochSchedule:
Contains information about epoch scheduling, including the epoch for a particular slot.Rent:
Contains the rental rate and information like the minimum balance requirements to keep an account rent exempt.Fees:
Contains the fee calculator for the current slot. The fee calculator provides information on how many lamports are paid per signature in a Solana transaction.EpochRewards:
The EpochRewards sysvar holds a record of epoch rewards distribution in Solana, including block rewards and staking rewards.RecentBlockhashes:
Contains the active recent block hashes.SlotHashes:
Contains history of recent slot hashes.SlotHistory:
Holds an array of slots available during the most recent epoch in Solana, and it is updated every time a new slot is processed.StakeHistory:
maintains a record of stake activations and deactivations for the entire network on a per-epoch basis, which is updated at the beginning of each epoch.Instructions:
To get access to the serialized instructions that are part of the current transaction.LastRestartSlot:
Contains the slot number of the last restart (the last time Solana restarted ) or zero if none ever happened. If the Solana blockchain were to crash and restart, an application can use this information to determine if it should wait until things stabilize.
- A
slot
is a window of time (around400 ms
) where a designated leader can produce a block. - A
slot
might not contain ablock
if the block leader failed to produce a block during that slot.