使用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
在合约中添加日志
- 导入import “hardhat/console.sol”;
- 方法中console.log(“mint: feeOn=%u totalSupply=%u”,feeOn,totalSupply);
- 在运行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;
}