2. Configure hardhat.config.js
⚠️ Important Security WarningDo Not Commit Sensitive Information
Accidentally committing sensitive information such as seed phrases can lead to the loss of funds. Always double-check your code and configurations before committing. Use
.gitignore
files and environment variables to protect sensitive data.
After successfully setting up your Hardhat project, the next step is to configure the hardhat.config.js file. This will be the essential configuration file where you can customize the networks, plugins, compiler settings, and more.
Open the
hardhat.config.js
file
⚠️Note: Avoid using import "@openzeppelin/hardhat-upgrades";
because this library calls getStorageAt
, which will not work if storage is disabled.

Set a variable with your private key
To set the variable, use the following command:
npx hardhat vars set PRIVATE_KEY
After running the command, you will be prompted to enter your private key.
You can read more about setting the configuration variables here.
Setup the Swisstronik's network
require("@nomicfoundation/hardhat-toolbox");
// Remember to use the private key of a testing account
// For better security practices, it's recommended to use npm i dotenv for storing secret variables
//use configuration-variables in hardhat to set PRIVATE_KEY variable
const PRIVATE_KEY = vars.get("PRIVATE_KEY");
module.exports = {
defaultNetwork: "swisstronik",
solidity: "0.8.19",
networks: {
swisstronik: {
url: "https://json-rpc.testnet.swisstronik.com/",
accounts: [`0x` + `${PRIVATE_KEY}`],
},
},
};
Make sure you have enough funds in this wallet to deploy/interact with the smart contract. otherwise, you can get SWTR test tokens here
Last updated