Configure Foundry to deploy contracts to your Stagenet, run Forge commands against its RPC URL, and activate Workspaces for deployed contracts.
Deploy with Foundry
Deploy contracts from an existing Foundry project to your Stagenet using forge script, forge create, or any other Foundry command that accepts an RPC URL.
You do not need to change your contracts or your scripts. Just point Foundry at your Stagenet’s RPC URL.
Prerequisites
- A Foundry project with a deployment script (e.g.
script/Deploy.s.sol) - A Stagenet — create one in the dashboard if you don’t have one yet
- 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 network.
Deploy with forge script
Load the variables and run your existing script with --rpc-url and --private-key:
source .env
forge script script/Deploy.s.sol:DeployScript \
--rpc-url $STAGENET_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcastFoundry sends the deployment transactions through your Stagenet’s RPC. The contracts persist on the Stagenet and can be inspected from the dashboard.
Deploy with forge create
For one-off deployments you can skip the script and use forge create directly:
forge create src/Counter.sol:Counter \
--rpc-url $STAGENET_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcastAuto-generated Workspaces
To get a dedicated Workspace for each deployed contract — with activity, balances, TVL, storage, and tracked metrics — push the contracts to your Stagenet before deploying.
Install the CLI and initialise it with your Stagenet’s RPC URL:
npm install contract.dev
npx contract.dev init --rpc-url=<YOUR_STAGENET_RPC_URL>Then compile and push:
forge build
npx contract.dev push-contractsEach pushed contract becomes a pending Workspace. When forge script deploys a contract whose bytecode matches a pushed artifact, the Stagenet activates its Workspace automatically.
Re-run npx contract.dev push-contracts after any contract changes to keep your Stagenet in sync. To have new and updated contracts pushed automatically on every commit, set up GitHub CI/CD.
See the push-contracts reference for details on source/artifact directory overrides.
Next steps
- Workspaces — inspect each deployed contract in its own dashboard.
- Tracked Data — record and graph contract balances, storage variables, and function outputs over time.