Protorunes Protocol
Protorunes is the foundation layer that enables Alkanes smart contracts on Bitcoin. It extends the Runes protocol with programmable functionality, allowing for complex on-chain logic while maintaining Bitcoin's security guarantees.
What are Protorunes?
Protorunes extend the Runes protocol with:
- Programmable Functionality – Execute arbitrary WASM code
- State Management – Maintain persistent contract state
- Token Standards – Create and manage fungible tokens
- Composability – Enable contract-to-contract interactions
How Protorunes Work
1. Transaction Encoding
Protorunes data is encoded in Bitcoin transactions using OP_RETURN outputs. Each transaction can contain calldata (instructions for contract execution), token transfers, and state updates.
2. Indexing
The Metashrew indexer processes Bitcoin blocks, extracts protorune transactions, executes WASM contract code, maintains state database, and provides query interfaces.
3. Execution Model
- Transaction is validated against Bitcoin rules
- Calldata is extracted and parsed
- Target contract's WASM code is executed
- State changes are committed
- Token transfers are recorded
Protocol Tag
Alkanes uses protocol tag 1n to identify its transactions. This distinguishes Alkanes from other protorune implementations.
const ALKANES_PROTOCOL_TAG = 1n;Alkane IDs
Each deployed contract receives a unique Alkane ID consisting of the block number and transaction index. For example, [2, 0] refers to DIESEL token.
Reserved IDs
[2, n]– Standard token deployments[3, n]– Factory contract deployments[4, n]– Reserved address space
State Storage
Protorunes provide key-value storage for contracts. State is persisted across transactions and blocks, enabling complex stateful applications.
// Store a value
storage::set(b"my_key", &value);
// Retrieve a value
let value = storage::get(b"my_key");Token Operations
Minting
oyl alkane new-token -name "MYTOKEN" -symbol "MTK" -amount 1000000Transfers
oyl alkane send -blk 2 -tx 14 -amt 100 -to <ADDRESS>Balances
const balance = await alkanes.protorunesbyaddress({
address: 'bc1...',
protocolTag: 1n,
});Security Model
Protorunes inherit Bitcoin's security:
- All state is anchored to Bitcoin blocks
- Transactions are validated by Bitcoin consensus
- No separate validator set or bridge required
- Deterministic execution ensures consistent state