All lessons

Work through them in order, or jump to what you need.

Smart contract fundamentals

  1. Your first contract: storageA contract is a Python module whose functions the chain can call. State lives in storage — and storage holds bytes, nothing else. ⌨ exercise 8m
  2. Numbers in a bytes-only storeStorage holds bytes, but contracts count things. The conversion pattern below is used by every Animica contract, including the token standard. ⌨ exercise 10m
  3. Failing correctly: require and revertA contract that accepts bad input corrupts its own state forever. abi.require is how you refuse. ⌨ exercise 8m
  4. Who is calling: abi.caller and ownershipWithout knowing the caller, every function is public to everyone. This is how access control works. ⌨ exercise 10m
  5. Events: telling the outside worldStorage is what your contract knows. Events are what it announces. Indexers, wallets and explorers read events, not storage. ⌨ exercise 8m
  6. Mappings: many values, one namespaceThere is no dict in storage. You build one by composing keys — and the prefix you choose is a security boundary. ⌨ exercise 9m
🚀

Compile, deploy, call

  1. Install the CLIOne pip package ships the wallet, the node runner, the contract tooling and the miner. 5m
  2. The manifest: how the chain knows your ABIYour .py file is the code. The manifest declares what the outside world may call, and with what types. 9m
  3. CompileTurn source into an artifact with a code hash. This is also your first real correctness check. 6m
  4. Deploy, then callPut the artifact on-chain, then read from it for free and write to it with a transaction. 12m
  5. Inclusion is not executionThe single most expensive misunderstanding in blockchain integration work — and it is not specific to Animica. 7m
🧠

The AI network

  1. The free inference networkAn OpenAI-compatible endpoint with no API key. What it is, what it costs, and why the first call is slow. 7m
  2. Prompting that survives a small modelTechniques that matter more, not less, when the model is small and the latency is high. 10m
  3. Streaming, and designing for slowTwenty seconds of blank screen feels broken. The same twenty seconds with tokens arriving feels fast. 9m
  4. Where AI can and cannot goA contract may commission inference but never receive the answer in the same breath. Understanding why explains most of the AICF design. 8m
  5. Put it together: an agent that pays for what it usesDiscovery, price comparison and payment — the loop that makes an autonomous agent more than a chatbot. 12m
🪙

Build a token, step by step

  1. A token, part 1: balances and transferMint, read a balance, move value between accounts. This is the core every fungible token shares. ⌨ exercise 14m
  2. A token, part 2: allowancesLetting a third party spend on your behalf — the mechanism every exchange and marketplace depends on, and its famous footgun. ⌨ exercise 14m
  3. A token, part 3: caps and burningA maximum supply is a promise. Enforce it in code, because that is the only place anyone can verify it. ⌨ exercise 11m
  4. Handing over the keys safelyOne-step ownership transfer means one typo loses the contract forever. Two steps make the mistake recoverable. ⌨ exercise 10m
🧰

Build real things

  1. Escrow: holding value between strangersA buyer, a seller, and a contract that will only ever do one of two things with the money. ⌨ exercise 15m
  2. Multisig: M-of-N approvalNo single key can act alone. The pattern behind every treasury that has not been drained by one compromised laptop. ⌨ exercise 16m
  3. A name registryFirst come, first served — and the transfer rules that decide whether a name is really yours. ⌨ exercise 12m
  4. Voting that cannot be voted twiceProposals, a deadline, one vote per address, and a result nobody can quietly change afterwards. ⌨ exercise 14m
⛓️

Working with the chain

  1. Reading the chainTwo free, no-auth ways to ask the network what is true — and the small mistakes that make each one fail. 11m
  2. Addresses, and the signatures behind themWhy Animica addresses look the way they do, and why the signature scheme is unusual — and larger than you expect. 12m
  3. Sending a transaction, and knowing it workedThe full lifecycle with real timings, measured by paying out this academy's own lesson rewards. 13m
🔐

Patterns worth knowing

  1. Hashing, and which one actually worksA one-way fingerprint of any data. The building block for commitments, ids and integrity checks — with one important footgun on this chain. ⌨ exercise 10m
  2. Commit-reveal: keeping a secret on a public chainEverything in storage is public forever. This is how you run a secret ballot anyway. ⌨ exercise 16m
  3. Vesting: paying out over timeA cliff, then a straight line. The arithmetic that governs most team and investor allocations. ⌨ exercise 14m
🛡

Security and composition

  1. caller vs tx_origin: the authorization bugTwo functions that look interchangeable. Using the wrong one hands your contract to anyone who can get you to click something. ⌨ exercise 12m
  2. A contract that asks for inferenceA contract cannot receive a model's answer — but it can commission one deterministically. Including what that primitive does and does not do today. ⌨ exercise 11m
  3. Calling other contracts, and reentrancyThe moment your contract calls another one, it can be re-entered before it finishes. Order your writes accordingly. 13m
  4. Why the VM takes things away from youEvery restriction in the contract VM traces back to one requirement: every node must compute the identical result, forever. 10m
  5. Testing before you deployDeployed code is permanent and public. Everything you can find locally costs nothing to fix. 11m