A collection of Solidity interfaces, libraries, and mock implementations for Base precompiles.
- ActivationRegistry — Feature flags controlled by Base team to activate/deactivate features.
- PolicyRegistry — Membership sets controlled by custom admins, initially providing allow and block lists for B20 token operations.
- B20 — Standard ERC-20 implementation with extensions for roles, policies, memos, pausing, ERC-2612 permits, and a variant system.
These source files are imported by production contracts to interact with Base precompiles.
forge install base/base-stdsrc ├── StdPrecompiles.sol: Precompile addresses with interface wrapper handles ├── interfaces │ ├── IB20.sol: Core token standard │ ├── IB20Asset.sol: Asset variant of B20 │ ├── IB20Stablecoin.sol: Stablecoin variant of B20 │ ├── IB20Factory.sol: B20 factory precompile │ ├── IPolicyRegistry.sol: Policy registry precompile │ └── IActivationRegistry.sol: Activation registry precompile └── lib ├── B20Constants.sol: B20 role and policy-type identifier constants └── B20FactoryLib.sol: Pure encoders for B20 factory params and initCalls
These mock contracts replace the live precompiles in unit tests, allowing tests to run without a fork.
test/lib/mocks ├── MockActivationRegistry.sol: Mock implementation of the activation registry precompile ├── MockPolicyRegistry.sol: Mock implementation of the policy registry precompile └── MockB20Factory.sol: Mock implementation of the B20 factory precompile
forge build
forge testSolidity version: 0.8.30 for reference implementations. Interfaces are
written for broader compatibility (>=0.8.20 <0.9.0) so consumers can
import them without forcing a specific compiler.
The unit suite can run against a chain hosting the live Rust precompile implementations to verify the Rust impls match the Solidity reference's behavior and storage layout. The same test bodies are reused — only the backend changes.
LIVE_PRECOMPILES=true FOUNDRY_PROFILE=fork forge test --fork-url vibenetWhat each flag does:
--fork-url vibenet— selects the RPC endpoint defined infoundry.tomlunder[rpc_endpoints](currentlyhttps://rpc.vibes.base.org/). Foundry forks the chain in a sandboxed copy-on-write state; tests mutate the fork without touching the real chain.LIVE_PRECOMPILES=true— tellsBaseTest.setUpto skip the mock-etching step. Without it,vm.etchwould clobber the live precompile addresses with the mock bytecode, silently routing every call back through the Solidity reference and producing false-pass results.FOUNDRY_PROFILE=fork— switches to a reduced-fuzz-runs profile (10 instead of 256). Each fuzz iteration may trigger RPC round-trips against the live precompiles; the goal at this stage is "does the layout / behavior match" rather than fuzz coverage. Drop this flag to use the default fuzz runs.
A test failure under this command means one of three things, in diagnostic order: (1) the feature isn't activated yet in the ActivationRegistry, (2) the precompile isn't deployed at its canonical address on the forked chain, or (3) the Rust impl's storage layout / behavior diverges from the Solidity reference at the asserted slot.
MIT