以太坊代币标准与ERC-20代币构建全解析
1. 代币创建与标准化需求
随着以太坊等智能合约平台的出现,使用智能合约创建代币变得十分容易。技术上,只需几行代码就能在以太坊上创建代币,示例代码如下:
pragma solidity ^0.8.0;
contract token {
mapping (address => uint) public coinBalanceOf;
event CoinTransfer(address sender, address receiver, uint amount);
/* Initializes contract with initial supply tokens to the creator of the
contract */
function tokenx(uint supply) public {
supply = 1000;
coinBalanceOf[msg.sender] = supply;
}
/* Very simple trade function */
function sendCoin(address receiver, uint amount) public returns(bool
sufficient) {
if (coinBalanceOf[msg.sender] < amount) return false;
coinBalanceOf[msg.sender] -= amount;
coinBalanceOf[rece
超级会员免费看
订阅专栏 解锁全文
1485

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



