What are Precompiles?
Precompiles are special contracts deployed at fixed addresses that bypass the EVM interpreter. Instead of executing bytecode, calls to precompile addresses are routed directly to optimized native code. This provides:- Gas Efficiency: 10-100x cheaper than equivalent Solidity contracts
- Performance: Direct memory access and native operations
- Security: Core protocol logic protected from bytecode vulnerabilities
- Upgradability: Can be updated via hardforks without changing addresses
Security Model
All Tempo precompiles enforce:- No DELEGATECALL: Precompiles can only be called directly, never via
DELEGATECALL - Static Context Awareness: Mutating functions revert when called in static context
- Gas Metering: All operations are properly metered for resource consumption
- Storage Isolation: Each precompile has isolated storage at its address
Available Precompiles
Core Protocol
Nonce Manager
2D nonce management for parallel transaction execution
Account Keychain
Multi-key authorization with spending limits for smart accounts
Token Infrastructure
TIP-20 Factory
Deploy TIP-20 tokens at deterministic addresses
TIP-403 Registry
Compliance policy registry for transfer restrictions
Consensus
Validator Config
Manage validator set and DKG ceremony scheduling
Precompile Addresses
All precompiles are deployed at fixed, human-readable addresses:| Precompile | Address | Purpose |
|---|---|---|
| Nonce Manager | 0x4E4F4E4345000000000000000000000000000000 | 2D nonce management |
| Account Keychain | 0xAAAAAAAA00000000000000000000000000000000 | Multi-key authorization |
| TIP-20 Factory | 0x20FC000000000000000000000000000000000000 | Token deployment |
| TIP-403 Registry | 0x403C000000000000000000000000000000000000 | Compliance policies |
| Validator Config | 0xCCCCCCCC00000000000000000000000000000000 | Consensus validators |
Addresses are chosen to be memorable:
0x4E4F4E4345...= “NONCE” in ASCII hex0xAAAAAAAA...= Account (repeating A)0x20FC...= 20 (TIP-20) + Factory0x403C...= 403 (TIP-403) + Compliance0xCCCCCCCC...= Consensus (repeating C)
Usage Patterns
Direct Calls
Precompiles are called like regular contracts:From Web3 Libraries
Hardfork Activation
Precompile behavior can change across hardforks:- Genesis: Base precompiles (Nonce, TIP-20, TIP-403, Validator Config)
- T1: Account Keychain, improved error handling
- T1C: P256 signature support via Osaka precompiles
- T2: Compound policies (TIP-1015), Validator Config V2
CfgEnv.spec.
Gas Costs
Precompile operations have fixed base costs plus per-operation charges:- Base Call: ~2,100 gas (similar to contract call)
- Storage Read: 100-2,100 gas (cold/warm)
- Storage Write: 2,900-20,000 gas (new/existing)
- Calldata: 6 gas per 32-byte word
Error Handling
Precompiles return ABI-encoded errors like Solidity contracts:Implementation Details
Precompiles are implemented in Rust incrates/precompiles/src/. Each precompile:
- Defines storage layout using the
#[contract]macro - Implements the
Precompiletrait with acall()dispatcher - Uses
tempo_contractsfor Solidity interface generation - Includes comprehensive test coverage
- ABI encoding/decoding
- Gas metering and refunds
- Storage slot computation
- Event emission
- Error handling