hardhat入门
第一步:
mkdir hardhat-tutorial
cd hardhat-tutorial
npm init --yes
npm install --save-dev hardhat
npx hardhat
第二步、首先创建一个名为 contracts 的新目录,然后在目录内创建一个名为Token.sol的文件。
// Solidity files have to start with this pragma.
// It will be used by the Solidity compiler to validate its version.
pragma solidity ^0.7.0;
// This is the main building block for smart contracts.
contract Token {
// Some string type variables to identify the token.
string public name = "My Hardhat Token";
string public symbol = "MBT";
// 固定发行量
uint256 public totalSupply = 1000000;
// An address type variable is used to store ethereum accounts.
address public owner;
// A mapping is a key/value map. Here we store each account balance.
mapping(address => uint256) balances;
/**
* 合约构造函数
*
* The `constructor` is executed only once when the contract is created.
* The `public` modifier makes a function ca

这篇教程介绍了如何使用Hardhat进行智能合约的开发,包括创建合约目录、编写Token.sol合约、编译合约以及创建测试用例进行合约功能验证。通过这个过程,读者将学习到如何在以太坊网络上部署和管理自己的ERC20代币。
最低0.47元/天 解锁文章
2074

被折叠的 条评论
为什么被折叠?



