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.
What you build
Section titled “What you build”By the end of this guide you will have:
- A development environment running Base’s Foundry build
- 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 Base’s Foundry build, used throughout this guide.
curl -L https://raw.githubusercontent.com/base/base-anvil/HEAD/foundryup/install | bashbase-foundryupThis lands base-forge, base-cast, and base-anvil next to whatever Foundry you already have. Nothing is overwritten, and the two toolchains coexist.
- Initialize a Solidity project.
base-forge initThe project is ready. The starter contract sits at src/Counter.sol — this guide uses that contract as the deployment target.
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.
base-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.
base-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.
base-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
base-cast:
base-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.