Comment on page

Testing with Hardhat

A step-by-step guide for creating a Hardhat project and deploying it to your private StealthTest environment.
Before you begin, please make sure to create your StealthTest environment and have access to the RPC URL and chain ID.
This document is intended to act as a quick start integration guide for new Hardhat projects. If you already have an established Hardhat project, skip to step 3.
For more information on Hardhat please access the documentation here: Hardhat documentation
We will never ask you for your private key, nor will it ever be required at any step in the process of creating a StealthTest environment.
  1. 1.
    Create a new Hardhat project.
    1. 1.
      npm init -y
    2. 2.
      npm install --save-dev hardhat
    3. 3.
      npx hardhat
    4. 4.
      You will be provided with a default project containing: a smart contract, tests, and a deploy script.
    Here is what you will see when creating your project
  2. 2.
    Compile your contracts
    1. 1.
      Contracts are located at ./contracts
    2. 2.
      npx hardhat compile
  3. 3.
    Configure your Hardhat project for StealthTest
    1. 1.
      Within your hardhat.config.js
    2. 2.
      Add an object called networks
    3. 3.
      Inside that object, create an entry for stealthtest
    4. 4.
      Add the url, chainId, and a list of accounts private keys you would like to use.
      1. 1.
        Note: Each StealthTest environment comes with 5 pre-funded wallets, but please never use these on mainnet. You may also quickly fund your own wallet with our Faucet but please never share your private key with us or anyone you don't know.
    5. 5.
      As an option, you can add stealthtest as your defaultNetwork so it will always be used.
Example hardhat.config.js
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.18",
defaultNetwork: "stealthtest",
networks: {
stealthtest: {
url: "",
chainId: 148073,
accounts: ["0xf5d82a795ec5c5751161334378841e7a765182a047ee071bdfb1184f67b78d76"],
  1. 4.
    Deploy your contracts
    1. 1.
      npx hardhat run scripts/deploy.js
    2. 2.
      stealthtest is your defaultNetwork, so your deployment(s) will be sent there

And that's it! You're now testing in private using StealthTest!