> 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

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-dataseed1-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-dataseed1-testnet.svpchain.org",
      chainId: 2517,
      accounts: [process.env.PRIVATE_KEY!],
    },
    svpMainnet: {
      url: "https://svp-dataseed1.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="/pages/WbWNTH7LlQ7WJX7p5DLo">/pages/WbWNTH7LlQ7WJX7p5DLo</a></td></tr><tr><td>Use RPC methods directly</td><td><a href="/pages/77zTbbBQ0JBb98y28p8h">/pages/77zTbbBQ0JBb98y28p8h</a></td></tr><tr><td>Real-time subscriptions</td><td><a href="/pages/Io3CHhXbFpFy7A3qIStL">/pages/Io3CHhXbFpFy7A3qIStL</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://svpchain.gitbook.io/svpchain-docs/build/deploy-a-contract.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
