Get Started
Foundry

Foundry Quickstart

This quickstart walks you through integrating a Stagenet into your Foundry workflow. You’ll connect it to a GitHub repository containing your Foundry project, generate a Contract Workspace for each contract, and activate its Contract Analytics.

Create a Stagenet

Start by creating a new project — each one comes with its own Stagenet. Create one for free here.

Add Stagenet Endpoint and Private Key

To run Foundry commands against your Stagenet, you’ll need to give it two things:

  • Your Stagenet’s RPC URL
  • A funded private key (from the Stagenet’s Wallet Generator)

Create a .env file in the root of your Foundry project to store both values (if you don’t already have one).

Add Stagenet RPC URL

Open your project's dashboard and copy your Stagenet’s RPC URL. It will look something like:

https://rpc.contract.dev/3bf1bb611043d73921481c879e5d18fa

Add it to your .env file:

STAGENET_RPC_URL=https://rpc.contract.dev/3bf1bb611043d73921481c879e5d18fa

Get a Funded Stagenet Wallet

Open Tools → Wallet Generator in the sidebar. Copy the generated private key and click Fund Wallet. It will look like:

0x15340a8098a663d3965e0dbdef07606d200a416c9ff1218dc2b452af457ec6fc

Then add it to your .env file:

STAGENET_PRIVATE_KEY=0x15340a8098a663d3965e0dbdef07606d200a416c9ff1218dc2b452af457ec6fc

You can now run Foundry commands against your Stagenet using these environment variables.

# To load the RPC URL and the private key from your .env file
source .env
 
# Run Foundry commands
forge create src/Counter.sol:Counter --rpc-url $STAGENET_RPC_URL --private-key $STAGENET_PRIVATE_KEY --broadcast
forge script script/Counter.s.sol:CounterScript --rpc-url $STAGENET_RPC_URL --private-key $STAGENET_PRIVATE_KEY --broadcast

Connect GitHub Repository

Now connect a GitHub repository that contains your Foundry project to your Stagenet. Doing this will:

  • Import its contracts and generate a dedicated Contract Workspace for each one
  • Keep your Stagenet in sync with your repository — pushing new or updated contracts creates new workspaces or versions automatically

To do this, follow these steps:

  • Open Repositories via the sidebar and install the contract.dev GitHub App
  • Grant it access to the repository that contains your Foundry project
  • Once you’re redirected back, click Add Repository and select your repository

This links your repository to your Stagenet and automatically starts compiling its contracts. After compilation finishes, a Contract Workspace will be created for each one. You can view them by opening the Contracts page from the sidebar.

Activate Workspaces & Analytics

You have imported your contracts into your Stagenet, but you still need to actually deploy them. This will activate their Contract Workspaces and turn on Contract Analytics.

Do this via your usual Foundry commands:

# To load the RPC URL and the private key from your .env file
source .env
 
# Deploy your contracts onto your Stagenet
forge create src/MyContract.sol:MyContract --rpc-url $STAGENET_RPC_URL --private-key $STAGENET_PRIVATE_KEY --broadcast
forge script script/MyContractScript.s.sol:MyContractScript --rpc-url $STAGENET_RPC_URL --private-key $STAGENET_PRIVATE_KEY --broadcast

With their contracts deployed, you can now explore your new Contract Workspaces. Inside, you can view real-time activity, inspect storage state, track USD-denominated TVL, and browse each contract’s version and deployment history.

Furthermore, Contract Workspaces stay synced with your GitHub repository:

  • Pushing new contracts creates new Workspaces
  • Pushing updates to existing contracts automatically creates new Versions

You'll also have enabled Contract Analytics, where you can view contract behavior in ready-made views, or build custom dashboards that track state variables, token balances, function return values, and more.

Next Steps

Congratulations! Your Foundry project is now wired up to your Stagenet. Simply push new or updated contracts to your linked repository, and they’ll be automatically imported into the Stagenet as you develop. To continue exploring the Stagenet and its suite of built-in tools, follow the links below: