🚀

Module M000

Cardano Background & Development Setup

Duration: 2 hours

Format: 1 hour lecture + 1 hour hands-on

DirectEd x CATS Hackathon Aiken Development Workshop

SLIDE 1

Your Instructor

John Ndigirigi

John Ndigirigi

Cardano blockchain developer and educator specializing in Aiken smart contract development.

𝕏

@ndigirigi__john

Follow on X
in

linkedin.com/in/ndigirigijohn

Connect on LinkedIn
SLIDE 2

Module Overview

Welcome to your first step in Cardano blockchain development!

What You'll Learn

  • Blockchain accounting models
  • Cardano's unique eUTxO system
  • Native assets on Cardano
  • Development environment setup
  • Writing your first Aiken tests

Prerequisites

✓ Basic programming knowledge

✓ Computer with internet access

✓ Willingness to learn!

Goal: Understand what makes Cardano different and prepare your development environment for writing smart contracts
SLIDE 3

Learning Objectives - Part 1

1. Blockchain Fundamentals

  • Understand UTxO vs Account-based models
  • Learn Cardano's eUTxO (Extended UTxO) model
  • Recognize native assets on Cardano
  • Learn about CIPs (Cardano Improvement Proposals)
  • Understand wallets and transactions
  • Grasp functional programming principles
SLIDE 4

Learning Objectives - Part 2

2. Development Environment Setup

  • Install Aiken development tools
  • Configure Visual Studio Code
  • Clone and navigate course repository
  • Run your first Aiken tests
  • Understand Aiken project structure
Let's dive into the blockchain fundamentals! đŸŽ¯
SLIDE 5

Understanding Blockchain Accounting Models

Blockchains track ownership using two main models:

Account-Based Model

Used by: Ethereum

đŸ’ŗ Like a bank account

📊 Tracks account balances

🔄 Modifies balances directly

Example:
"Ali has $20 in his account,
take $5 from it"

UTxO Model

Used by: Bitcoin, Cardano

đŸ’ĩ Like physical cash

📝 Tracks unspent outputs

🔀 Consumes inputs, creates outputs

Example:
"Ali has this $20 bill,
give it and get $15 change"
SLIDE 6

UTxO Model Visualization

Transaction Flow in UTxO Model

INPUT
UTxO: 20 ADA

Unspent Output

→
TRANSACTION
Spend 5 ADA

Processing

→
OUTPUT 1
5 ADA
(to recipient)
OUTPUT 2
15 ADA
(change)

New UTxOs

Key Insight: Original UTxO is completely consumed. New UTxOs are created as outputs.
SLIDE 7

Why UTxO Matters for Smart Contracts

Key Benefits

đŸŽ¯ Deterministic

Know exactly which UTxOs you're spending before submitting

⚡ Parallel Processing

Different UTxOs can be processed simultaneously

💾 Local State

Each UTxO carries its own data (datum)

Smart Contract Concept

In Cardano smart contracts, you validate whether specific UTxOs can be spent, rather than modifying account balances.

"Can this UTxO be spent given these conditions?"

✓ Valid → Transaction proceeds
✗ Invalid → Transaction rejected

SLIDE 8

Cardano's eUTxO: Extended UTxO Model

Cardano enhances Bitcoin's UTxO model with powerful smart contract capabilities

The Evolution: UTxO → eUTxO

Bitcoin's UTxO
Basic Model
+

Enhancements:

â€ĸ Datums

â€ĸ Redeemers

â€ĸ Script Context

=
Cardano's eUTxO
Smart Contracts!
Result: Bitcoin's security + Ethereum's smart contract power!
SLIDE 9

Key Enhancements in eUTxO

1. Datums (Custom State)

Each UTxO can carry custom data
💡 Think of it as attaching a note to a dollar bill
Example: An NFT UTxO carries metadata about the artwork

2. Redeemers (Spending Arguments)

Arguments provided when spending a UTxO
🔑 Like showing proof you're allowed to spend
Example: Providing a password or proof of ownership

3. Script Context (Transaction Awareness)

Validators can see the entire transaction
đŸ‘ī¸ Includes inputs, outputs, signatories, time ranges
Enables: Complex validation based on transaction structure

4. Deterministic Validation

Check if transaction will succeed BEFORE submitting
✅ Reduces failed transactions and wasted fees
Benefit: More predictable dApp development

SLIDE 10

Real-World Analogy: The Smart Safe

Basic UTxO

📨

Sending cash in an envelope

  • Contains money
  • Basic transaction
  • Simple to open

eUTxO

🔐

Sending cash in a smart safe

  • Has custom data written on it (datum)
  • Requires specific conditions to open (validator)
  • Can check who's opening it and when (context)
  • Needs the right key or code (redeemer)
Key Insight: eUTxO gives you Bitcoin's security and determinism PLUS Ethereum's smart contract expressiveness!
SLIDE 11

The Smart Contract Trinity

On Cardano, smart contracts involve three key components:

đŸ“Ļ

DATUM

The data locked at the script address

Example: "Auction ends at 5pm"

🔑

REDEEMER

The argument provided when spending

Example: "I'm bidding 100 ADA"

🔍

SCRIPT CONTEXT

The transaction information

Time, signers, inputs, outputs

In Aiken: You'll write validators that receive datums, redeemers, and script context as parameters, and return True (valid) or False (invalid)

SLIDE 12

Native Assets on Cardano

On Cardano, tokens are "native assets" - handled directly by the blockchain ledger, not by smart contracts.

Feature Cardano (Native) Ethereum (ERC-20)
Implementation Built into ledger ✅ Requires smart contract
Complexity Simple ✅ More complex
Security High (ledger-level) ✅ Depends on contract code
Transaction Cost Lower ✅ Higher (gas for contract)
Ownership Direct ledger entry ✅ Contract manages ownership
Why This Matters: When you own a token on Cardano, you directly own it - only you can spend it. No smart contract needs to be called to transfer tokens, making it more secure and efficient!
SLIDE 13

Types of Native Assets

💰

Fungible Tokens

Each unit is identical

Examples:

ADA (Cardano's native currency)

USD coins

Loyalty points

1 token = 1 token
Interchangeable

🎨

Non-Fungible Tokens (NFTs)

Each token is unique

Examples:

Digital artwork

Collectibles

Property deeds

Each token is different
Not interchangeable

SLIDE 14

Cardano Improvement Proposals (CIPs)

CIPs are formal design documents that propose changes or standards for Cardano

Types of CIPs

📋 Standards Track CIPs

Core protocol changes

  • CIP-25: NFT Metadata Standard
  • CIP-30: Wallet API Standard

âš™ī¸ Process CIPs

Community practices

  • How to submit a CIP
  • Governance procedures

â„šī¸ Informational CIPs

Guidelines & recommendations

  • Best practices
  • Educational content

Why CIPs Matter

✓ Community-driven evolution

✓ Standardized approaches

✓ Reference for developers

✓ Transparent process

🔗 Find CIPs at:
cips.cardano.org

SLIDE 15

Wallets and Transactions

What is a Wallet?

A Cardano wallet is software that helps you:

đŸ—ī¸ Build transactions

âœī¸ Sign transactions with private keys

📤 Submit transactions to blockchain

Note: In this course, we'll simulate transactions in tests. In production, wallets handle building, signing, and submission.

Transaction Flow

1. User Action
↓
2. Wallet Builds Transaction
Selects UTxOs, defines outputs, calculates fees
↓
3. User Signs Transaction
Private key signature proves ownership
↓
4. Wallet Submits to Network
Transaction validated and added to blockchain
SLIDE 16

Transaction Analogy: Online Shopping

Think of using Cardano like online shopping:

đŸ›ī¸

Browse

User selects items

(Decides what to do)

🛒

Cart

Items added to cart

(Transaction being built)

đŸ’ŗ

Checkout

Payment with Cardano

(Wallet signs and submits)

✅

Confirmation

Order confirmed

(Transaction on blockchain)

SLIDE 17

Functional Programming and eUTxO

Cardano smart contracts use functional programming because it naturally matches the eUTxO model

Think About Algebra

Simple Function:

y = 3x
  • Input: x
  • Process: multiply by 3
  • Output: y

Multiple Inputs:

y = a + b + c

Function Composition:

y = 3x
z = y + 5

Transactions as Functions

Every Cardano transaction is like a mathematical function:

transaction(inputs, redeemers, context)
→ outputs

Where:
â€ĸ inputs = UTxOs to spend (each with datum)
â€ĸ redeemers = arguments proving right to spend
â€ĸ context = full transaction information
â€ĸ outputs = new UTxOs to create
â€ĸ Fee = sum(inputs) - sum(outputs)

SLIDE 18

Functional Programming Principles

Pure Functions

Same input always gives same output
đŸŽ¯ Predictable and testable

Immutability

Data doesn't change, new data is created
🔒 No unexpected modifications

No Side Effects

Functions don't modify external state
✨ Everything is explicit

Why This Fits Cardano

  • UTxOs are immutable
  • Validators are pure functions
  • No hidden state changes
  • Datums are immutable
  • Redeemers are input arguments

In Aiken

You'll write validators as pure functions that:

  • Receive datum, redeemer, context
  • Return True (valid) or False (invalid)
  • Have no side effects
  • Are deterministic
SLIDE 19

Part 2: Development Environment Setup

âš™ī¸

Now let's get your development environment ready!

What We'll Install

  • Aiken toolchain
  • Visual Studio Code
  • Aiken VS Code extension
  • Git (for version control)

What You'll Learn

  • Create Aiken projects
  • Write and run tests
  • Understand project structure
  • Debug with trace messages
Duration: This section takes about 60-70 minutes including hands-on practice
SLIDE 20

Installing Aiken

Aiken is the programming language and toolchain for Cardano smart contracts

Prerequisites

✓ Node.js and npm (v16+ and 8+)

✓ Git (v2+)

✓ Visual Studio Code

Verify Installations

node --version
npm --version
git --version

Installation Steps

1. Install aikup

npm install -g @aiken-lang/aikup

2. Install Aiken

aikup install latest

3. Verify

aiken --version
# Should show v1.1.7 or higher

🔗 Detailed instructions: aiken-lang.org/installation-instructions

SLIDE 21

Visual Studio Code Setup

Installing Aiken Extension

  1. Open Visual Studio Code
  2. Click Extensions icon (or Ctrl+Shift+X)
  3. Search for "Aiken"
  4. Click "Install" on official extension
đŸ’ģ

Look for the official Aiken extension with the Aiken logo

Features You'll Get

✅ Syntax highlighting for .ak files

✅ Code completion and IntelliSense

✅ Real-time error checking

✅ Inline documentation

✅ Automatic formatting on save

SLIDE 22

Creating Your First Aiken Project

Step 1: Create Development Folder

# Create in home directory
mkdir ~/cardano-dev
cd ~/cardano-dev

Step 2: Create New Aiken Project

# Create project called "hello-aiken"
aiken new hello-aiken

# Navigate into project
cd hello-aiken

Step 3: Open in VS Code

code .

This opens the entire project with syntax highlighting ready!

SLIDE 23

Understanding Aiken Project Structure

Project Files & Folders

hello-aiken/
├── aiken.toml
├── lib/
├── validators/
└── README.md

What Each Does

aiken.toml

Project configuration, dependencies, compiler settings

validators/

Smart contract validators - controls how UTxOs can be spent

lib/

Reusable code, helper functions, type definitions

README.md

Project documentation

SLIDE 24

Writing Your First Test

Create validators/hello.ak

// A simple function that returns true
test hello_world() {
True
}

// A test with basic math
test basic_math() {
let x = 5
let y = 10
x + y == 15
}

// A test with trace message
test with_trace() {
trace @"Hello from Aiken!"
True
}

Run Your Tests

aiken check

You should see all tests pass with memory and CPU usage!

SLIDE 25

Understanding Test Output

Successful Test Output

Testing hello-aiken

┍━ validators/hello ━━━━━━━━━━━━━━
│ PASS [mem: 100, cpu: 100] hello_world
│ PASS [mem: 200, cpu: 300] basic_math
│ PASS [mem: 150, cpu: 250] with_trace
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Summary
3 tests | 3 passed | 0 failed

What the Numbers Mean

mem: Memory units used
cpu: CPU steps consumed

These affect transaction costs on-chain

When Tests Fail

FAIL [mem: 1234, cpu: 456789]
✗ Assertion failed
Expected: True
Got: False
🎉

Congratulations! You've just run your first Aiken tests!

SLIDE 26

Debugging with Trace Messages

Trace messages help you debug and understand your code's execution

Example with Trace

test experiment() {
trace @"Testing a calculation"
let result = 7 * 6
trace @"Result calculated"
result == 42
}

Run Specific Test

aiken check -m experiment

You'll see your trace messages in the output!

Tip: Use trace messages to see intermediate values and understand how your code executes. They're invaluable for debugging complex validators!
SLIDE 27

Hands-On Exercises

👨‍đŸ’ģ

Time to practice what you've learned!

Exercise 1 (10 min)

Environment Verification

Verify all tools are installed correctly

Exercise 2 (15 min)

Create First Project

Build workshop-m000 project with tests

Exercise 3 (15 min)

Experiment with Tests

Test different data types and operators

Exercise 4 (15 min)

Working with Traces

Add trace messages for debugging

Exercise 5 (10 min)

Project Organization

Create multiple validator files and organize code

SLIDE 28

Assignment M000

Objective

Set up your Aiken development environment, create your first project, and demonstrate understanding of Cardano fundamentals

Tasks

  1. Install Aiken and verify
  2. Install VS Code with Aiken extension
  3. Create project: m000-assignment
  4. Write minimum 5 passing tests
  5. Include tests with trace messages
  6. Test boolean, integer, comparison operations

What to Submit

  • Personal details
  • GitHub repository URL
  • Description of your work
  • What you learned
  • Challenges and solutions
  • Understanding of UTxO vs eUTxO
Deadline: Submit before Workshop M001 begins
SLIDE 29

Troubleshooting Common Issues

Issue: "aiken: command not found"

Add Aiken to your PATH:

echo 'export PATH="$HOME/.aiken/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Issue: Permission Denied Errors

Use sudo for npm install:

sudo npm install -g @aiken-lang/aikup

Issue: VS Code Extension Not Working

  • Ensure latest VS Code version
  • Restart VS Code after installing
  • Check extension is enabled
  • Open a .ak file to trigger activation

Need help? Check the Troubleshooting Guide in the module document or ask in the workshop Discord!

SLIDE 30

Additional Resources

📚 Documentation

  • Aiken Official Docs
  • Aiken Language Tour
  • Aiken Standard Library
  • Cardano Developer Portal

đŸŽĨ Videos

  • DirectEd YouTube Channel
  • Aiken Getting Started tutorials
  • Cardano Fundamentals series

đŸ‘Ĩ Community

  • Workshop Discord Server
  • Cardano Forum
  • Aiken GitHub

📖 Further Reading

  • CIP-25: NFT Metadata Standard
  • CIP-30: Cardano dApp-Wallet Bridge
  • UTxO Model: Bitcoin whitepaper
  • EUTxO Paper: Extended model
SLIDE 31

Key Takeaways

By completing this module, you should now:

✅ Understand why Cardano uses the UTxO model

✅ Know how eUTxO extends UTxO with datums, redeemers, and script context

✅ Know what makes native assets special on Cardano

✅ Recognize how CIPs drive Cardano's evolution

✅ Have a working Aiken development environment

✅ Be able to run and modify Aiken tests

✅ Understand basic Aiken project structure

✅ Be ready to write your first smart contract in M001

SLIDE 32

What's Next: Module M001

🚀

Writing Your First Smart Contract

In the next module, you'll write your first Aiken validator - a smart contract that controls how funds can be spent on Cardano.

You'll learn about:

  • Validator structure and syntax
  • Type signatures in Aiken
  • Working with datums and redeemers
  • Testing contracts with mock transactions
  • Building your first working validator

Questions?

Ask in the workshop chat, visit office hours, or post in the workshop Discord server!

SLIDE 33
🎉

Thank You!

Module M000 Complete

DirectEd x CATS Hackathon

Aiken Development Workshop

See you in Module M001! 🚀

/ 34