Skip to content

base/base-std

Repository files navigation



Base_lockup_white



Base Standard Library

A collection of Solidity interfaces, libraries, and mock implementations for Base precompiles.

Installation

forge install base/base-std

Standard Precompiles

src
├── StdPrecompiles.sol: Collection of precompiles and their interfaces
└── interfaces
    ├── IB20.sol: Core Token Standard
    ├── IB20Stablecoin.sol: Stablecoin variant of B20
    ├── IB20Security.sol: Security variant of B20
    ├── IPolicyRegistry.sol: Policy registry shared across B20s
    └── ITokenFactory.sol: B20 factory contract

Development

forge build
forge test

Solidity 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.

Fork testing against live precompiles

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 vibenet

What each flag does:

  • --fork-url vibenet — selects the RPC endpoint defined in foundry.toml under [rpc_endpoints] (currently https://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 — tells BaseTest.setUp to skip the mock-etching step. Without it, vm.etch would 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.

License

MIT

About

A collection of Solidity interfaces, libraries, and mock implementations for Base precompiles.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors