From fe9c800301d9e30ab2da78bd5f6209b6340c6de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=85=9C=E7=82=9C?= Date: Mon, 19 May 2025 10:52:08 +0800 Subject: [PATCH 1/2] style refactor index.js --- basic/06-ethersjs-waffle/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/basic/06-ethersjs-waffle/index.js b/basic/06-ethersjs-waffle/index.js index d9fed9abd..62450d7e8 100644 --- a/basic/06-ethersjs-waffle/index.js +++ b/basic/06-ethersjs-waffle/index.js @@ -1,4 +1,3 @@ -const fs = require("fs"); const SimpleToken = require("./build/SimpleToken.json"); const { ethers } = require("ethers"); @@ -27,7 +26,7 @@ let bal; // support eip1559 async function getGasPrice () { - return await web3Provider.getFeeData().then(async function (res) { + return await web3Provider.getFeeData().then(function (res) { let maxFeePerGas = res.maxFeePerGas; let maxPriorityFeePerGas = res.maxPriorityFeePerGas; console.log("maxFeePerGas: ", maxFeePerGas.toString()); @@ -52,6 +51,7 @@ async function checkBalance () { checkBalance(); let token; + async function deploy () { let option = await getGasPrice(); // 常见合约工厂实例 @@ -60,19 +60,24 @@ async function deploy () { SimpleToken.bytecode, wallet ); + console.log('start deploy') + token = await simpletoken.deploy("HEHE", "HH", 1, 100000000); console.log(token.target); await token.waitForDeployment(); console.log('deployed') + tx = await token.transfer( "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", ethers.parseEther("0.00000000001"), option ); + await tx.wait(); console.log('hash', tx.hash); + let bal = await token.balanceOf(wallet.address); console.log(bal.toString()); } From dc9582964fad4f481bba4c7935ba2f2d85d5c5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=85=9C=E7=82=9C?= Date: Wed, 21 May 2025 15:58:36 +0800 Subject: [PATCH 2/2] update 08-hardhat-graph/scripts/deploy.js --- basic/08-hardhat-graph/scripts/deploy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/basic/08-hardhat-graph/scripts/deploy.js b/basic/08-hardhat-graph/scripts/deploy.js index 5b01ef7ee..3dea7cfc2 100644 --- a/basic/08-hardhat-graph/scripts/deploy.js +++ b/basic/08-hardhat-graph/scripts/deploy.js @@ -15,6 +15,7 @@ async function main() { const Token = await ethers.getContractFactory('SimpleToken'); const token = await Token.deploy('HHToken', 'HHT', 1, 100000000); + await token.waitForDeployment(); console.log('Contract address:', token.target);