【Hardhat 运行本地Node】

  • 使用命令yarn hardhat node启动本地节点 (终端不关闭)
  • hardhat.config.js中配置本地localhost节点
module.exports = {
  defaultNetwork: "hardhat",
  networks: {
    bsctest: {
      url: BSCTEST_RPC_URL,
      accounts: [PRIVATE_KEY],
      gasPrice: 1500000000,
      chainId: 97
    },
    localhost: {
      url: "http://127.0.0.1:8545/",
      // accounts: 不用配置,默认使用本地节点的账号
      chainId: 31337
    }
  },
  solidity: "0.8.19",
  etherscan: {
    apiKey: BSCSCAN_API_KEY
  }
};
  • 然后再新建一个终端窗口
  • 最后在新窗口中运行yarn hardhat run .\scripts\deploy.js --network localhost
> yarn hardhat run .\scripts\deploy.js --network localhost

Deploying contract...
Deployed contract address: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Current Value is : 0
Updated Value is: 7
Done in 1.88s.
  • 切换到运行本地节点的窗口,可以查到具体的日志信息
eth_chainId
eth_accounts
hardhat_metadata (20)
eth_blockNumber
eth_getBlockByNumber
eth_feeHistory
eth_sendTransaction
  Contract deployment: SimpleStorage
  Contract address:    0x5fbdb2315678afecb367f032d93f642f64180aa3
  Transaction:         0x4513914f378ac34a126e911c7bc4812924d4b07cb2471f5b7e2468d5be68019b
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  Value:               0 ETH
  Gas used:            562691 of 30000000
  Block #1:            0x3c7602aac34eceaa1578f447426a376745b565565e43560619ad4579d40d687d

eth_getTransactionByHash
eth_getTransactionReceipt
eth_blockNumber
eth_call
  Contract call:       SimpleStorage#retrieve
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x5fbdb2315678afecb367f032d93f642f64180aa3

eth_blockNumber
eth_feeHistory
eth_sendTransaction
  Contract call:       SimpleStorage#store
  Transaction:         0x260c8c546f56b715788a06ae7c8314829c32143e65df27c10afdc24e14bf1df8
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x5fbdb2315678afecb367f032d93f642f64180aa3
  Value:               0 ETH
  Gas used:            43724 of 30000000
  Block #2:            0x5945408b94f401a74121d91a3717f1f80608885ea7848c566108e1713e58d0b3

eth_getTransactionByHash
eth_getTransactionReceipt
eth_call
  Contract call:       SimpleStorage#retrieve
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x5fbdb2315678afecb367f032d93f642f64180aa3

eth_blockNumber
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值