mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2026-04-27 21:01:04 +02:00
Rewrite contract, new license, adds settable minters
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user