Skip to Content

Deploying Solidity Contracts

You can deploy Solidity contracts to EVM-compatible chains in several ways. This page focuses on Foundry forge scripts for a concise, repeatable workflow.

Forge scripts let you write deployments in Solidity and execute them with the Foundry toolchain. They work for single or multiple contracts.

Writing Forge Scripts

Create a script directory in the root of your project and add the script file.

      • Deployment.s.sol
Deployment.s.sol
import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; import {MyBVSService} from "../src/MyBVSService.sol"; contract DeploymentScript is Script { function run() public virtual { vm.startBroadcast(); MyBVSService myBVSService = new MyBVSService(); console.log("MyBVSService deployed at: %s", address(myBVSService)); vm.stopBroadcast(); } }

Deploying

Dry run the script (no transactions are sent):

forge script script/Deployment.s.sol:DeploymentScript --chain <CHAIN> --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> -vvvv

Broadcast transactions by adding --broadcast:

forge script script/Deployment.s.sol:DeploymentScript --broadcast --chain <CHAIN> --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> -vvvv

Set --sender if your contracts use Ownable or similar patterns that require a specific deployer address; otherwise the Foundry default sender is used.

References

Read more about forge scripts in the Foundry Guide .

Last updated on