无题
{"transactions":[{"hash":"0xc6006863c267735a11476b7f15b15bc718e117e2da114a2be815dd651e1a509f","type":"CALL","contractName":"Test","contractAddress":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","function":"multiple_arguments(uint256,address,uint256[]):(uint256)","arguments":["1","0000000000000000000000000000000000001337","[3,4]"],"tx":{"type":"0x02","from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","gas":"0x73b9","value":"0x0","data":"0x23e99187 ...
无题
{"name":"forge-std","version":"0.1.0","description":"Forge Standard Library is a collection of helpful contracts for use with forge and foundry","homepage":"https://book.getfoundry.sh/forge/forge-std","bugs":"https://github.com/foundry-rs/forge-std/issues","license":"(Apache-2.0 OR MIT)","author":"Contributors to forge-std","files":["src/*"],"repository":{"type":"git","url":"https://github.com/foundry-rs/forge-std.git"}}
无题
Forge Standard Library •
Forge Standard Library is a collection of helpful contracts for use with forge and foundry. It leverages forge’s cheatcodes to make writing tests easier and faster, while improving the UX of cheatcodes.
Learn how to use Forge Std with the 📖 Foundry Book (Forge Std Guide).
Install
1forge install foundry-rs/forge-std
Contracts
stdError
This is a helper contract for errors and reverts. In forge, this contract is particularly helpful for the expectRevert cheatcode, as it p ...
无题
const {expect} = require('chai');
const { ethers } = require('hardhat');
describe("ERC20 合约测试", ()=>{
it("合约部署", async () => {
// ethers.getSigners,代表eth账号 ethers 是一个全局函数,可以直接调用
const [owner, addr1, addr2] = await ethers.getSigners();
// ethers.js 中的 ContractFactory 是用于部署新智能合约的抽象,因此这里的 ERC20 是我们代币合约实例的工厂。ERC20代表contracts 文件夹中的 ERC20.sol 文件
const Token = await ethers.getContractFactory("ERC20");
// 部署合约, 传入参数 ERC20.sol 中的构造函数参数分别是 name, symbol 这里我们都叫做WTF
const h ...
无题
{"transactions":[{"hash":"0x3ded5d748168062f17923c0d3b139c80950564def78dcbb2c63bc732dbeca599","transactionType":"CREATE","contractName":"Counter","contractAddress":"0xb007167714e2940013EC3bb551584130B7497E22","function":null,"arguments":null,"transaction":{"type":"0x02","from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","gas":"0x21ddf","value":"0x0","data":"0x608060405234801561001057600080fd5b5060f78061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80633fb5c1cb146 ...
无题
{"transactions":[{"hash":"0x3ded5d748168062f17923c0d3b139c80950564def78dcbb2c63bc732dbeca599","transactionType":"CREATE","contractName":"Counter","contractAddress":"0xb007167714e2940013EC3bb551584130B7497E22","function":null,"arguments":null,"transaction":{"type":"0x02","from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","gas":"0x21ddf","value":"0x0","data":"0x608060405234801561001057600080fd5b5060f78061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80633fb5c1cb146 ...
无题
{"transactions":[{"hash":"0x3ded5d748168062f17923c0d3b139c80950564def78dcbb2c63bc732dbeca599","transactionType":"CREATE","contractName":"Counter","contractAddress":"0xb007167714e2940013EC3bb551584130B7497E22","function":null,"arguments":null,"transaction":{"type":"0x02","from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","gas":"0x21ddf","value":"0x0","data":"0x608060405234801561001057600080fd5b5060f78061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80633fb5c1cb146 ...
无题
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.21",
networks: {
goerli: {
url: "https://eth-goerli.g.alchemy.com/v2/API_KEY",
accounts: ["PRIVATE_KEY"],
},
},
etherscan: {
apiKey: "YOUR_ETHERSCAN_API_KEY",
},
};
无题
{"name":"tool06_hardhat","version":"1.0.0","description":"我最近在重新学solidity,巩固一下细节,也写一个“WTF Solidity极简入门”,供小白们使用),每周更新1-3讲。","main":"index.js","scripts":{"test":"echo \\\"Error: no test specified\\\" && exit 1"},"keywords":[],"author":"","license":"ISC","devDependencies":{"@nomicfoundation/hardhat-toolbox":"^4.0.0","hardhat":"^2.22.2"},"directories":{"test":"test"}}
无题
// 我们可以通过 npx hardhat run 来运行想要的脚本
// 这里你可以使用 npx hardhat run deploy.js 来运行
const hre = require("hardhat");
async function main() {
const Contract = await hre.ethers.getContractFactory("ERC20");
const token = await Contract.deploy("WTF","WTF");
await token.waitForDeployment();
console.log("成功部署合约:", token.target);
}
// 运行脚本
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});