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
contract.dev generate-wallet, or fund an existing address with 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 chain.
Deploy contracts
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 an automatic dashboard for each deployment, push your compiled contracts before (or after) deploying:
contract.dev push-contractsDeployments matching pushed bytecode are detected and get dashboards automatically. See Pushing Contracts.
Last updated on