Deploy on Base
Set up a Foundry project, point it at Base, and deploy a contract to Base Sepolia in a single end-to-end workflow.
Base is EVM-equivalent, so Solidity and Vyper contracts carry over from Ethereum unchanged — same bytecode, same ABIs, same tooling. The one place that equivalence stops is the precompiles.
Base adds native precompiles at fixed addresses — the B20 token standard, the PolicyRegistry, and the B20 Factory among them. They are built into the node, so those addresses hold no bytecode, and a local EVM that does not know about them reverts the moment a contract calls one.
Stock Foundry now handles this. From v1.8.4, forge, cast, anvil, and chisel implement Base’s precompiles, and from v1.9.0 they also run the Denim rules that are live on Base Mainnet and Base Sepolia. Base support is switched on by choosing a Base hardfork, which this guide does below.
Ordinary token standards need none of this. ERC-20, ERC-721, ERC-1155, ERC-4626 vaults, and permissioned designs such as ERC-3643 are plain contracts and deploy on Base exactly as they do on Ethereum. B20 is the exception because it lives in the node: its method and event signatures are part of consensus, they keep parity with the core ERC-20 surface, and any B20 change ships with a network upgrade.
What you build
Section titled “What you build”By the end of this guide you will have:
- A Foundry v1.9.0+ environment with Base’s precompiles enabled
- A smart contract deployed to Base Sepolia
- A connection pattern your frontend can reuse against your contracts
Set up your development environment
Section titled “Set up your development environment”- Create a project directory.
mkdir my-base-project && cd my-base-project- Install Foundry v1.9.0 or later.
curl -L https://foundry.paradigm.xyz | bashfoundryupConfirm what you got with forge --version. To pin a release, use foundryup --install <version>, for example foundryup --install v1.9.0.
- Initialize a Solidity project.
forge init- Turn on Base’s precompiles for local tests. Add a Base hardfork to the
[profile.default]section offoundry.toml;base:Denimmatches what Base Mainnet and Base Sepolia run today.
hardfork = "base:Denim"The project is ready. The starter contract sits at src/Counter.sol — this guide uses that contract as the deployment target.
Choosing where Base is enabled
Section titled “Choosing where Base is enabled”Foundry behaves like Ethereum unless told otherwise, and the switch differs by context:
| Where it runs | How to enable Base |
|---|---|
forge test and forge script locally | Set hardfork = "base:Denim" in foundry.toml, or pass --hardfork base:Denim |
A local anvil node | anvil --hardfork base:Denim |
| A fork of Base Mainnet or Base Sepolia | Pass --fork-url; Foundry detects Base from the chain ID. Also pass --hardfork base:Denim (see below) |
cast against a live Base RPC | Nothing; the Base node executes the precompiles |
The hardfork value picks which upgrade’s rules and precompiles Foundry applies. Match it to the upgrade live on your target network:
| Value | Base precompiles |
|---|---|
base:Azul | None |
base:Beryl | B20 factory, B20 tokens, PolicyRegistry, ActivationRegistry |
base:Cobalt | Beryl’s precompiles with Cobalt’s B20 changes |
base:Denim | Cobalt’s precompiles with Denim’s B20 and PolicyRegistry changes (requires Foundry v1.9.0 or later) |
Coming from base-anvil
Section titled “Coming from base-anvil”base-anvil is Base’s own Foundry fork. It installs prefixed binaries next to stock Foundry, with the precompiles on by default, and earlier versions of this guide used it. New projects should use Foundry v1.9.0 or later instead. Some B20 issuance samples still call base-cast (pinned to base-anvil v1.1.1); since those hit a live RPC, plain cast from v1.8.4 onward runs them unchanged.
| Command | Foundry v1.9.0+ equivalent |
|---|---|
base-forge | forge with hardfork = "base:Denim" |
base-cast | cast |
base-anvil | anvil --hardfork base:Denim |
base-chisel | chisel |
Configure the toolchain for Base
Section titled “Configure the toolchain for Base”Deploying to Base requires two pieces:
- An RPC connection to the network
- A funded private key for signing the deployment transaction
1. Set up your RPC connection
Section titled “1. Set up your RPC connection”- Create a
.envfile at the project root. - Add the Base RPC URLs.
BASE_RPC_URL="https://mainnet.base.org"BASE_SEPOLIA_RPC_URL="https://sepolia.base.org"- Load the variables into your shell.
source .env2. Secure your private key
Section titled “2. Secure your private key”- Import your private key into the encrypted keystore.
cast wallet import deployer --interactive- Paste the key when prompted and set a password.
The encrypted key is stored at ~/.foundry/keystores, which is excluded from git.
Deploy your contract
Section titled “Deploy your contract”With the environment configured, deploy to Base Sepolia.
- (Optional) Run a dry run first to confirm the deployment is well-formed.
forge create ./src/Counter.sol:Counter --rpc-url $BASE_SEPOLIA_RPC_URL --account deployerThis simulates the deploy without broadcasting. You will see the transaction details and ABI; nothing is written onchain.
- Add
--broadcastto actually deploy.
forge create ./src/Counter.sol:Counter --rpc-url $BASE_SEPOLIA_RPC_URL --account deployer --broadcastThe contract argument follows the format <contract-path>:<contract-name>.
- A successful deploy prints output similar to:
Deployer: 0x...Deployed to: 0x... <-- YOUR CONTRACT ADDRESSTransaction hash: 0x...- Save the deployed address into
.env.
COUNTER_CONTRACT_ADDRESS="0x..."Replace 0x... with the address from the output.
- Reload the variables.
source .envVerify your deployment
Section titled “Verify your deployment”To confirm the contract is live:
- Look up the transaction hash on Sepolia Basescan.
- Read the contract directly with
cast:
cast call $COUNTER_CONTRACT_ADDRESS "number()(uint256)" --rpc-url $BASE_SEPOLIA_RPC_URLThe call returns the initial value of the Counter’s number storage slot, which is 0.
The contract is now live on Base Sepolia.
Next steps
Section titled “Next steps”- Launch a token on Base’s native standard, built in at the precompile level — see B20 and the B20 precompile reference.
- Wire a frontend to your contracts using wagmi or viem.
- Drive deployments from scripts with the Foundry scripting guide.