Smart Contracts: Programmable Money
Bitcoin Script, Miniscript, BitVM and DLCs on one side, the EVM and account abstraction on the other: what is programmable where — and what deliberately is not.
Ethereum was built for programmable contracts, Bitcoin deliberately not — yet remarkably much maps onto Bitcoin: from multisig vaults through Lightning channels to bets on real-world events. This chapter explains Bitcoin's script language and its disciplined extensions — and on the other side, how account abstraction makes Ethereum accounts programmable.
The idea in one paragraph
A smart contract locks money to conditions instead of people: “spendable if …”. On Bitcoin, a small stack language phrases these conditions directly in the transaction; complex logic moves into layers above (Miniscript, BitVM, DLCs) that stay invisible in the normal case. On Ethereum, accounts themselves carry logic — account abstraction turns them into configurable smart accounts. Common denominator: trust in code instead of counterparties — which makes audits and understanding all the more important.
Bitcoin Script: deliberately limited
Bitcoin Script is a simple stack language without loops — not a flaw but design: every execution terminates predictably at bounded cost. The building blocks:
- Opcodes: Signature checks, hash comparisons and time conditions via CLTV/CSV, among others. Available instructions depend on the script version; ordinary Script does not support loops or direct access to external data.
- Standard types: P2PKH and P2WPKH use public-key hashes; P2SH and P2WSH use script hashes. Taproot uses an output key that may also commit to script paths (see Chapter 6).
- UTXO logic: Each output carries its own script; on spending, script plus unlocking data run deterministically (see UTXO model). No global state, no side effects.
What works: multisig, escrow with deadline, payment channels. What does not: loops, random numbers, access to external data — that needs oracle constructions like DLCs.
Miniscript: readable spending policy
Miniscript represents a subset of Bitcoin Script in a structured form. It supports composition, analysis and signing of spending conditions, such as combinations of signatures and timelocks. Software can analyze satisfaction paths and resource requirements. Whether a design correctly expresses the intended recovery or inheritance policy still requires review; wallet support also matters.
BitVM and DLCs: compute outside, dispute on-chain
Two approaches bring arbitrary complex logic to Bitcoin without changing the base layer:
- BitVM: Arbitrary computations run off-chain between parties; only a dispute mechanism lands on-chain: cheaters lose the challenge game against an honest verifier. In principle this enables Turing-complete contracts on Bitcoin — at the price of interactive, capital-binding protocols (research and construction status).
- DLCs (Discreet Log Contracts): Two parties bet on an external event (price, election, weather): an oracle signs the outcome, the contract pays out automatically — without the oracle ever touching money or learning the bet's content. Ideal for hedging and prediction markets with minimal trust.
Account abstraction: accounts with logic
Ethereum distinguishes externally owned accounts controlled through keys from contract accounts controlled by code. ERC-4337 provides infrastructure for smart-account operations; EIP-7702 allows EOAs to delegate execution. These are different mechanisms with overlapping uses:
- ERC-4337: Bundlers collect UserOperations and submit them to an EntryPoint contract, without changing consensus rules. Paymasters can sponsor fees. Token payments and session-key limits require suitable wallet or paymaster implementations; the standard does not automatically provide them.
- EIP-7702: Ordinary Ethereum accounts can delegate code execution to an implementation. The delegation persists until changed or cleared; it does not expire at the end of a transaction.
- Consequences for keys: Social recovery (trusted people instead of seed paper), spending limits, biometrics plus hardware — but also: more code, more attack surface, dependence on bundler infrastructure.
Risks: code is attackable
Programmability multiplies attack surface. The patterns repeat:
- Reentrancy and logic bugs (EVM): contracts calling foreign code before completing their own state change — still a top cause despite known patterns.
- Admin keys and upgrades: Many DeFi contracts change via proxy — then you trust the key holders, not the code (see the L2BEAT logic in Chapter 7).
- Oracle dependence: DLCs and DeFi stand and fall with oracle integrity — decentralized oracle networks spread but don't eliminate residual risk.
- BitVM complexity: Challenge games need online presence and locked capital — similar responsiveness requirements to Lightning, but with protocol-specific assumptions.
Practice and limits
What you can touch today: sign and verify messages with the message verifier (EIP-191 for signed messages; contract-wallet signatures may require ERC-1271), read contract data with the ABI decoder, verify addresses per network with the address validator. What to skip: feeding significant amounts to unaudited contracts, ignoring admin keys, confusing “audited” with “safe”. Terms live in the glossary, fee logic in the ether article.
Sources
- ERC-1271: Contract signature validation
- Bitcoin Script (reference): en.bitcoin.it/wiki/Script
- Miniscript (language reference): bitcoin.sipa.be/miniscript
- BitVM (whitepaper and implementation): bitvm.org
- ERC-4337 (account abstraction): eips.ethereum.org/EIPS/eip-4337
- EIP-7702 (EOAs with code delegation): eips.ethereum.org/EIPS/eip-7702
Continue in the atlas: back to the overview — or on to Chapter 9: Regulation, back to Chapter 7: Layer 2. Also: Bitcoin & Web3 Basics and the reading-list atlas. More numbers and formats: cheat sheet.