Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
Your first real deploy. You'll write a Forge script (a small Solidity file with a run() function), run it against Anvil, and get back a contract address. The whole loop — code → compile → deploy → verify — takes under ten seconds locally. The discipline you build here (always deploy locally first) will save you on testnets and mainnet.
A Forge script is a Solidity file that calls vm.startBroadcast() before any state-changing operations; without --broadcast on the CLI, the script only simulates. This simulate-then-broadcast pattern lets you catch constructor failures and unexpected gas spends before you spend real ETH.
// script/DeployHello.s.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "forge-std/Script.sol";
import "../src/Hello.sol";
contract DeployHello is Script {
function run() external returns (Hello) {
vm.startBroadcast();
Hello hello = new Hello("gm");
vm.stopBroadcast();
return hello;
}
}
// Run against local anvil (use one of anvil's test private keys):
// forge script script/DeployHello.s.sol \
// --rpc-url http://127.0.0.1:8545 \
// --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
// --broadcast
//
// Output includes:
// "Contract Address: 0x5FbDB2315678afecb367f032d93F642f64180aa3"DeployHello.s.sol script exactly as above. Run forge build to compile.anvil in one terminal, keep it running.http://127.0.0.1:8545 with one of anvil's pre-funded private keys. You should see a contract address.greeting from the CLI: cast call <address> 'greeting()(string)' --rpc-url http://127.0.0.1:8545. You should see 'gm'.'hi from anvil' and redeploy. Confirm the new greeting with cast call. You just iterated on a smart contract in ~10 seconds.