diff --git a/packages/hardhat/deploy/00_deploy_your_contract.ts b/packages/hardhat/deploy/00_deploy_your_contract.ts index 418b91218..1c12ac796 100644 --- a/packages/hardhat/deploy/00_deploy_your_contract.ts +++ b/packages/hardhat/deploy/00_deploy_your_contract.ts @@ -1,5 +1,6 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; import { DeployFunction } from "hardhat-deploy/types"; +import { Contract } from "ethers"; /** * Deploys a contract named "YourContract" using the deployer account and @@ -31,8 +32,9 @@ const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEn autoMine: true, }); - // Get the deployed contract - // const yourContract = await hre.ethers.getContract("YourContract", deployer); + // Get the deployed contract to interact with it after deploying. + const yourContract = await hre.ethers.getContract("YourContract", deployer); + console.log("👋 Initial greeting:", await yourContract.greeting()); }; export default deployYourContract; diff --git a/packages/hardhat/package.json b/packages/hardhat/package.json index 77d626828..178dd6cda 100644 --- a/packages/hardhat/package.json +++ b/packages/hardhat/package.json @@ -33,7 +33,7 @@ "eslint": "^8.26.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", - "ethers": "^5.7.1", + "ethers": "^6.10.0", "hardhat": "^2.19.4", "hardhat-deploy": "^0.11.45", "hardhat-deploy-ethers": "^0.4.1", diff --git a/packages/hardhat/scripts/listAccount.ts b/packages/hardhat/scripts/listAccount.ts index 0f95f7275..ffc46d491 100644 --- a/packages/hardhat/scripts/listAccount.ts +++ b/packages/hardhat/scripts/listAccount.ts @@ -24,10 +24,11 @@ async function main() { try { const network = availableNetworks[networkName]; if (!("url" in network)) continue; - const provider = new ethers.providers.JsonRpcProvider(network.url); + const provider = new ethers.JsonRpcProvider(network.url); + await provider._detectNetwork(); const balance = await provider.getBalance(address); console.log("--", networkName, "-- 📡"); - console.log(" balance:", +ethers.utils.formatEther(balance)); + console.log(" balance:", +ethers.formatEther(balance)); console.log(" nonce:", +(await provider.getTransactionCount(address))); } catch (e) { console.log("Can't connect to network", networkName); diff --git a/packages/hardhat/test/YourContract.ts b/packages/hardhat/test/YourContract.ts index 67a6174ae..a44cf04e1 100644 --- a/packages/hardhat/test/YourContract.ts +++ b/packages/hardhat/test/YourContract.ts @@ -10,7 +10,7 @@ describe("YourContract", function () { const [owner] = await ethers.getSigners(); const yourContractFactory = await ethers.getContractFactory("YourContract"); yourContract = (await yourContractFactory.deploy(owner.address)) as YourContract; - await yourContract.deployed(); + await yourContract.waitForDeployment(); }); describe("Deployment", function () { diff --git a/yarn.lock b/yarn.lock index 46ba4e282..99be4a237 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1841,7 +1841,7 @@ __metadata: eslint: ^8.26.0 eslint-config-prettier: ^8.5.0 eslint-plugin-prettier: ^4.2.1 - ethers: ^5.7.1 + ethers: ^6.10.0 hardhat: ^2.19.4 hardhat-deploy: ^0.11.45 hardhat-deploy-ethers: ^0.4.1 @@ -2535,6 +2535,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:18.15.13": + version: 18.15.13 + resolution: "@types/node@npm:18.15.13" + checksum: 79cc5a2b5f98e8973061a4260a781425efd39161a0e117a69cd089603964816c1a14025e1387b4590c8e82d05133b7b4154fa53a7dffb3877890a66145e76515 + languageName: node + linkType: hard + "@types/node@npm:^10.0.3": version: 10.17.60 resolution: "@types/node@npm:10.17.60" @@ -3837,6 +3844,13 @@ __metadata: languageName: node linkType: hard +"aes-js@npm:4.0.0-beta.5": + version: 4.0.0-beta.5 + resolution: "aes-js@npm:4.0.0-beta.5" + checksum: cc2ea969d77df939c32057f7e361b6530aa6cb93cb10617a17a45cd164e6d761002f031ff6330af3e67e58b1f0a3a8fd0b63a720afd591a653b02f649470e15b + languageName: node + linkType: hard + "aes-js@npm:^3.1.2": version: 3.1.2 resolution: "aes-js@npm:3.1.2" @@ -6915,6 +6929,21 @@ __metadata: languageName: node linkType: hard +"ethers@npm:^6.10.0": + version: 6.10.0 + resolution: "ethers@npm:6.10.0" + dependencies: + "@adraffy/ens-normalize": 1.10.0 + "@noble/curves": 1.2.0 + "@noble/hashes": 1.3.2 + "@types/node": 18.15.13 + aes-js: 4.0.0-beta.5 + tslib: 2.4.0 + ws: 8.5.0 + checksum: 6f0a834b9b9bb31eceda9ac0a841b1061d5e2eefb5d0b042013db1c5abf48fa993ec0a602ae4c64d9e259d495fc01c100cf61f17e928e09eb43f0c7860f2a317 + languageName: node + linkType: hard + "ethjs-unit@npm:0.1.6": version: 0.1.6 resolution: "ethjs-unit@npm:0.1.6" @@ -13469,6 +13498,13 @@ __metadata: languageName: node linkType: hard +"tslib@npm:2.4.0": + version: 2.4.0 + resolution: "tslib@npm:2.4.0" + checksum: 8c4aa6a3c5a754bf76aefc38026134180c053b7bd2f81338cb5e5ebf96fefa0f417bff221592bf801077f5bf990562f6264fecbc42cd3309b33872cb6fc3b113 + languageName: node + linkType: hard + "tslib@npm:^2.0.0, tslib@npm:^2.1.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0": version: 2.6.2 resolution: "tslib@npm:2.6.2" @@ -14481,6 +14517,21 @@ __metadata: languageName: node linkType: hard +"ws@npm:8.5.0": + version: 8.5.0 + resolution: "ws@npm:8.5.0" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 76f2f90e40344bf18fd544194e7067812fb1372b2a37865678d8f12afe4b478ff2ebc0c7c0aff82cd5e6b66fc43d889eec0f1865c2365d8f7a66d92da7744a77 + languageName: node + linkType: hard + "ws@npm:^7.4.5, ws@npm:^7.4.6, ws@npm:^7.5.1": version: 7.5.9 resolution: "ws@npm:7.5.9"