nUSD is an ETH backed coin, somewhat like WETH but with one basic difference. WETH's minting and burning process is proportional to the amount of ETH you deposit/ withdraw from the contract, and in the case of nUSD minting and burning depends on both, ETH amount you deposit/withdraw and price of ETH (in USD) at the time of minting/burning.
Instead of creating UI, I have used https://github.com/adrianmcli/eth95. Have been using this UI generator from some time and faced no issues.
User himself tries to reedem ETH, like no third-party is trying to redeem on behalf of the user (approve(), burnFrom() I believe these 2 functions explain the assumption).
-
Add Sepolia RPC URL and account private key in .env
-
Install dependencies using
npm i
-
Compile the contract using
npx hardhat compile
-
Deploy the contract using
npx hardhat run scripts/deploy.js --network <network-name>
-
Generate UI using the command
eth95 ./artifacts/contracts/nUSD.sol
-
Copy the deployed contract address logged in console after step 4 and paste it in the UI.
-
Connect your metamask and interact with the contract :)
Ensure your accounts have sufficient eth to deploy and interact.
To run the basic test cases run npx hardhat test test/basic-tests.js