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.
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.Create a new Hardhat project.
- 1.
npm init -y
- 2.
npm install --save-dev hardhat
- 3.
npx hardhat
- 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.Compile your contracts
- 1.Contracts are located at
./contracts
- 2.
npx hardhat compile
- 3.Configure your Hardhat project for StealthTest
- 1.Within your
hardhat.config.js
- 2.Add an object called
networks
- 3.Inside that object, create an entry for
stealthtest
- 4.Add the
url
,chainId
, and a list ofaccounts
private keys you would like to use.- 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.As an option, you can add
stealthtest
as yourdefaultNetwork
so it will always be used.
Example
🧠
hardhat.config.js
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.18",
defaultNetwork: "stealthtest",
networks: {
stealthtest: {
url: "https://5937ec2d-1c79-41b8-a5d1-c288e0e2efc7.ethereum.staging-42.nameless.io",
chainId: 148073,
accounts: ["0xf5d82a795ec5c5751161334378841e7a765182a047ee071bdfb1184f67b78d76"],
},
},
};
- 4.Deploy your contracts
- 1.
npx hardhat run scripts/deploy.js
- 2.
stealthtest
is yourdefaultNetwork
, so your deployment(s) will be sent there