commit 30baee6d198dff8b6a5904840fe832c45589a8e4
parent 27ea14772f023326963edf127a9d0c55d1d797b6
Author: nolash <dev@holbrook.no>
Date: Sun, 6 Dec 2020 14:12:49 +0100
Rewrite contract, new license, adds settable minters
Diffstat:
5 files changed, 135 insertions(+), 167 deletions(-)
diff --git a/python/LICENSE b/python/LICENSE
@@ -0,0 +1,45 @@
+ Bprotocol Foundation (Bancor) LICENSE
+
+1. SUBJECT TO THE PROVISIONS SET FORTH HEREIN, INCLUDING “EFFECTIVE DATE”, YOU CAN
+ USE THIS CODE, FILE AND/OR SOFTWARE (“SOFTWARE”) ONLY IN CONNECTION WITH THE
+ BANCOR LIQUIDITY NETWORK AND/OR THE USE OF BNT ("PERMITTED USE"). ANY OTHER USE IS
+ PROHIBITED UNLESS THE USER SHALL RECEIVE AN EXPLICIT PRIOR WRITTEN APPROVAL FROM
+ BPROTOCOL FOUNDATION (BANCOR) TO DO SO (PLEASE CONTACT license@bancor.network IN
+ THIS REGARD), WHICH APPROVAL, IF GIVEN, MAY REQUIRE THE OBTAINMENT OF SEPARATE
+ LICENSE UNDER A DIFFERENT LICENSING MODEL. USING THIS SOFTWARE NOT IN THE FRAME OF
+ SUCH PERMITTED USE MAY, AMONG OTHERS, ALSO BREACH PATENT RIGHTS CONCERNING PATENTS
+ WHICH ARE EMBODIED/INCORPORATED/USED IN THIS SOFTWARE.
+
+2. ANY SUCH PERMITTED USE SHOULD ALSO COMPLY WITH THE TERMS BELOW.
+
+3. Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+A. Redistributions of source code must retain the above copyright notice, this list
+ of conditions and the following disclaimer.
+B. Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+C. Neither the name of the copyright holder nor the names of its contributors may be
+ used to endorse or promote products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+EFFECTIVE DATE: THIS LICENSE SHALL APPLY ONLY TO SOFTWARE (OR ANY VERSION THEREOF),
+THAT HAS BEEN PUBLISHED AFTER THE DATE AND TIME THIS LICENSE HAS BEEN FIRST PUBLISHED
+(“EFFECTIVE DATE”); Any previous versions published prior to the effective date (“Older Versions”)
+shall remain licensed under the Apache License, Version 2.0 (the "Older Versions License");
+You may obtain a copy of the Older Version License at http://www.apache.org/licenses/LICENSE-2.0
+you may not use this file except in compliance with the Older Version License. Unless
+required by applicable law or agreed to in writing, Older Versions distributed under the
+Older Version License are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, either express or implied. See the Older Version License for the specific
+language governing permissions and limitations under the Older Version License.
diff --git a/python/giftable_erc20_token/runnable/deploy.py b/python/giftable_erc20_token/runnable/deploy.py
@@ -24,11 +24,11 @@ logging.getLogger('urllib3').setLevel(logging.WARNING)
argparser = argparse.ArgumentParser()
argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)')
-#argparser.add_argument('-g', '--gift', dest='g', action='store_true', help='If set, tokens will be gifted to all accounts in provider wallet')
argparser.add_argument('-n', '--name', dest='n', default='Giftable Token', type=str, help='Token name')
argparser.add_argument('-s', '--symbol', dest='s', default='GFT', type=str, help='Token symbol')
argparser.add_argument('-d', '--decimals', dest='d', default=18, type=int, help='Token decimals')
argparser.add_argument('-a', '--account', dest='a', action='append', type=str, help='Account to fund')
+argparser.add_argument('-m', '--minter', dest='m', action='append', type=str, help='Minter to add')
argparser.add_argument('--contracts-dir', dest='contracts_dir', type=str, default='.', help='Directory containing bytecode and abi')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('amount', type=int, help='Initial token supply (will be owned by contract creator)')
@@ -51,25 +51,34 @@ def main():
w3.eth.defaultAccount = w3.eth.accounts[0]
c = w3.eth.contract(abi=abi, bytecode=bytecode)
- tx_hash = c.constructor(args.n, args.s, args.d, args.amount).transact()
+ tx_hash = c.constructor(args.n, args.s, args.d).transact()
rcpt = w3.eth.getTransactionReceipt(tx_hash)
address = rcpt.contractAddress
c = w3.eth.contract(abi=abi, address=address)
logg.debug('construct tx {} address {}'.format(tx_hash.hex(), address))
+
balance = c.functions.balanceOf(w3.eth.defaultAccount).call()
- logg.info('balance {}: {}'.format(w3.eth.defaultAccount, balance))
+ logg.info('balance {}: {} {}'.format(w3.eth.defaultAccount, balance, tx_hash))
if args.a != None:
for a in args.a:
if a == w3.eth.defaultAccount:
continue
- tx_hash = c.functions.gift(a, args.amount).transact()
+ tx_hash_mint = c.functions.mint(args.amount).transact()
+ tx_hash_transfer = c.functions.transfer(a, args.amount).transact()
rcpt = w3.eth.getTransactionReceipt(tx_hash)
balance = c.functions.balanceOf(a).call()
logg.info('balance {}: {}'.format(a, balance))
+ if args.m != None:
+ for a in args.m:
+ if a == w3.eth.defaultAccount:
+ continue
+ tx_hash_minter = c.functions.addMinter(a).transact()
+ logg.info('minter {}'.format(a))
+
print(address)
diff --git a/solidity/GiftableToken.abi.json b/solidity/GiftableToken.abi.json
@@ -1 +1 @@
-[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_initialSupply","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":false,"internalType":"uint256","name":"_oldTotal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newTotal","type":"uint256"}],"name":"ChangedSupply","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"},{"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":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"gift","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","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"}]
+[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"}],"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":"_minter","type":"address"}],"name":"addMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowances","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":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"removeMinter","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"}]
diff --git a/solidity/GiftableToken.bin b/solidity/GiftableToken.bin
@@ -1 +1 @@
-60806040523480156200001157600080fd5b50604051620012db380380620012db833981810160405260808110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b838201915060208201858111156200006f57600080fd5b82518660018202830111640100000000821117156200008d57600080fd5b8083526020830192505050908051906020019080838360005b83811015620000c3578082015181840152602081019050620000a6565b50505050905090810190601f168015620000f15780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200011557600080fd5b838201915060208201858111156200012c57600080fd5b82518660018202830111640100000000821117156200014a57600080fd5b8083526020830192505050908051906020019080838360005b838110156200018057808201518184015260208101905062000163565b50505050905090810190601f168015620001ae5780820380516001836020036101000a031916815260200191505b506040526020018051906020019092919080519060200190929190505050600084511162000244576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4552525f494e56414c49445f4e414d450000000000000000000000000000000081525060200191505060405180910390fd5b6000835111620002bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4552525f494e56414c49445f53594d424f4c000000000000000000000000000081525060200191505060405180910390fd5b8360009080519060200190620002d49291906200035e565b508260019080519060200190620002ed9291906200035e565b5081600260006101000a81548160ff021916908360ff1602179055508060038190555080600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050505062000414565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620003965760008555620003e2565b82601f10620003b157805160ff1916838001178555620003e2565b82800160010185558215620003e2579182015b82811115620003e1578251825591602001919060010190620003c4565b5b509050620003f19190620003f5565b5090565b5b8082111562000410576000816000905550600101620003f6565b5090565b610eb780620004246000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c806370a082311161006657806370a082311461024d57806395d89b41146102a5578063a9059cbb14610328578063cbce4c971461038c578063dd62ed3e146103f05761009e565b806306fdde03146100a3578063095ea7b31461012657806318160ddd1461018a57806323b872dd146101a8578063313ce5671461022c575b600080fd5b6100ab610468565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100eb5780820151818401526020810190506100d0565b50505050905090810190601f1680156101185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101726004803603604081101561013c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610506565b60405180821515815260200191505060405180910390f35b610192610700565b6040518082815260200191505060405180910390f35b610214600480360360608110156101be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610706565b60405180821515815260200191505060405180910390f35b610234610997565b604051808260ff16815260200191505060405180910390f35b61028f6004803603602081101561026357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109aa565b6040518082815260200191505060405180910390f35b6102ad6109c2565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ed5780820151818401526020810190506102d2565b50505050905090810190601f16801561031a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103746004803603604081101561033e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a60565b60405180821515815260200191505060405180910390f35b6103d8600480360360408110156103a257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610be6565b60405180821515815260200191505060405180910390f35b6104526004803603604081101561040657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610db6565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104fe5780601f106104d3576101008083540402835291602001916104fe565b820191906000526020600020905b8154815290600101906020018083116104e157829003601f168201915b505050505081565b60008261051281610ddb565b600083148061059d57506000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b61060f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4552525f494e56414c49445f414d4f554e54000000000000000000000000000081525060200191505060405180910390fd5b82600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a3600191505092915050565b60035481565b60008361071281610ddb565b8361071c81610ddb565b83600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555083600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555083600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a36001925050509392505050565b600260009054906101000a900460ff1681565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a585780601f10610a2d57610100808354040283529160200191610a58565b820191906000526020600020905b815481529060010190602001808311610a3b57829003601f168201915b505050505081565b600082610a6c81610ddb565b82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b600082610bf281610ddb565b82600354016003819055506000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905083600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f5f8b22485eeda034e9b3b8726a34dbff9aeea5105cbefd66dac32e2890de592e81600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808381526020018281526020019250505060405180910390a18473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a360019250505092915050565b6005602052816000526040600020602052806000526040600020600091509150505481565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e7e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4552525f494e56414c49445f414444524553530000000000000000000000000081525060200191505060405180910390fd5b5056fea2646970667358221220c03c933fbef61b72e1494c56e20cc2e1a0f185aed6ac65f30476e92f2c11677564736f6c63430007040033
-\ No newline at end of file
+60806040523480156200001157600080fd5b50604051620010e2380380620010e2833981810160405260608110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b838201915060208201858111156200006f57600080fd5b82518660018202830111640100000000821117156200008d57600080fd5b8083526020830192505050908051906020019080838360005b83811015620000c3578082015181840152602081019050620000a6565b50505050905090810190601f168015620000f15780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200011557600080fd5b838201915060208201858111156200012c57600080fd5b82518660018202830111640100000000821117156200014a57600080fd5b8083526020830192505050908051906020019080838360005b838110156200018057808201518184015260208101905062000163565b50505050905090810190601f168015620001ae5780820380516001836020036101000a031916815260200191505b5060405260200180519060200190929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600290805190602001906200021a929190620002af565b50816003908051906020019062000233929190620002af565b5080600460006101000a81548160ff021916908360ff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050505062000365565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620002e7576000855562000333565b82601f106200030257805160ff191683800117855562000333565b8280016001018555821562000333579182015b828111156200033257825182559160200191906001019062000315565b5b50905062000342919062000346565b5090565b5b808211156200036157600081600090555060010162000347565b5090565b610d6d80620003756000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806355b6ed5c1161007157806355b6ed5c146102bd57806370a082311461033557806395d89b411461038d578063983b2d5614610410578063a0712d681461046a578063a9059cbb146104ae576100b4565b806306fdde03146100b9578063095ea7b31461013c57806318160ddd146101a057806323b872dd146101be5780633092afd514610242578063313ce5671461029c575b600080fd5b6100c1610512565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101886004803603604081101561015257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105b0565b60405180821515815260200191505060405180910390f35b6101a86106ab565b6040518082815260200191505060405180910390f35b61022a600480360360608110156101d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b1565b60405180821515815260200191505060405180910390f35b6102846004803603602081101561025857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108d3565b60405180821515815260200191505060405180910390f35b6102a46109c5565b604051808260ff16815260200191505060405180910390f35b61031f600480360360408110156102d357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109d8565b6040518082815260200191505060405180910390f35b6103776004803603602081101561034b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109fd565b6040518082815260200191505060405180910390f35b610395610a15565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d55780820151818401526020810190506103ba565b50505050905090810190601f1680156104025780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104526004803603602081101561042657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ab3565b60405180821515815260200191505060405180910390f35b6104966004803603602081101561048057600080fd5b8101908080359060200190929190505050610b6e565b60405180821515815260200191505060405180910390f35b6104fa600480360360408110156104c457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c2c565b60405180821515815260200191505060405180910390f35b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105a85780601f1061057d576101008083540402835291602001916105a8565b820191906000526020600020905b81548152906001019060200180831161058b57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60055481565b600081600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f5f7542858008eeb041631f30e6109ae94b83a58e9a58261dd2c42c508850f939856040518082815260200191505060405180910390a4600190509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061095b57508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61096457600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b600460009054906101000a900460ff1681565b6007602052816000526040600020602052806000526040600020600091509150505481565b60066020528060005260406000206000915090505481565b60038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aab5780601f10610a8057610100808354040283529160200191610aab565b820191906000526020600020905b815481529060010190602001808311610a8e57829003601f168201915b505050505081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b0e57600080fd5b60018060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610bc657600080fd5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508160056000828254019250508190555060019050919050565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509291505056fea26469706673582212200b85b942c63f47042a88c63582e4de8fd6a9606fc84b94711dac4024d2413c7764736f6c63430007050033
+\ No newline at end of file
diff --git a/solidity/GiftableToken.sol b/solidity/GiftableToken.sol
@@ -1,160 +1,74 @@
-pragma solidity ^0.6.12;
-
-// SPDX-License-Identifier: SEE LICENSE IN LICENSE
-
-/*
- * This is a MOCK token used for DEVELOPMENT PURPOSES ONLY.
- * It allows anyone to freely mint tokens with themselves as beneficiaries
- * Code is based on the ERC20Token contract from Bancor's contracts-solidity repository
- *
- * @dev ERC20 Standard Token implementation
-*/
-
-contract GiftableToken { //is IERC20Token, Utils {
- //using SafeMath for uint256;
-
- string public name;
- string public symbol;
- uint8 public decimals;
- uint256 public totalSupply;
- mapping (address => uint256) public balanceOf;
- mapping (address => mapping (address => uint256)) public allowance;
-
- /**
- * @dev triggered when tokens are transferred between wallets
- *
- * @param _from source address
- * @param _to target address
- * @param _value transfer amount
- */
- event Transfer(address indexed _from, address indexed _to, uint256 _value);
-
- /**
- * @dev triggered when a wallet allows another wallet to transfer tokens from on its behalf
- *
- * @param _owner wallet that approves the allowance
- * @param _spender wallet that receives the allowance
- * @param _value allowance amount
- */
- event Approval(address indexed _owner, address indexed _spender, uint256 _value);
-
- event ChangedSupply(uint256 _oldTotal, uint256 _newTotal);
-
- /**
- * @dev initializes a new ERC20Token instance
- *
- * @param _name token name
- * @param _symbol token symbol
- * @param _decimals decimal points, for display purposes
- * @param _initialSupply total supply of token units
- */
- constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _initialSupply) public {
- // validate input
- require(bytes(_name).length > 0, "ERR_INVALID_NAME");
- require(bytes(_symbol).length > 0, "ERR_INVALID_SYMBOL");
-
- name = _name;
- symbol = _symbol;
- decimals = _decimals;
- totalSupply = _initialSupply;
- balanceOf[msg.sender] = _initialSupply;
- }
-
- // validates an address - currently only checks that it isn't null
- modifier validAddress(address _address) {
- _validAddress(_address);
- _;
- }
-
- // error message binary size optimization
- function _validAddress(address _address) internal pure {
- require(_address != address(0), "ERR_INVALID_ADDRESS");
- }
-
-
- function gift(address _to, uint256 _value)
- public
- virtual
- validAddress(_to)
- returns (bool)
- {
- totalSupply = totalSupply + _value;
- uint256 oldSupply = balanceOf[_to];
- balanceOf[_to] = balanceOf[_to] + _value;
- emit ChangedSupply(oldSupply, balanceOf[_to]);
- emit Transfer(address(0x00), _to, _value);
- return true;
- }
-
- /**
- * @dev transfers tokens to a given address
- * throws on any error rather then return a false flag to minimize user errors
- *
- * @param _to target address
- * @param _value transfer amount
- *
- * @return true if the transfer was successful, false if it wasn't
- */
- function transfer(address _to, uint256 _value)
- public
- virtual
- validAddress(_to)
- returns (bool)
- {
- balanceOf[msg.sender] = balanceOf[msg.sender] - _value;
- balanceOf[_to] = balanceOf[_to] + _value;
- emit Transfer(msg.sender, _to, _value);
- return true;
- }
-
- /**
- * @dev transfers tokens to a given address on behalf of another address
- * throws on any error rather then return a false flag to minimize user errors
- *
- * @param _from source address
- * @param _to target address
- * @param _value transfer amount
- *
- * @return true if the transfer was successful, false if it wasn't
- */
- function transferFrom(address _from, address _to, uint256 _value)
- public
- virtual
- validAddress(_from)
- validAddress(_to)
- returns (bool)
- {
- allowance[_from][msg.sender] = allowance[_from][msg.sender] - _value;
- balanceOf[_from] = balanceOf[_from] - _value;
- balanceOf[_to] = balanceOf[_to] + _value;
- emit Transfer(_from, _to, _value);
- return true;
- }
-
- /**
- * @dev allows another account/contract to transfers tokens on behalf of the caller
- * throws on any error rather then return a false flag to minimize user errors
- *
- * also, to minimize the risk of the approve/transferFrom attack vector
- * (see https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/), approve has to be called twice
- * in 2 separate transactions - once to change the allowance to 0 and secondly to change it to the new allowance value
- *
- * @param _spender approved address
- * @param _value allowance amount
- *
- * @return true if the approval was successful, false if it wasn't
- */
- function approve(address _spender, uint256 _value)
- public
- virtual
- validAddress(_spender)
- returns (bool)
- {
- // if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal
- require(_value == 0 || allowance[msg.sender][_spender] == 0, "ERR_INVALID_AMOUNT");
-
- allowance[msg.sender][_spender] = _value;
- emit Approval(msg.sender, _spender, _value);
- return true;
- }
-}
+pragma solidity >=0.6.12;
+
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+contract GiftableToken {
+
+ address owner;
+ mapping(address => bool) minters;
+
+ string public name;
+ string public symbol;
+ uint8 public decimals;
+ uint256 public totalSupply;
+ mapping (address => uint256) public balanceOf;
+ mapping (address => mapping (address => uint256)) public allowances;
+
+ 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) {
+ owner = msg.sender;
+ name = _name;
+ symbol = _symbol;
+ decimals = _decimals;
+ minters[msg.sender] = true;
+ }
+
+ function mint(uint256 _value) public returns (bool) {
+ require(minters[msg.sender]);
+
+ balanceOf[msg.sender] += _value;
+ totalSupply += _value;
+
+ return true;
+ }
+
+ function addMinter(address _minter) public returns (bool) {
+ require(msg.sender == owner);
+
+ minters[_minter] = true;
+
+ return true;
+ }
+
+ function removeMinter(address _minter) public returns (bool) {
+ require(msg.sender == owner || msg.sender == _minter);
+
+ minters[_minter] = false;
+
+ return true;
+ }
+
+ function transfer(address _to, uint256 _value) public returns (bool) {
+ balanceOf[msg.sender] -= _value;
+ balanceOf[_to] += _value;
+ emit Transfer(msg.sender, _to, _value);
+ return true;
+ }
+
+ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
+ allowances[_from][msg.sender] = allowances[_from][msg.sender] - _value;
+ balanceOf[_from] -= _value;
+ balanceOf[_to] += _value;
+ emit TransferFrom(_from, _to, msg.sender, _value);
+ return true;
+ }
+
+ function approve(address _spender, uint256 _value) public returns (bool) {
+ allowances[msg.sender][_spender] += _value;
+ emit Approval(msg.sender, _spender, _value);
+ return true;
+ }
+}