Skip to content

Commit fbe5a3a

Browse files
authored
Fix deployment tutorial: add --broadcast flag and clarify env setup (#522)
Add missing --broadcast flag to forge create command and clarify COUNTER_CONTRACT_ADDRESS environment variable setup steps to prevent deployment and verification failures.
1 parent b74d5ad commit fbe5a3a

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

docs/base-chain/quickstart/deploy-on-base.mdx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,38 +100,67 @@ Never share or commit your private key. Always keep it secure and handle with ca
100100

101101
Now that your environment is set up, let's deploy your contracts to Base Sepolia.
102102

103-
1. Use the following command to compile and deploy your contract
103+
1. (Optional) First, perform a dry run to simulate the deployment and verify everything is configured correctly:
104104

105105
```bash
106106
forge create ./src/Counter.sol:Counter --rpc-url $BASE_SEPOLIA_RPC_URL --account deployer
107107
```
108108

109+
This performs a simulation without broadcasting the transaction to the network. You'll see the transaction details and contract ABI, but no actual deployment will occur.
110+
111+
2. Deploy your contract by adding the `--broadcast` flag:
112+
113+
```bash
114+
forge create ./src/Counter.sol:Counter --rpc-url $BASE_SEPOLIA_RPC_URL --account deployer --broadcast
115+
```
116+
117+
<Tip>
118+
The `--broadcast` flag is **required** to actually deploy your contract to the network. Without it, Foundry only performs a dry run simulation.
119+
</Tip>
120+
109121
Note the format of the contract being deployed is `<contract-path>:<contract-name>`.
110122

111-
2. After successful deployment, the transaction hash will be printed to the console output
123+
3. After successful deployment, you'll see output including:
112124

113-
3. Copy the deployed contract address and add it to your `.env` file
125+
```
126+
Deployer: 0x...
127+
Deployed to: 0x... <-- YOUR CONTRACT ADDRESS
128+
Transaction hash: 0x...
129+
```
130+
131+
4. Copy the deployed contract address and add it to your `.env` file:
114132

115133
```bash
116134
COUNTER_CONTRACT_ADDRESS="0x..."
117135
```
118136

119-
4. Load the new environment variable
137+
Replace `0x...` with your actual deployed contract address from the output above.
138+
139+
5. Load the new environment variable:
120140

121141
```bash
122142
source .env
123143
```
124144

145+
<Tip>
146+
You need to run `source .env` after modifying your `.env` file to load the new variables in your current terminal session.
147+
</Tip>
148+
125149
### Verify Your Deployment
126150

127151
To ensure your contract was deployed successfully:
128152

129-
1. Check the transaction on [Sepolia Basescan](https://sepolia.basescan.org/).
130-
2. Use the `cast` command to interact with your deployed contract from the command line
153+
1. Check the transaction on [Sepolia Basescan](https://sepolia.basescan.org/) using your transaction hash
154+
2. Use the `cast` command to interact with your deployed contract from the command line:
131155

132156
```bash
133157
cast call $COUNTER_CONTRACT_ADDRESS "number()(uint256)" --rpc-url $BASE_SEPOLIA_RPC_URL
134158
```
159+
160+
<Tip>
161+
Make sure you've added `COUNTER_CONTRACT_ADDRESS` to your `.env` file and run `source .env` before running this command. Otherwise, the environment variable will be undefined and the command will fail.
162+
</Tip>
163+
135164
This will return the initial value of the Counter contract's `number` storage variable, which will be `0`.
136165

137166
**Congratulations! You've deployed your smart contracts to Base Sepolia!**

0 commit comments

Comments
 (0)