DUSKLINGS
1 / 14

The answer

Lines to add are green; lines to remove are red.


    

Smart contracts in Rust

The Hatchery

Write a Dusk Forge smart contract in Rust over five lessons: state, events, calls between contracts, block height and approvals.

Lesson 1: The Hatchery

  1. Dusk falls
  2. Contracts
  3. Constants and integers
  4. Math
  5. Structs
  6. Vectors
  7. Functions
  8. Making a Duskling
  9. Private functions
  10. Return values
  11. Mixing the seed
  12. Putting it together
  13. Event types
  14. Emitting events
  15. Hatch your Duskling

Lesson 2: Keepers

  1. Every Duskling needs a keeper
  2. Reading state
  3. Maybe there, maybe not
  4. Who's calling?
  5. Recording the keeper
  6. Whose is it?
  7. Counting with iterators
  8. One hatch per keeper
  9. Keepers of the harbor

Lesson 3: Moth hunt

  1. Something to eat
  2. Contract addresses
  3. Calling another contract
  4. Mixing DNA
  5. Moth-born
  6. Only your own Duskling
  7. The feast
  8. A second event type
  9. Telling the world
  10. The moth feast

Lesson 4: Night battles

  1. The Night Arena
  2. A place to rest
  3. The chain's clock
  4. Resting
  5. Don't repeat yourself
  6. Wins and losses
  7. Rolling the dice (sort of)
  8. Into the arena
  9. Win or lose
  10. Arena night

Lesson 5: Trading

  1. Trading day
  2. Handing it over
  3. A receipt
  4. Room for an approval
  5. Approving a keeper
  6. Collecting it
  7. The stale approval
  8. Trade day

All paths