mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2024-11-21 17:26:47 +01:00
Add static token contract
This commit is contained in:
parent
c7b8ccfa62
commit
04cfd96dbb
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = eth-erc20
|
||||
version = 0.1.5
|
||||
version = 0.1.7
|
||||
description = ERC20 interface and simple contract with deployment script that lets any address mint and gift itself tokens.
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
@ -30,11 +30,14 @@ packages =
|
||||
eth_erc20
|
||||
eth_erc20.data
|
||||
eth_erc20.runnable
|
||||
static_token.data
|
||||
|
||||
[options.package_data]
|
||||
* =
|
||||
data/GiftableToken.json
|
||||
data/GiftableToken.bin
|
||||
data/StaticToken.json
|
||||
data/StaticToken.bin
|
||||
data/ERC20.json
|
||||
|
||||
[options.entry_points]
|
||||
@ -44,3 +47,4 @@ console_scripts =
|
||||
giftable-token-minter = giftable_erc20_token.runnable.minter:main
|
||||
erc20-transfer = eth_erc20.runnable.transfer:main
|
||||
erc20-balance = eth_erc20.runnable.balance:main
|
||||
erc20-info = eth_erc20.runnable.info:main
|
||||
|
1
python/static_token/data/StaticToken.bin
Normal file
1
python/static_token/data/StaticToken.bin
Normal file
File diff suppressed because one or more lines are too long
1
python/static_token/data/StaticToken.json
Normal file
1
python/static_token/data/StaticToken.json
Normal file
@ -0,0 +1 @@
|
||||
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_supply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
|
File diff suppressed because one or more lines are too long
@ -4,7 +4,11 @@ all:
|
||||
$(SOLC) --bin GiftableToken.sol --evm-version byzantium | awk 'NR>3' > GiftableToken.bin
|
||||
truncate -s -1 GiftableToken.bin
|
||||
$(SOLC) --abi GiftableToken.sol --evm-version byzantium | awk 'NR>3' > GiftableToken.json
|
||||
$(SOLC) --bin StaticToken.sol --evm-version byzantium | awk 'NR>3' > StaticToken.bin
|
||||
truncate -s -1 StaticToken.bin
|
||||
$(SOLC) --abi StaticToken.sol --evm-version byzantium | awk 'NR>3' > StaticToken.json
|
||||
|
||||
install: all
|
||||
cp -v *{json,bin} ../python/giftable_erc20_token/data/
|
||||
cp -v Giftable*{json,bin} ../python/giftable_erc20_token/data/
|
||||
cp -v Static*{json,bin} ../python/static_token/data/
|
||||
|
||||
|
76
solidity/StaticToken.sol
Normal file
76
solidity/StaticToken.sol
Normal file
@ -0,0 +1,76 @@
|
||||
pragma solidity >0.6.11;
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
contract StaticToken {
|
||||
|
||||
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);
|
||||
|
||||
constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _supply) public {
|
||||
owner = msg.sender;
|
||||
name = _name;
|
||||
symbol = _symbol;
|
||||
decimals = _decimals;
|
||||
totalSupply = _supply;
|
||||
balanceOf[owner] = _supply;
|
||||
}
|
||||
|
||||
// Implements ERC20
|
||||
function transfer(address _to, uint256 _value) public returns (bool) {
|
||||
require(balanceOf[msg.sender] >= _value);
|
||||
balanceOf[msg.sender] -= _value;
|
||||
balanceOf[_to] += _value;
|
||||
emit Transfer(msg.sender, _to, _value);
|
||||
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);
|
||||
allowance[_from][msg.sender] = allowance[_from][msg.sender] - _value;
|
||||
balanceOf[_from] -= _value;
|
||||
balanceOf[_to] += _value;
|
||||
emit TransferFrom(_from, _to, msg.sender, _value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements ERC20
|
||||
function approve(address _spender, uint256 _value) public returns (bool) {
|
||||
if (_value > 0) {
|
||||
require(allowance[msg.sender][_spender] == 0);
|
||||
}
|
||||
allowance[msg.sender][_spender] = _value;
|
||||
emit Approval(msg.sender, _spender, _value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements EIP165
|
||||
function supportsInterface(bytes4 _sum) public returns (bool) {
|
||||
if (_sum == 0xc6bb4b70) { // ERC20
|
||||
return true;
|
||||
}
|
||||
if (_sum == 0x01ffc9a7) { // EIP165
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user