Skip to content
BaseHub by wbnns Updated

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.

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
  1. Create a project directory.
Terminal window
mkdir my-base-project && cd my-base-project
  1. Install Base’s Foundry build, used throughout this guide.
Terminal window
curl -L https://raw.githubusercontent.com/base/base-anvil/HEAD/foundryup/install | bash
base-foundryup

This lands base-forge, base-cast, and base-anvil next to whatever Foundry you already have. Nothing is overwritten, and the two toolchains coexist.

  1. Initialize a Solidity project.
Terminal window
base-forge init

The project is ready. The starter contract sits at src/Counter.sol — this guide uses that contract as the deployment target.

Deploying to Base requires two pieces:

  1. An RPC connection to the network
  2. A funded private key for signing the deployment transaction
  1. Create a .env file at the project root.
  2. Add the Base RPC URLs.
Terminal window
BASE_RPC_URL="https://mainnet.base.org"
BASE_SEPOLIA_RPC_URL="https://sepolia.base.org"
  1. Load the variables into your shell.
Terminal window
source .env
  1. Import your private key into the encrypted keystore.
Terminal window
base-cast wallet import deployer --interactive
  1. Paste the key when prompted and set a password.

The encrypted key is stored at ~/.foundry/keystores, which is excluded from git.

With the environment configured, deploy to Base Sepolia.

  1. (Optional) Run a dry run first to confirm the deployment is well-formed.
Terminal window
base-forge create ./src/Counter.sol:Counter --rpc-url $BASE_SEPOLIA_RPC_URL --account deployer

This simulates the deploy without broadcasting. You will see the transaction details and ABI; nothing is written onchain.

  1. Add --broadcast to actually deploy.
Terminal window
base-forge create ./src/Counter.sol:Counter --rpc-url $BASE_SEPOLIA_RPC_URL --account deployer --broadcast

The contract argument follows the format <contract-path>:<contract-name>.

  1. A successful deploy prints output similar to:
Deployer: 0x...
Deployed to: 0x... <-- YOUR CONTRACT ADDRESS
Transaction hash: 0x...
  1. Save the deployed address into .env.
Terminal window
COUNTER_CONTRACT_ADDRESS="0x..."

Replace 0x... with the address from the output.

  1. Reload the variables.
Terminal window
source .env

To confirm the contract is live:

  1. Look up the transaction hash on Sepolia Basescan.
  2. Read the contract directly with base-cast:
Terminal window
base-cast call $COUNTER_CONTRACT_ADDRESS "number()(uint256)" --rpc-url $BASE_SEPOLIA_RPC_URL

The call returns the initial value of the Counter’s number storage slot, which is 0.

The contract is now live on Base Sepolia.