Learn SIMPLICITY with Real Code Examples
Updated Nov 25, 2025
Code Sample Descriptions
1
Simplicity Minimal Contract Example
// Define a contract that locks funds until a condition is met
contract lockFunds {
input: signature sig, condition cond
output: funds released if cond(sig) == true
}
A minimal example illustrating a composable financial contract in Simplicity.
2
Simplicity Basic Escrow
contract escrow {
input: sig senderSig, sig recipientSig
output: funds released if verify(senderSig) && verify(recipientSig)
}
Funds are released to a recipient only if both parties sign.
3
Simplicity Time-Lock Contract
contract timelock {
input: currentBlockTime
output: funds released if currentBlockTime >= lockTime
}
Funds are locked until a specific block time is reached.
4
Simplicity Multi-Signature Wallet
contract multisig {
input: sigs[3]
output: funds released if count_valid(sigs) >= 2
}
Releases funds only if multiple signatures approve.
5
Simplicity Conditional Payment
contract conditionalPay {
input: sig payerSig, data d
output: funds released if validate(d) && verify(payerSig)
}
Transfers funds only if a condition on input data is satisfied.
6
Simplicity Atomic Swap
contract atomicSwap {
input: hash preimage, sig senderSig, sig receiverSig
output: funds released if hash(preimage) == knownHash && verify(senderSig) && verify(receiverSig)
}
Enables atomic swap between two parties using hash preimage.
7
Simplicity Escrow with Timeout
contract escrowTimeout {
input: sig senderSig, sig recipientSig, currentBlockTime
output: funds released to recipient if verify(recipientSig) || refunded to sender if currentBlockTime >= timeout
}
Funds can be claimed by recipient or refunded after timeout.
8
Simplicity Crowdfunding Contract
contract crowdfunding {
input: sig contributorSig, amount, totalRaised
output: release to owner if totalRaised >= goal else refundable to contributors
}
Funds are released to project owner only if funding goal is reached.
9
Simplicity Token Vesting
contract vesting {
input: currentBlockTime
output: release vestedAmount(currentBlockTime) to recipient
}
Vests tokens over time to a recipient.
10
Simplicity Payment Channel
contract paymentChannel {
input: sig senderSig, sig receiverSig, balanceUpdate
output: settle funds according to signed balanceUpdate
}
Enables off-chain microtransactions with on-chain settlement.