WARNING: This example project uses Hardhat 3, which is still in development. Hardhat 3 is not yet intended for production use.
Welcome to the Hardhat 3 alpha version! This project showcases some of the changes and new features coming in Hardhat 3.
To learn more about the Hardhat 3 Alpha, please visit its tutorial. To share your feedback, join our Hardhat 3 Alpha Telegram group or open an issue in our GitHub issue tracker.
This example project includes:
- A simple Hardhat configuration file.
- Foundry-compatible Solidity unit tests.
- TypeScript integration tests using
node:test
, the new Node.js native test runner, andviem
. - Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet.
To get the most out of this example project, we recommend exploring the files in the following order:
- Read the
hardhat.config.ts
file, which contains the project configuration and explains multiple changes. - Review the "Running Tests" section and explore the files in the
contracts/
andtest/
directories. - Read the "Make a deployment to Sepolia" section and follow the instructions.
Each file includes inline explanations of its purpose and highlights the changes and new features introduced in Hardhat 3.
To run all the tests in the project, execute the following command:
npx hardhat test
You can also selectively run the Solidity or node:test
tests:
npx hardhat test solidity
npx hardhat test node
This project includes an example Ignition module to deploy the contract. You can deploy this module to a locally simulated chain or to Sepolia.
To run the deployment to a local chain:
npx hardhat ignition deploy ignition/modules/Counter.ts
To run the deployment to Sepolia, you need an account with funds to send the transaction. The provided Hardhat configuration includes a Configuration Variable called SEPOLIA_PRIVATE_KEY
, which you can use to set the private key of the account you want to use.
You can set the SEPOLIA_PRIVATE_KEY
variable using the hardhat-keystore
plugin or by setting it as an environment variable.
To set the SEPOLIA_PRIVATE_KEY
config variable using hardhat-keystore
:
npx hardhat keystore set SEPOLIA_PRIVATE_KEY
After setting the variable, you can run the deployment with the Sepolia network:
npx hardhat ignition deploy --network sepolia ignition/modules/Counter.ts
Feel free to explore the project and provide feedback on your experience with Hardhat 3 Alpha!
This project contains a test suite for the IonicDebtToken contract that uses a forked Mode mainnet for testing interactions with existing contracts.
- Node.js (v18 or higher)
- npm or yarn
- A Mode mainnet RPC URL (default uses public endpoint but may be rate-limited)
- Clone the repository:
git clone https://github.com/your-username/ionic-recovery.git
cd ionic-recovery
- Install dependencies:
npm install
- Set up your environment variables by creating a
.env
file:
MODE_MAINNET_RPC_URL=https://mainnet.mode.network
# Or use your own RPC provider:
# MODE_MAINNET_RPC_URL=https://your-mode-rpc-provider.com
To run the tests on a forked Mode mainnet:
npx hardhat test test/IonicDebtToken.fork.ts
The tests use Hardhat's network forking capability to create a local copy of the Mode mainnet. This allows:
- Interaction with existing deployed contracts
- Impersonating accounts that hold tokens needed for testing
- Testing of contract functionalities in a realistic mainnet environment
- Verifying contract behavior with actual token pricing and exchange rates
The Mode mainnet fork test uses the following configuration:
- Forks from a specific block for consistent testing
- Impersonates a whale account to obtain ion tokens for testing
- Tests the full lifecycle of the IonicDebtToken contract:
- Whitelisting ion tokens
- Setting and updating scale factors
- Minting debt tokens by providing whitelisted ion tokens
- Withdrawing collected ion tokens
If you need to test with different token addresses or configurations:
- Update the Mode mainnet addresses in
test/IonicDebtToken.fork.ts
:
const MODE_MAINNET_ADDRESSES = {
USDC: "0xd988097fb8612ae244b87df08e2abe6c3f25b08b", // Mode USDC address
MASTER_PRICE_ORACLE: "your-oracle-address",
SAMPLE_ION_TOKEN: "your-ion-token-address",
WHALE_ADDRESS: "address-with-ion-tokens",
};
- Adjust the test parameters as needed for your specific testing scenario.
The test attempts to use the ABIs from compiled artifacts. Make sure to compile your contracts first:
npx hardhat compile