Skip to Content

Import Contracts with the CLI

Import your Hardhat or Foundry project’s contracts onto your Stagenet from your terminal.

Prerequisites

  • A Hardhat or Foundry Project

Install the contract.dev CLI

Install the contract.dev package from npm:

npm install contract.dev

Then create a contract.dev.js config at your project root, passing your Stagenet’s RPC URL, which you can get from its dashboard:

npx contract.dev init --rpc-url=<YOUR_STAGENET_RPC_URL>

You can now run commands targeting your Stagenet. See the CLI reference for the full setup and command list.

Push your project’s contracts

From a Hardhat or Foundry project, compile and push:

# Foundry forge build # Hardhat npx hardhat compile # Then, from either project type npx contract.dev import-contracts

You’ll see something like:

Detected Hardhat project Pushing 2 contract(s) to stagenet... Token created Vault created Contracts: 2 created, 0 updated, 0 unchanged

Each contract becomes a pending Workspace. When a contract is deployed and its bytecode matches a pushed artifact, the Stagenet activates the matching Workspace automatically.

Re-run import-contracts after any contract changes — unchanged contracts are no-ops, changed contracts get a new version. See the import-contracts reference for source/artifact directory overrides and Hardhat configs that compute paths dynamically.

Last updated on