Skip to main content
The Stellar team has put together a large collection of example contracts to demonstrate use of smart contracts on Stellar. For many of these example contracts, we’ve written an accompanying tutorial that will walk you through the example contract and describe a bit more about its design. The examples listed below are provided in a sequential manner. The first listed example contracts create a solid foundation of concepts that will be required during the later examples. While you are absolutely free to choose, read, and use any of the example contracts you like, please keep in mind that the order you see is intentional.

Storage

Increment a counter and store the incremented value

Events

Publish events from a smart contract.

Simple Account

A minimal contract account secured by a single ed25519 public key.

Complex Account

Implement a contract account with multisig and custom authorization policies.

BLS Signature

A contract account with BLS signature verification.

Delegate Auth

A custom account contract that uses CAP-71 auth delegation to forward __check_auth to registered delegate signers.

Custom Types

Define your own data structures in a smart contract.

Errors

Define and generate errors in a smart contract.

Logging

Debug a smart contract with logs.

Auth

Implement authentication and authorization.

Cross Contract Calls

Call a smart contract from another smart contract.

Deployer

Deploy and initialize a smart contract using another smart contract.

Allocator

Use the allocator feature to emulate heap memory in a smart contract.

Atomic Swap

Swap tokens atomically between authorized users.

Batched Atomic Swaps

Swap a token pair among groups of authorized users.

Mint Lock

Implement a contract that can delegate minting with limits.

Timelock

Lockup some token to be claimed by another user under set conditions.

Single Offer Sale

Make a standing offer to sell a token in exchange for another token.

Upgradeable Contract

Upgrading Wasm Bytecode for a Deployed Contract.

Liquidity Pool

Write a constant-product liquidity pool contract.

Tokens

Write a CAP-46-6 compliant token contract.

Fuzz Testing

Increase confidence in a contract’s correctness with fuzz testing.

Workspace

Develop multiple contracts side-by-side.