How Base Differs
Base adds native precompiles at fixed addresses that extend the EVM with functionality built into the node itself, such as the B20 token standard, the PolicyRegistry, and the B20 Factory. These addresses hold no contract bytecode, so a local EVM that does not implement them reverts when a contract calls them. Foundry v1.8.4 and later implement Base’s precompiles inforge, cast, anvil, and chisel. Enable them by setting a Base hardfork, as shown below.
Set Up Your Environment
- Create a new project directory
Terminal
- Install Foundry v1.8.4 or later
Terminal
forge --version to confirm the version.
- Initialize a new Solidity project
Terminal
- Enable Base’s precompiles for local tests by adding a Base hardfork to the
[profile.default]section offoundry.toml:
foundry.toml
Counter contract in src/Counter.sol, which you can replace with your own contracts.
Configure a Node Connection and Deployer Key
- Create a
.envfile in your project root and add the Base RPC URLs
.env
- Load the variables
Terminal
- Store your deployer private key in Foundry’s secure keystore
Terminal
~/.foundry/keystores, which is not tracked by git.
Deploy a Contract
- (Optional) Dry-run the deployment to confirm your configuration:
Terminal
- Deploy by adding the
--broadcastflag:
Terminal
<contract-path>:<contract-name>.
- On success you’ll see the deployed address:
Example Output
Verify Your Deployment
- Check the transaction on Sepolia Basescan using the transaction hash.
- Read the contract’s state from the command line:
Terminal
Counter contract’s number variable, 0.
Next Steps
B20 Token Standard
Launch Base’s native token standard, built in at the precompile level.
Connect to Base
Network details, RPC endpoints, and wallet configuration.