Skip to main content
Base is an EVM-equivalent Ethereum L2. Smart contracts are written in Solidity or Vyper and deploy exactly as they do on Ethereum — the same bytecode, ABIs, and tooling apply.

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 in forge, cast, anvil, and chisel. Enable them by setting a Base hardfork, as shown below.
Foundry versions before v1.8.4 do not implement Base’s precompiles. A contract that reads or writes a Base precompile, for example one that deploys or calls a B20 token, fails in local tests and simulations under those versions.

Set Up Your Environment

  1. Create a new project directory
Terminal
  1. Install Foundry v1.8.4 or later
Terminal
Run forge --version to confirm the version.
  1. Initialize a new Solidity project
Terminal
  1. Enable Base’s precompiles for local tests by adding a Base hardfork to the [profile.default] section of foundry.toml:
foundry.toml
Your project is ready. You’ll find an example Counter contract in src/Counter.sol, which you can replace with your own contracts.
See Foundry for Base for how to enable Base in anvil and forks, which hardfork value to use, and how Foundry relates to Base’s base-anvil fork.

Configure a Node Connection and Deployer Key

  1. Create a .env file in your project root and add the Base RPC URLs
.env
  1. Load the variables
Terminal
  1. Store your deployer private key in Foundry’s secure keystore
Terminal
Enter your private key and a password when prompted. The key is stored in ~/.foundry/keystores, which is not tracked by git.
Never share or commit your private key. Always keep it secure and handle it with care.
Base Sepolia is the test network for Base, used for the rest of this guide. Get free Base Sepolia ETH from one of the faucets listed on the Get Funds page.

Deploy a Contract

  1. (Optional) Dry-run the deployment to confirm your configuration:
Terminal
This simulates the deployment without broadcasting. You’ll see the transaction details and contract ABI, but nothing is deployed.
  1. Deploy by adding the --broadcast flag:
Terminal
The contract path format is <contract-path>:<contract-name>.
  1. On success you’ll see the deployed address:
Example Output

Verify Your Deployment

  1. Check the transaction on Sepolia Basescan using the transaction hash.
  2. Read the contract’s state from the command line:
Terminal
This returns the initial value of the 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.
Use wagmi or viem to connect your frontend to your contracts, and see the Foundry scripting guide for command-line interaction.