简单代币合约  / 学习智能合约#4

简单代币合约 / 学习智能合约#4

智能合约

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pragma solidity >=0.4.22 <0.7.0;

contract SimpleToken{
mapping(address => uint256) public balanceOf;
uint id;
constructor() public{
balanceOf[msg.sender] = 1000000;
}

function transfer(address _to, uint256 _value) public{
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
}
}

把帐本信息存入一个mapping(映射)中,实现简单的转帐功能!代币想发多少有多少!


This page is synchronized from the post: ‘简单代币合约 / 学习智能合约#4’

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×