> For the complete documentation index, see [llms.txt](https://svpchain.gitbook.io/svpchain-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://svpchain.gitbook.io/svpchain-docs/build/deploy-a-contract.md).

# Deploy a contract

Compile, deploy, and verify a Solidity contract on SVPChain — Hardhat and Foundry.

SVPChain is EVM-compatible, so any Solidity workflow works unchanged. You just need three things:

* an RPC endpoint ([Networks](/svpchain-docs/chain/networks.md))
* a funded address ([Faucet](/svpchain-docs/get-started/faucet-testnet.md) for testnet)
* the chain ID — `2517` (testnet) or `2518` (mainnet, when live)

This page walks through both **Foundry** and **Hardhat**.

### Foundry

#### 1) Set environment variables

```sh
export SVP_RPC=https://svp-dataseeds-testnet.svpchain.org
export SVP_CHAIN_ID=2517
export PRIVATE_KEY=0x...   # testnet only — never paste a mainnet key
```

#### 2) Deploy

From a project containing `src/Counter.sol`:

```sh
forge create src/Counter.sol:Counter \
  --rpc-url   $SVP_RPC \
  --chain-id  $SVP_CHAIN_ID \
  --private-key $PRIVATE_KEY \
  --broadcast
```

Or with a deploy script (`script/Deploy.s.sol`):

```sh
forge script script/Deploy.s.sol:Deploy \
  --rpc-url   $SVP_RPC \
  --chain-id  $SVP_CHAIN_ID \
  --private-key $PRIVATE_KEY \
  --broadcast
```

#### 3) Sanity check

```sh
cast code <deployed-address> --rpc-url $SVP_RPC | head -c 20
# → starts with 0x6080... (or your bytecode prefix)
```

### Hardhat

#### 1) Add the network

In `hardhat.config.ts`:

```ts
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

const config: HardhatUserConfig = {
  solidity: "0.8.24",
  networks: {
    svpTestnet: {
      url: "https://svp-dataseeds-testnet.svpchain.org",
      chainId: 2517,
      accounts: [process.env.PRIVATE_KEY!],
    },
    svpMainnet: {
      url: "https://svp-dataseeds.svpchain.org",
      chainId: 2518,
      accounts: [process.env.PRIVATE_KEY!],
    },
  },
};

export default config;
```

#### 2) Deploy

```sh
PRIVATE_KEY=0x... npx hardhat run scripts/deploy.ts --network svpTestnet
```

A minimal `scripts/deploy.ts`:

```ts
import { ethers } from "hardhat";

async function main() {
  const Counter = await ethers.getContractFactory("Counter");
  const c = await Counter.deploy();
  await c.waitForDeployment();
  console.log("Counter deployed at", await c.getAddress());
}

main().catch((e) => { console.error(e); process.exit(1); });
```

### Gas

* **Min gas price:** `2 Gwei` — submitting below this fails with `tx underpriced`.
* **EIP-1559** is supported. Default base fee is around `1.9 Gwei`. For a one-shot deploy, just let your tooling pick `maxFeePerGas` and `maxPriorityFeePerGas` (cast/forge/hardhat all do this correctly).
* For deterministic deploys (CREATE2), the bytecode hash and salt are network-agnostic — the same address you got on Ethereum will deploy at the same address on SVPChain, given the same deployer and nonce/salt.

### Verify on the explorer

<https://explorer.svpchain.com> is a Blockscout fork and supports source verification. There are two paths:

**From the explorer UI** — open the contract address page, click **Code → Verify & Publish**, and follow the form (single file, multi-part, or standard JSON input).

**From Hardhat** (using the [Blockscout verification plugin](https://docs.blockscout.com/devs/verification/hardhat-verification-plugin)) — TODO: confirm the API key/URL flow once the explorer team publishes their endpoint, and we'll drop a copy-paste config here.

### Next steps

<table data-view="cards"><thead><tr><th>After deploy</th><th data-card-target data-type="content-ref">Link</th></tr></thead><tbody><tr><td>Listen to logs and events</td><td><a href="/svpchain-docs/build/indexing-and-events.md">Indexing &amp; events</a></td></tr><tr><td>Use RPC methods directly</td><td><a href="/svpchain-docs/build/json-rpc.md">JSON-RPC</a></td></tr><tr><td>Real-time subscriptions</td><td><a href="/svpchain-docs/build/websocket.md">WebSocket</a></td></tr></tbody></table>
