From 70358bde5a42c60f40a5b67667509d30e717055c Mon Sep 17 00:00:00 2001 From: cryptam <102138190+CryptAm@users.noreply.github.com> Date: Mon, 25 May 2026 10:08:12 +0300 Subject: [PATCH] Update Hardhat tutorial to ethers v6 API The examples use ethers v5 API (`contract.deployed()`, `contract.address`), but `@nomicfoundation/hardhat-toolbox` ships with ethers v6. Copy-pasting causes tests and deployment to fail with `TypeError: contract.deployed is not a function`. Also, `hardhat.config.js` calls `require("dotenv")`, but dotenv is not installed in the dependency setup step. Fixes: - Added `dotenv` to the `npm install` command - `await contract.deployed()` > `await contract.waitForDeployment()` - `contract.address` > `await contract.getAddress()` **Result:** The tutorial now matches the current Hardhat Toolbox, users can run setup, tests, and deployment without API fixes. --- .../tutorials/deploying-a-smart-contract/hardhat.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/build/tutorials/deploying-a-smart-contract/hardhat.mdx b/src/pages/build/tutorials/deploying-a-smart-contract/hardhat.mdx index 4d2ad31e..30cda93e 100644 --- a/src/pages/build/tutorials/deploying-a-smart-contract/hardhat.mdx +++ b/src/pages/build/tutorials/deploying-a-smart-contract/hardhat.mdx @@ -25,7 +25,7 @@ npm init -y 2. Install Hardhat and necessary dependencies: ```bash -npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox +npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox dotenv ``` 3. Create a new Hardhat project: @@ -122,7 +122,7 @@ describe("InkContract", function () { it("Should return the correct greeting", async function () { const InkContract = await ethers.getContractFactory("InkContract"); const contract = await InkContract.deploy(); - await contract.deployed(); + await contract.waitForDeployment(); expect(await contract.greeting()).to.equal("Hello, Ink!"); }); @@ -144,9 +144,9 @@ async function main() { const InkContract = await ethers.getContractFactory("InkContract"); const contract = await InkContract.deploy(); - await contract.deployed(); + await contract.waitForDeployment(); - console.log("InkContract deployed to:", contract.address); + console.log("InkContract deployed to:", await contract.getAddress); } main()