Skip to Content
CLIPush Contracts

Push Contracts

Push the compiled contracts of a Hardhat or Foundry project to your Stagenet, so deployments are recognised and get dashboards automatically.

Re-run after each rebuild to keep your Stagenet in sync — unchanged contracts are no-ops, changed contracts get a new version.

Usage

Run it from your project root after compiling:

# Foundry forge build # Hardhat npx hardhat compile # Then contract.dev push-contracts
Detected Hardhat project 2 contracts pushed: - Token - Vault
FlagDescription
--contracts <dir>Override the detected source directory.
--artifacts <dir>Override the detected compiled-artifacts directory.

import-contracts is accepted as an alias for the old name.

How it works

The CLI scans your compiled build artifacts:

  • Foundry: out/
  • Hardhat: artifacts/contracts/

For each deployable contract, it uploads the ABI, bytecode, and metadata to your Stagenet. When a contract is deployed to the Stagenet, its bytecode is compared against the pushed artifacts — on a match, a dashboard is created for the deployment. If matching bytecode is already deployed, it is detected immediately.

The CLI does not build your project — compile first.

Source and artifact directories

The CLI pushes only contracts from your project’s source directory, so dependencies (OpenZeppelin, node_modules libraries) aren’t treated as part of your project:

  • Foundry: reads [profile.default].src and out from foundry.toml (defaults src/, out/).
  • Hardhat: reads paths.sources and paths.artifacts from hardhat.config.{ts,js,cjs,mjs} (defaults contracts/, artifacts/contracts/).

The Hardhat config is not executed — paths are read as string literals. If your config computes paths dynamically (env vars, path.join, imported constants, template literals), the CLI falls back to the defaults and tells you; pass the resolved paths explicitly:

contract.dev push-contracts --contracts src/protocol --artifacts build/artifacts/src/protocol

For Hardhat, --artifacts should be the artifacts root plus your sources subpath — Hardhat mirrors the sources tree under the artifacts root.

Storage layout

Pushes include the storage layout when your Hardhat or Foundry project outputs it in the compiled artifacts — it powers the dashboard’s decoded storage section.

Notes

  • Interfaces and abstract contracts are skipped.
  • Contracts without deployable bytecode are skipped.
  • Backed by the dev_importContracts RPC method for custom build pipelines.
Last updated on