solidity Remix hardhat console开发

使用Remix DeskTop开发

open folder

使用hardhat

npx hardhat init
调整配置hardhat.config.ts

import {HardhatUserConfig} from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

// @ts-ignore
const config: HardhatUserConfig = {
    solidity: {

        version: "0.8.28", // The version is a property *inside* the 'solidity' object
        // 👇 'settings' is also a property *inside* the 'solidity' object
        settings: {
            optimizer: {
                enabled: true,
                runs: 1000,     // Adjust runs if needed (e.g., 5000 or 10000 for size optimization)
            },
        },
    },
    networks: {
        hardhat: {
            chainId: 31337,
            allowUnlimitedContractSize: true,
        },
    }

};

export default config;

npx hardhat node

Remix DeskTops链接本地hardhat node

http://127.0.0.1:8545
ENVIRONMENT->Dev-Hardhat Provider

在合约中添加日志
  1. 导入import “hardhat/console.sol”;
  2. 方法中console.log(“mint: feeOn=%u totalSupply=%u”,feeOn,totalSupply);
  3. 在运行npx hardhat node终端下面可以看到日志信息
使用flutter 来调试合约

web3client

  static Web3Client getWeb3Client() {
    final httpClient = Client();
    var web3 = Web3Client(
      // "https://mainnet.infura.io/v3/${Constants.apiKey2}",
      // "https://sepolia.infura.io/v3/${Constants.apiKey2}",
      // "https://optimism-sepolia.infura.io/v3/${Constants.apiKey2}",
      //"https://polygon-mainnet.infura.io/v3/${Constants.apiKey2}",
       "http://127.0.0.1:8545",
      httpClient,
    );
    return web3;
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值