mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2026-09-17 10:49:40 +02:00
Update url
This commit is contained in:
@@ -7,16 +7,23 @@ contract GiftableToken {
|
||||
address owner;
|
||||
mapping(address => bool) minters;
|
||||
|
||||
// Implements ERC20
|
||||
string public name;
|
||||
// Implements ERC20
|
||||
string public symbol;
|
||||
// Implements ERC20
|
||||
uint8 public decimals;
|
||||
// Implements ERC20
|
||||
uint256 public totalSupply;
|
||||
// Implements ERC20
|
||||
mapping (address => uint256) public balanceOf;
|
||||
// Implements ERC20
|
||||
mapping (address => mapping (address => uint256)) public allowance;
|
||||
|
||||
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
||||
event TransferFrom(address indexed _from, address indexed _to, address indexed _spender, uint256 _value);
|
||||
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
|
||||
event Mint(address indexed _minter, address indexed _beneficiary, uint256 _value);
|
||||
|
||||
constructor(string memory _name, string memory _symbol, uint8 _decimals) public {
|
||||
owner = msg.sender;
|
||||
@@ -32,6 +39,8 @@ contract GiftableToken {
|
||||
balanceOf[_to] += _value;
|
||||
totalSupply += _value;
|
||||
|
||||
emit Mint(msg.sender, _to, _value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,6 +60,7 @@ contract GiftableToken {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements ERC20
|
||||
function transfer(address _to, uint256 _value) public returns (bool) {
|
||||
require(balanceOf[msg.sender] >= _value);
|
||||
balanceOf[msg.sender] -= _value;
|
||||
@@ -59,6 +69,7 @@ contract GiftableToken {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements ERC20
|
||||
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
|
||||
require(allowance[_from][msg.sender] >= _value);
|
||||
require(balanceOf[_from] >= _value);
|
||||
@@ -69,9 +80,24 @@ contract GiftableToken {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements ERC20
|
||||
function approve(address _spender, uint256 _value) public returns (bool) {
|
||||
allowance[msg.sender][_spender] += _value;
|
||||
emit Approval(msg.sender, _spender, _value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements EIP165
|
||||
function supportsInterface(bytes4 _sum) {
|
||||
if (_sum == 0xc6bb4b70) { // ERC20
|
||||
return true;
|
||||
}
|
||||
if (_sum == 0x449a52f8) { // Minter
|
||||
return true;
|
||||
}
|
||||
if (_sum == 0x01ffc9a7) { // EIP165
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user