forge create, and a repeatable forge script.
What you’ll build
AGreeter contract on testnet, deployed and verified on BOTScan in one command.
Prerequisites
- A Foundry project configured for BOT Chain with the
uzo-devkeystore. Follow Set up Foundry first. - At least 0.01 tBOT in
uzo-dev.
Steps
1
Add the contract
src/Greeter.sol
2
Option 1: deploy with forge create
forge create deploys one contract. Put --constructor-args last, because it takes every value after it.Output
--broadcast, forge create only simulates the deploy.3
Option 2: deploy with a script
A script is Solidity code that runs your deploy steps. Use it when you deploy more than one contract or need setup calls after the deploy.Run it, and verify on BOTScan in the same command:Forge simulates first, sends the transaction, waits for it, then submits the source. The output ends with
script/DeployGreeter.s.sol
All (1) contracts were verified!. Forge records the run in broadcast/DeployGreeter.s.sol/968/run-latest.json.Verify it worked
Read the greeting back from the chain:https://scan.bohr.life/address/0xYOUR_GREETER to see the contract on BOTScan.
Deploy to mainnet
Swap the RPC alias and the verifier URL:Troubleshooting
forge create prints the transaction but nothing is deployed
forge create prints the transaction but nothing is deployed
You left out
--broadcast, so Forge only simulated the deploy. Add it and run again.Forge reads other flags as constructor arguments
Forge reads other flags as constructor arguments
--constructor-args takes every value that follows it, so a flag placed after it becomes an argument. Move --constructor-args to the end of the command.The script deploys but verification fails
The script deploys but verification fails
Check that the verifier URL ends in
/api/, with the trailing slash. To retry only the verification, use forge verify-contract; see Verify with Foundry.transaction underpriced
transaction underpriced
If you pass
--priority-gas-price or --with-gas-price, use at least 20gwei. Otherwise leave them out and Forge reads the right value from the node.Next steps
Verify with Foundry
Verify a contract that is already deployed.
Set up wagmi
Call your contract from a web app.