Quickstart
This quickstart guides you through setting up Mockchain with a Hardhat or Foundry project, allowing you to put your contracts on an ultra-realistic test blockchain and access rich analytics and purpose-built dev tools.
Create a Project
First, create a new Mockchain project. Each one comes with its own Stagenet. Do this by clicking the Create Project button on this page (opens in a new tab).
Link your Stagenet
Next, link your Stagenet to your Hardhat or Foundry project. Grab its RPC URL from your Mockchain project's dashboard and use it like any other RPC endpoint — as shown in the examples below.
Hardhat
Configure Hardhat to use your Stagenet by adding it as a network entry in your hardhat.config.ts
(or .js
):
// hardhat.config.ts
import { HardhatUserConfig } from "hardhat/config";
const config: HardhatUserConfig = {
networks: {
mockchain: {
url: "https://rpc.mockchain.xyz/abcde12345.....",
},
},
// ...other config
};
export default config;
Once added, run tasks against your Stagenet using the --network
flag:
npx hardhat run scripts/deploy.ts --network mockchain
Foundry
To use Foundry with your Stagenet, add its URL as an environment variable:
export FOUNDRY_RPC_URL=https://your-stagenet-url
Then run your usual commands:
forge script script/Deploy.s.sol --broadcast
Alternatively, pass the URL directly as a flag to your commands:
forge script script/Deploy.s.sol --rpc-url https://your-stagenet-url --broadcast
Set Up Your Contracts
After linking your Stagenet, you’ll want to add your project’s smart contracts to Mockchain to unlock deployment and version tracking — along with devtools, analytics, and dashboards, all tailored to each contract.
The easiest way to do this is by connecting a GitHub repo that contains your Hardhat or Foundry project. Go to the Project Contracts section of the app and click Connect Repository.
Authorize GitHub access, choose your repo, and wait for it to compile. Once ready, click Add Repository. Your contracts will appear like this.
Now deploy them to your Stagenet: either click Deploy Now in the UI, or run your usual deploy script using the Stagenet's RPC URL (for example npx hardhat run scripts/deploy.ts --network mockchain
or forge script script/Deploy.s.sol --rpc-url https://your-stagenet-url --broadcast
).
Once deployed, you'll see your contracts move from Ready to Deploy to Live.
Once a deployment is registered, click the contract’s Dashboard button to open its control center — where you can explore state and activity, and manage all future deployments and versions.
Next Steps
You’ve now got your contracts running on a true-to-life Stagenet, with tailored tools active and automatic updates on every push to your main branch. You’re ready to iterate faster, with full visibility at every step.
Now that the basics are in place, explore what else Mockchain can do:
- Understand how the Stagenet works – learn how mainnet replay and state sync make your Stagenet behave like the real thing.
- Dive into project contract management – see how Mockchain’s CI/CD tracks your deployments and versions, and gives you dev tools out of the box.
- Simulate mainnet activity on your Stagenet – replay real transactions to apps like Uniswap and Aave on your Stagenet.