Deploy with Foundry
This guide shows you how to deploy contracts from a Foundry project onto your Stagenet.
You do not need to change your contracts or your scripts. Just point Foundry at your Stagenet’s RPC URL.
Prerequisites
- A Foundry project
- A funded deployer wallet:
- generate one with the Wallet Generator
- or fund an existing address using the Faucet
Configure your environment
Copy your Stagenet’s RPC URL from its dashboard and add it to your .env alongside the funded private key:
STAGENET_RPC_URL=<YOUR_STAGENET_RPC_URL>
PRIVATE_KEY=<YOUR_FUNDED_PRIVATE_KEY>Stagenets expose a standard Ethereum JSON-RPC interface, so Foundry talks to them the same way it talks to any other EVM blockchain.
Deploy contracts
Load the variables and run your existing script with --rpc-url and --private-key:
source .env
# Run your deployment script through your Stagenet's RPC
forge script script/Deploy.s.sol:DeployScript \
--rpc-url $STAGENET_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast
# Or deploy directly with forge create
forge create src/Counter.sol:Counter \
--rpc-url $STAGENET_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcastNext steps
To get automatic Workspaces — dashboards that show contract transaction, balances, TVL, storage, and more — for each of your deployed contracts, import them onto your Stagenet.
You can do this via:
- Via the CLI by running
npx contract.dev import-contractsin your Foundry project. - Importing them from GitHub with the Stagenet’s CI/CD
When you import them, their deployments will be detected as instances of the imported contracts and they will have Workspaces created for them automatically.