Skip to Content
ReferenceRPCImport Contracts

Import Contracts

RPC method for pushing a project’s compiled contracts (ABI, bytecode, and optional metadata) to your Stagenet. Each pushed contract gets a pending Workspace that activates when the matching bytecode is deployed.

This backs the contract.dev import-contracts CLI. The CLI is the easiest way to use it — it auto-detects your Foundry/Hardhat project, reads compiled artifacts, and assembles the request for you. Call the RPC directly only when you need to push from a custom build pipeline.

dev_importContracts

ParameterTypeDescription
inputobject{ contracts: LocalContract[] } (see below)

Each LocalContract describes one compiled contract:

FieldTypeDescription
namestringContract name (e.g. "Vault"). Required.
abistringJSON-encoded ABI string. Required.
bytecodestringHex-encoded bytecode used for matching against on-chain deployments. Usually the deployed (runtime) bytecode. Required.
creationBytecodestring?Creation bytecode. Optional.
deployedBytecodestring?Deployed (runtime) bytecode. Optional.
sourcePathstring?Project-relative path to the contract’s source file (e.g. src/Vault.sol).
sourcestring?Full Solidity source of the contract’s own .sol file (max ~1 MB).
storageLayoutobject?solc storage-layout output. Only present when the user opts in via outputSelection / extra_output.
bytecodeLinkReferencesobject?Library link references from solc, for the creation bytecode.
deployedBytecodeLinkReferencesobject?Library link references for the deployed bytecode.

Interfaces and abstract contracts have no runtime bytecode and should not be pushed — the server will reject bytecode: "0x". The CLI filters them automatically.

Result

{ "contracts": [ { "name": "Vault", "projectContractId": "pc_...", "projectContractVersionId": "pcv_...", "status": "created" }, { "name": "Token", "projectContractId": "pc_...", "projectContractVersionId": "pcv_...", "status": "new_version" }, { "name": "Math", "projectContractId": "pc_...", "projectContractVersionId": "pcv_...", "status": "unchanged" } ] }

Status values:

  • created — first time this contract name was pushed.
  • new_version — the bytecode or ABI changed; a new version was created.
  • unchanged — nothing differed from the last push; no new version was written.

Example

curl -X POST <YOUR_STAGENET_RPC_URL> \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "dev_importContracts", "params": [{ "contracts": [ { "name": "Vault", "abi": "[{\"type\":\"function\",\"name\":\"deposit\",\"inputs\":[],\"outputs\":[]}]", "bytecode": "0x6080604052...", "sourcePath": "src/Vault.sol" } ] }] }'

When the Workspace activates

dev_importContracts creates a pending Workspace per contract. The Workspace activates once a transaction deploys bytecode that matches the imported bytecode. If a matching deployment already exists on the Stagenet, the Workspace is activated immediately.

For one-off per-address attachments (e.g. mainnet contracts, wallets) use dev_addWorkspace instead.

Last updated on