or Space · ⌘P pop out notes
Notes

Smart
Contracts
on Stellar

What they are, how they work,
and why they matter

Leigh McCulloch

Vending Machines

A vending machine
Step 1 of 4

Choose

A B C 1 2 3 B3
Step 2 of 4

The Price Is Shown

$2.00
Step 3 of 4

You Pay

$ $ $2.00
Step 4 of 4

Swap Complete

THANK YOU

The Ancestor of
Smart Contracts

Late 1800s vending machine
1880s — Vending machines appear. Automated agreements, no human in the middle.
1994 — Computer scientist Nick Szabo sees the connection.
He calls the vending machine the "ancestor of smart contracts" and coins the term.
14 years before Bitcoin. Even more before Ethereum.

What Is a
Smart Contract?

Take the vending machine pattern — an agreement that enforces itself.

Remove the physical machine. Just the logic.

Put it on a network of computers that nobody owns.

Now anyone, anywhere, can use it.

An agreement that enforces itself,
running on a computer nobody controls.

Step 1 of 4

Identify

SwapContract fn swap() fn price() fn balance() fn deposit() fn withdraw()
Step 2 of 4

Simulate

SwapContract fn swap() fn price() fn balance() fn deposit() fn withdraw() SIMULATE: swap(100 USDC) RESULT: 92 EURC
Step 3 of 4

Submit

TX TX SwapContract fn swap() fn price() fn balance() fn deposit() fn withdraw() 100 USDC + signature
Step 4 of 4

Execute

SwapContract fn swap() fn price() fn balance() fn deposit() fn withdraw() SUCCESS 92 EURC

The Stellar
Network

A blockchain founded in 2014, focused on payments and financial access. Think of it as a plaza where vending machines can be deployed.

2014
Founded
~5s
Settlement
<$0.01
Per Txn
Global
Access

Stellar's OG
Vending Machine

Fixed vending machine
  • 26 built-in operations — send payments, create offers, manage trust
  • A built-in decentralized exchange
  • Like a machine with 26 preset buttons
  • Useful — but you couldn't add new buttons
  • Want something not on the menu? Convince the whole network to add a 27th button

Soroban:
The Programmable
Machine

February 2024 — Live on Stellar
  • Soroban — Stellar's smart contract platform
  • Written in Rust, compiled to WebAssembly
  • Anyone can build a new machine with custom rules
  • Not just 26 buttons — unlimited possibilities
  • The old preset buttons still work too
Programmable vending machine

Was Stellar the First
Smart Contract Blockchain?

No.

Lifecycle of Smart
Contract Development

1. Write
Code + Tests
2. Audit
Review +
Verify
3. Compile
.wasm file
4. Upload
To the network
5. Deploy
Create an instance
6. Use
Call, interact, compose

Lifecycle of Smart
Contract Development

1. Write
Code + Tests
2. Audit
Review +
Verify
3. Compile
.wasm file
4. Upload
To the network
5. Deploy
Create an instance
6. Use
Call, interact, compose

Lifecycle of Smart
Contract Development

1. Write
Code + Tests
2. Audit
Review +
Verify
3. Compile
.wasm file
4. Upload
To the network
5. Deploy
Create an instance
6. Use
Call, interact, compose

Lifecycle of Smart
Contract Development

1. Write
Code + Tests
2. Audit
Review +
Verify
3. Compile
.wasm file
4. Upload
To the network
5. Deploy
Create an instance
6. Use
Call, interact, compose

Lifecycle of Smart
Contract Development

1. Write
Code + Tests
2. Audit
Review +
Verify
3. Compile
.wasm file
4. Upload
To the network
5. Deploy
Create an instance
6. Use
Call, interact, compose

Lifecycle of Smart
Contract Development

1. Write
Code + Tests
2. Audit
Review +
Verify
3. Compile
.wasm file
4. Upload
To the network
5. Deploy
Create an instance
6. Use
Call, interact, compose
CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC

Lifecycle of Smart
Contract Development

1. Write
Code + Tests
2. Audit
Review +
Verify
3. Compile
.wasm file
4. Upload
To the network
5. Deploy
Create an instance
6. Use
Call, interact, compose
CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC

The Building
Blocks

Every contract has some common components.

Logic
The rules. What happens when you push a button.
Storage
The machine's memory. Instance, persistent, or temporary.
Auth
require_auth() — verify who's pushing the button.
Events
Receipts. A log of everything that happened.
Cross-Call
Machines can call other machines.

The Building
Blocks

Every contract has some common components.

Logic
The rules. What happens when you push a button.
Storage
The machine's memory. Instance, persistent, or temporary.
Auth
require_auth() — verify who's pushing the button.
Events
Receipts. A log of everything that happened.
Cross-Call
Machines can call other machines.

The Building
Blocks

Every contract has some common components.

Logic
The rules. What happens when you push a button.
Storage
The machine's memory. Instance, persistent, or temporary.
Auth
require_auth() — verify who's pushing the button.
Events
Receipts. A log of everything that happened.
Cross-Call
Machines can call other machines.

The Building
Blocks

Every contract has some common components.

Logic
The rules. What happens when you push a button.
Storage
The machine's memory. Instance, persistent, or temporary.
Auth
require_auth() — verify who's pushing the button.
Events
Receipts. A log of everything that happened.
Cross-Call
Machines can call other machines.

The Building
Blocks

Every contract has some common components.

Logic
The rules. What happens when you push a button.
Storage
The machine's memory. Instance, persistent, or temporary.
Auth
require_auth() — verify who's pushing the button.
Events
Receipts. A log of everything that happened.
Cross-Call
Machines can call other machines.

The Building
Blocks

Every contract has some common components.

Logic
The rules. What happens when you push a button.
Storage
The machine's memory. Instance, persistent, or temporary.
Auth
require_auth() — verify who's pushing the button.
Events
Receipts. A log of everything that happened.
Cross-Call
Machines can call other machines.

How a Contract Works

Contract Logic (rules) State (storage) mutate Inputs auth args Outputs result events

Why Do Smart
Contracts Matter?

SDF Mission

Create equitable access
to the global financial system.

Smart contracts let anyone build the financial services that make this possible.

Examples

Tokens
Create and manage any digital asset
Swaps
Exchange one asset for another
Lending
Borrow and lend with programmable terms
Liquidity
Pool assets so anyone can trade
Insurance
Automated payouts when conditions are met
Payments
Programmable money flows and splits
Savings
Earn yield on deposited assets
Escrow
Hold funds until conditions are met
Payroll
Automated recurring distributions
Crowdfund
Raise capital with transparent rules
Invoicing
Programmable billing and settlement
Custody
Multi-sig and programmable access control

Tokens Can
Represent Anything

Same interface. Same transfer, balance, approve. Different meaning.

USDC
US dollars, on-chain. Redeemable 1:1.
LOYALTY
Reward points. Earn, transfer, redeem.
TICKET
Event access. Verifiable, tradeable.
SHARE
Ownership. Dividends, voting rights.

One machine pattern.
Infinite use cases.

Examples on Stellar

Blend
Lending
Soroswap
Swaps
Sushi
Swaps
Reflector
Price Oracle
Axelar
Bridge
FxDAO
Stablecoin
Soroban Domains
Naming Service
Kale
Mining Game
DeFindex
Index Vaults
Soroswap Aggregator
DEX Aggregator
Batch Executor
Batch Operations
...

A small sample — many more are live and being built

Tokens
Create and manage any digital asset
Swaps
Exchange one asset for another
Lending
Borrow and lend with programmable terms
Liquidity
Pool assets so anyone can trade
Insurance
Automated payouts when conditions are met
Payments
Programmable money flows and splits
Savings
Earn yield on deposited assets
Escrow
Hold funds until conditions are met
Payroll
Automated recurring distributions
Crowdfund
Raise capital with transparent rules
Invoicing
Programmable billing and settlement
Custody
Multi-sig and programmable access control
Voting
Transparent, auditable governance
Supply Chain
Track provenance, each step immutable
Gaming
In-game items as real tradeable tokens
Identity
Prove things without revealing everything

Recap

Vending Machine Rules in hardware Self-enforcing No middleman Smart Contract Rules in code On a network nobody owns Anyone can use it Write → Audit → Compile Upload → Deploy → Use Unlocked Services Tokens Swaps Lending Liquidity Payments Insurance Voting Identity ...and anything with rules Stellar Network SDF mission: equitable access to the global financial system

Questions?

developers.stellar.org