A ready-to-code DevContainer for building, testing, and deploying smart contracts for Polkadot using either Hardhat or Foundry. It includes PolkaVM tooling, a local Dev node + ETH-RPC adapter, key management helpers, and opinionated defaults to get you productive fast.
- Hardhat preset:
@parity/hardhat-polkadot+resolcconfigured, sample contract/tests/ignition module, networks for local node and Polkadot Hub Testnet. - Foundry (Polkadot toolchain): Installed via
foundryup-polkadot(includesforge,cast,anvil). - Local node tooling:
dev-nodeandeth-rpcbinaries available in the container for PolkaVM local development. - Key management:
subkeypreinstalled; first attach auto-creates/imports a dev ECDSA key for testing and wires it into Hardhat or Foundry. - Dev tools: Convenience
devtoolsCLI for initializing projects, setting up the container, keypair, and checking balances.
- Docker Desktop (or compatible)
- VS Code + Dev Containers extension, GitHub Codespaces, or Gitpod
Option A — bring this DevContainer into any repo/folder (recommended):
curl -fsSL https://raw.githubusercontent.com/paritytech/smart-contracts-devcontainer/main/.devcontainer/fetch-devcontainer.sh | bash -s --To use a particular branch, just specify that as an argument:
curl -fsSL https://raw.githubusercontent.com/paritytech/smart-contracts-devcontainer/simplify-fetch-script/.devcontainer/fetch-devcontainer.sh | bash -s -- developThen open the folder in VS Code and “Reopen in Container”. On first attach, choose Hardhat or Foundry when prompted.
Option B — clone this template repo and open in VS Code:
- Open this repository in VS Code.
- “Reopen in Container” when prompted (or use the Dev Containers command).
- On first attach, you’ll be asked to initialize Hardhat or Foundry:
- Hardhat: a full sample project is copied and dependencies are installed.
- Foundry: a new
forgeproject is initialized.
- A dev ECDSA keypair is generated/imported and configured automatically:
- For Hardhat: stored via
hardhat varsasPRIVATE_KEY. - For Foundry: imported into the local keystore as the
paseoaccount.
- For Hardhat: stored via
- Use the workflows below to compile, test, run a local node, and deploy.
- GitHub Codespaces: After adding the
.devcontainer/to your repository (via the Quick start), open your repo on GitHub, click Code → “Create codespace on main”. Codespaces will build and start this DevContainer automatically. - Gitpod: After adding the
.devcontainer/to your repository, openhttps://gitpod.io/#<your-repo-url>(or use the Gitpod browser extension). Gitpod detects and uses the.devcontainerconfiguration out of the box.
Key files (created by init):
contracts/MyToken.solignition/modules/MyToken.tshardhat.config.ts(networks preconfigured)
Common commands (run inside the container):
npx hardhat compile
npx hardhat test
# Starts a local Revive Dev node + ETH-RPC adapter at 127.0.0.1:8545
npx hardhat nodeDeploy with Ignition:
# Local node (make sure `npx hardhat node` is running in another terminal)
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network localNode
# Polkadot Hub TestNet (uses TEST_ACC_PRIVATE_KEY set for you)
npx hardhat ignition deploy ./ignition/modules/MyToken.ts --network polkadotHubTestnetNotes:
- The
hardhatnetwork is configured to spawn a local Dev node + ETH-RPC adapter for you. You can also targetlocalNodeathttp://127.0.0.1:8545. - Some Hardhat-only helpers (for example
time,loadFixture) may not work with Polkadot nodes due to unsupported RPCs. Prefer plain ethers.js patterns for tests. See Hardhat docs for Polkadot for details.
Project is initialized with forge init.
Common commands:
forge build
forge test
# Example: query your testnet balance (RPC set below in Accounts)
cast balance <your-evm-address> --rpc-url "$ETH_RPC_URL"You can target the Polkadot Hub TestNet by setting:
export ETH_RPC_URL="https://testnet-passet-hub-eth-rpc.polkadot.io"To use the imported key:
- The key is imported into Foundry as the
paseokeystore with empty password. - Example send (be careful on live networks):
cast send <contract-or-recipient> <method-or-empty> \
--rpc-url "$ETH_RPC_URL" \
--keystore "$HOME/.foundry/keystores/paseo" \
--password ""- Start via Hardhat:
npx hardhat node(spawns Dev node on 127.0.0.1:8000 and ETH-RPC adapter on 127.0.0.1:8545). - The Hardhat network
hardhatuses the bundled binaries (dev-node,eth-rpc) from the container. - When running on Apple Silicon, the container uses amd64 binaries under emulation; expect slower performance.
On first attach, a keypair is prepared and wired into your toolchain:
- Hardhat:
hardhat vars get TEST_ACC_PRIVATE_KEYto view the configured private key (do not share). - Foundry: keystore name
paseowith empty password.
Your EVM address is displayed after setup. Get test tokens from the Paseo Smart Contract faucet, then check balance:
# Convenience helper in this container
devtools check-balancedevtools setup-devcontainer # One-time project/container setup (runs automatically on attach)
devtools setup-keypair # Create/import dev key, wire into Hardhat/Foundry, print faucet hint
devtools init-hardhat # Initialize Hardhat template if not present
devtools init-foundry # Initialize Foundry template if not present
devtools check-balance # Prints your current PAS balance on Polkadot Hub TestNet.devcontainer/DevContainer config and base toolingdevcontainer.jsonsets up extensions and runs setup scripts on attachDockerfileinstalls Node.js 22, Foundry (Polkadot), Subkey, and local node binariesscripts/devtool-scripts/*.shhelper scripts invoked viadevtoolsinit-hardhat/sample Hardhat project content used for initialization
- Hardhat on Polkadot: docs.polkadot.com – Development Environments: Hardhat
- Foundry on Polkadot: docs.polkadot.com – Development Environments: Foundry
- Local development node: docs.polkadot.com – Local Development Node
- JSON-RPC reference: docs.polkadot.com – JSON-RPC APIs
GPL-3.0. See LICENSE for details.