Welcome to the Base deployment quickstart guide! This comprehensive walkthrough will help you set up your environment and deploy smart contracts on Base. Whether you’re a seasoned developer or just starting out, this guide has got you covered.Documentation Index
Fetch the complete documentation index at: https://base-a060aa97-meyer9-discv5-p2p-protocol-id.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
What You’ll Achieve
By the end of this quickstart, you’ll be able to:- Set up your development environment to deploy on Base
- Deploy your smart contracts to Base
- Connect your frontend to your smart contracts
Set Up Your Development Environment
- Create a new project directory
- Install Foundry, a powerful framework for smart contract development
- Initialize a new Solidity project
src directory, which you can replace with your own contracts. For the purposes of this guide, we’ll use the Counter contract provided in /src/Counter.sol
Configure Foundry with Base
To deploy your smart contracts to Base, you need two key components:- A node connection to interact with the Base network
- A funded private key to deploy the contract
1. Set up your node connection
- Create a
.envfile in your project’s root directory - Add the Base network RPC URL to your
.envfile
- Load your environment variables
2. Secure your private key
- Store your private key in Foundry’s secure keystore
- When prompted enter your private key and a password.
~/.foundry/keystores which is not tracked by git.
Deploy Your Contracts
Now that your environment is set up, let’s deploy your contracts to Base Sepolia.- (Optional) First, perform a dry run to simulate the deployment and verify everything is configured correctly:
- Deploy your contract by adding the
--broadcastflag:
<contract-path>:<contract-name>.
- After successful deployment, you’ll see output including:
- Copy the deployed contract address and add it to your
.envfile:
0x... with your actual deployed contract address from the output above.
- Load the new environment variable:
Verify Your Deployment
To ensure your contract was deployed successfully:- Check the transaction on Sepolia Basescan using your transaction hash
- Use the
castcommand to interact with your deployed contract from the command line:
number storage variable, which will be 0.
Congratulations! You’ve deployed your smart contracts to Base Sepolia!
Next Steps
- Use wagmi or viem to connect your frontend to your contracts.
- Learn more about interacting with your contracts in the command line using Foundry from our Foundry tutorial.