mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2024-11-22 01:36:46 +01:00
Use external keystore file for signing.
This commit is contained in:
parent
9dffd5d2f7
commit
1281db8571
@ -1,3 +1,6 @@
|
||||
* 0.0.7-unreleased
|
||||
- Implement keystore signing.
|
||||
- Change makefile to compile contract for Byzantium.
|
||||
* 0.0.6
|
||||
- Rename contracts-dir flag to abi-dir
|
||||
- Use package data dir as default abi dir
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
[{"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"}]
|
||||
[{"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":"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":"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"}]
|
||||
|
@ -8,13 +8,16 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
import time
|
||||
|
||||
# third-party imports
|
||||
import web3
|
||||
from eth_keys import keys
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
@ -25,14 +28,19 @@ logging.getLogger('urllib3').setLevel(logging.WARNING)
|
||||
script_dir = os.path.dirname(__file__)
|
||||
data_dir = os.path.join(script_dir, '..', 'data')
|
||||
|
||||
|
||||
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('-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('-o', '--owner', dest='o', type=str, help='Reserve owner account')
|
||||
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('-w', action='store_true', help='Wait for the last transaction to be confirmed')
|
||||
argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed')
|
||||
argparser.add_argument('-e', action='store_true', help='Treat all transactions as essential')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='Ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
|
||||
argparser.add_argument('--name', dest='n', default='Giftable Token', type=str, help='Token name')
|
||||
argparser.add_argument('--symbol', dest='s', default='GFT', type=str, help='Token symbol')
|
||||
argparser.add_argument('--decimals', dest='d', default=18, type=int, help='Token decimals')
|
||||
argparser.add_argument('--account', action='append', type=str, help='Account to fund')
|
||||
argparser.add_argument('--minter', action='append', type=str, help='Minter to add')
|
||||
argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default=data_dir, help='Directory containing bytecode and abi (default: {})'.format(data_dir))
|
||||
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)')
|
||||
@ -41,8 +49,44 @@ args = argparser.parse_args()
|
||||
if args.v:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
|
||||
block_mode = 0
|
||||
if args.ww:
|
||||
logg.debug('set block after each tx')
|
||||
block_mode = 2
|
||||
elif args.w:
|
||||
logg.debug('set block until last tx')
|
||||
block_mode = 1
|
||||
|
||||
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
|
||||
|
||||
private_key = None
|
||||
signer_address = None
|
||||
if args.y != None:
|
||||
logg.debug('loading keystore file {}'.format(args.y))
|
||||
f = open(args.y, 'r')
|
||||
encrypted_key = f.read()
|
||||
f.close()
|
||||
private_key = w3.eth.account.decrypt(encrypted_key, '')
|
||||
private_key_object = keys.PrivateKey(private_key)
|
||||
signer_address = private_key_object.public_key.to_checksum_address()
|
||||
logg.debug('now have key for signer address {}'.format(signer_address))
|
||||
|
||||
network_pair = args.i.split(':')
|
||||
network_id = int(network_pair[1])
|
||||
|
||||
|
||||
def waitFor(tx_hash):
|
||||
i = 1
|
||||
while True:
|
||||
try:
|
||||
return w3.eth.getTransactionReceipt(tx_hash)
|
||||
except web3.exceptions.TransactionNotFound:
|
||||
logg.debug('poll #{} for {}'.format(i, tx_hash.hex()))
|
||||
i += 1
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def main():
|
||||
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
|
||||
|
||||
f = open(os.path.join(args.abi_dir, 'GiftableToken.json'), 'r')
|
||||
abi = json.load(f)
|
||||
@ -52,40 +96,120 @@ def main():
|
||||
bytecode = f.read()
|
||||
f.close()
|
||||
|
||||
w3.eth.defaultAccount = w3.eth.accounts[0]
|
||||
if args.o != None:
|
||||
w3.eth.defaultAccount = args.o
|
||||
gas_price = w3.eth.gasPrice
|
||||
|
||||
last_tx = None
|
||||
|
||||
nonce = w3.eth.getTransactionCount(signer_address, 'pending')
|
||||
|
||||
c = w3.eth.contract(abi=abi, bytecode=bytecode)
|
||||
tx_hash = c.constructor(args.n, args.s, args.d).transact()
|
||||
rcpt = w3.eth.getTransactionReceipt(tx_hash)
|
||||
tx = c.constructor(args.n, args.s, args.d).buildTransaction({
|
||||
'chainId': network_id,
|
||||
'gas': 1500000,
|
||||
'gasPrice': gas_price,
|
||||
'nonce': nonce,
|
||||
}) #transact()
|
||||
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
|
||||
tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
|
||||
last_tx = tx_hash
|
||||
rcpt = waitFor(tx_hash)
|
||||
if rcpt['status'] == 0:
|
||||
logg.critial('constructor transaction failed {}'.format(tx_hash))
|
||||
sys.exit(1)
|
||||
else:
|
||||
logg.info('constructor succeeded. gas used: {}'.format(rcpt['gasUsed']))
|
||||
|
||||
address = rcpt.contractAddress
|
||||
logg.debug('token contract mined {} {} {} {}'.format(address, args.n, args.s, args.d))
|
||||
c = w3.eth.contract(abi=abi, address=address)
|
||||
|
||||
logg.debug('construct tx {} address {}'.format(tx_hash.hex(), address))
|
||||
balance = c.functions.balanceOf(signer_address).call()
|
||||
logg.info('balance {}: {} {}'.format(signer_address, balance, tx_hash.hex()))
|
||||
|
||||
balance = c.functions.balanceOf(w3.eth.defaultAccount).call()
|
||||
logg.info('balance {}: {} {}'.format(w3.eth.defaultAccount, balance, tx_hash))
|
||||
|
||||
|
||||
if args.a != None:
|
||||
for a in args.a:
|
||||
if a == w3.eth.defaultAccount:
|
||||
if args.account != None:
|
||||
for a in args.account:
|
||||
if a == signer_address:
|
||||
continue
|
||||
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)
|
||||
nonce += 1
|
||||
tx = c.functions.mint(args.amount).buildTransaction({
|
||||
'chainId': network_id,
|
||||
'gas': 70000,
|
||||
'gasPrice': gas_price,
|
||||
'nonce': nonce,
|
||||
})
|
||||
|
||||
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
|
||||
tx_hash_mint = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
|
||||
last_tx = tx_hash_mint
|
||||
logg.info('mint to {} tx {}'.format(a, tx_hash_mint.hex()))
|
||||
|
||||
if block_mode == 2:
|
||||
rcpt = waitFor(tx_hash_mint)
|
||||
if rcpt['status'] == 0:
|
||||
logg.error('mint failed: {}'.format(tx_hash_mint.hex()))
|
||||
if args.e:
|
||||
sys.exit(1)
|
||||
else:
|
||||
logg.info('mint succeeded. gas used: {}'.format(rcpt['gasUsed']))
|
||||
|
||||
nonce += 1
|
||||
tx = c.functions.transfer(a, args.amount).buildTransaction({
|
||||
'chainId': network_id,
|
||||
'gas': 40000,
|
||||
'gasPrice': gas_price,
|
||||
'nonce': nonce,
|
||||
})
|
||||
|
||||
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
|
||||
tx_hash_transfer = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
|
||||
last_tx = tx_hash_transfer
|
||||
logg.info('trasnfer to {} tx {}'.format(a, tx_hash_mint.hex()))
|
||||
|
||||
if block_mode == 2:
|
||||
rcpt = waitFor(tx_hash_transfer)
|
||||
balance = c.functions.balanceOf(a).call()
|
||||
logg.info('balance {}: {}'.format(a, balance))
|
||||
if rcpt['status'] == 0:
|
||||
logg.error('transfer failed: {}'.format(tx_hash_mint.hex()))
|
||||
if args.e:
|
||||
sys.exit(1)
|
||||
else:
|
||||
logg.info('transfer succeeded. gas used: {}'.format(rcpt['gasUsed']))
|
||||
|
||||
if args.m != None:
|
||||
for a in args.m:
|
||||
if a == w3.eth.defaultAccount:
|
||||
if args.minter != None:
|
||||
for a in args.minter:
|
||||
if a == signer_address:
|
||||
continue
|
||||
tx_hash_minter = c.functions.addMinter(a).transact()
|
||||
logg.info('minter {}'.format(a))
|
||||
nonce += 1
|
||||
tx = c.functions.addMinter(a).buildTransaction({
|
||||
'chainId': network_id,
|
||||
'gas': 50000,
|
||||
'gasPrice': 1000000000000,
|
||||
'nonce': nonce,
|
||||
})
|
||||
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
|
||||
tx_hash_minter = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
|
||||
last_tx = tx_hash_minter
|
||||
logg.info('minter add {} tx {}'.format(a, tx_hash_minter.hex()))
|
||||
if block_mode == 2:
|
||||
rcpt = waitFor(tx_hash_minter)
|
||||
balance = c.functions.balanceOf(a).call()
|
||||
if rcpt['status'] == 0:
|
||||
logg.error('minter add failed: {}'.format(tx_hash_minter))
|
||||
if args.e:
|
||||
sys.exit(1)
|
||||
else:
|
||||
logg.info('minter add succeeded. gas used: {}'.format(rcpt['gasUsed']))
|
||||
|
||||
if block_mode > 0:
|
||||
rcpt = waitFor(last_tx)
|
||||
if rcpt['status'] == 0:
|
||||
logg.error('failed: {}'.format(tx_hash_mint.hex()))
|
||||
if args.e:
|
||||
sys.exit(1)
|
||||
|
||||
print(address)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Mints and gifts tokens to a given address
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
@ -7,13 +8,16 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
import time
|
||||
|
||||
# third-party imports
|
||||
import web3
|
||||
from eth_keys import keys
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
@ -26,36 +30,121 @@ data_dir = os.path.join(script_dir, '..', 'data')
|
||||
|
||||
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('-t', '--token-address', required='True', dest='t', type=str, help='Giftable token address')
|
||||
argparser.add_argument('-m', '--minter-address', dest='m', type=str, help='Minter account address')
|
||||
argparser.add_argument('-e', action='store_true', help='Treat all transactions as essential')
|
||||
argparser.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed')
|
||||
argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='Ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('-a', '--token-address', required='True', dest='a', type=str, help='Giftable token address')
|
||||
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
|
||||
argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default=data_dir, help='Directory containing bytecode and abi (default: {})'.format(data_dir))
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-r', '--recipient-address', dest='r', type=str, help='Recipient account address')
|
||||
argparser.add_argument('--recipient', type=str, help='Recipient account address. If not set, tokens will be gifted to the keystore account')
|
||||
argparser.add_argument('amount', type=int, help='Amount of tokens to mint and gift')
|
||||
args = argparser.parse_args()
|
||||
|
||||
if args.v:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
|
||||
block_mode = 0
|
||||
if args.ww:
|
||||
logg.debug('set block after each tx')
|
||||
block_mode = 2
|
||||
elif args.w:
|
||||
logg.debug('set block until last tx')
|
||||
block_mode = 1
|
||||
|
||||
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
|
||||
|
||||
private_key = None
|
||||
signer_address = None
|
||||
if args.y != None:
|
||||
logg.debug('loading keystore file {}'.format(args.y))
|
||||
f = open(args.y, 'r')
|
||||
encrypted_key = f.read()
|
||||
f.close()
|
||||
private_key = w3.eth.account.decrypt(encrypted_key, '')
|
||||
private_key_object = keys.PrivateKey(private_key)
|
||||
signer_address = private_key_object.public_key.to_checksum_address()
|
||||
logg.debug('now have key for signer address {}'.format(signer_address))
|
||||
|
||||
network_pair = args.i.split(':')
|
||||
network_id = int(network_pair[1])
|
||||
|
||||
|
||||
def waitFor(tx_hash):
|
||||
i = 1
|
||||
while True:
|
||||
try:
|
||||
return w3.eth.getTransactionReceipt(tx_hash)
|
||||
except web3.exceptions.TransactionNotFound:
|
||||
logg.debug('poll #{} for {}'.format(i, tx_hash.hex()))
|
||||
i += 1
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def main():
|
||||
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
|
||||
|
||||
f = open(os.path.join(args.abi_dir, 'GiftableToken.json'), 'r')
|
||||
abi = json.load(f)
|
||||
f.close()
|
||||
|
||||
c = w3.eth.contract(abi=abi, address=args.t)
|
||||
if args.m != None:
|
||||
w3.eth.defaultAccount = web3.Web3.toChecksumAddress(args.m)
|
||||
gas_price = w3.eth.gasPrice
|
||||
|
||||
last_tx = None
|
||||
|
||||
nonce = w3.eth.getTransactionCount(signer_address, 'pending')
|
||||
|
||||
c = w3.eth.contract(abi=abi, address=args.a)
|
||||
|
||||
recipient = signer_address
|
||||
if args.recipient != None:
|
||||
recipient = args.recipient
|
||||
|
||||
tx = c.functions.mint(args.amount).buildTransaction({
|
||||
'chainId': network_id,
|
||||
'gas': 60000,
|
||||
'gasPrice': gas_price,
|
||||
'nonce': nonce,
|
||||
})
|
||||
|
||||
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
|
||||
tx_hash_mint = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
|
||||
last_tx = tx_hash_mint
|
||||
logg.info('mint to {} tx {}'.format(signer_address, tx_hash_mint.hex()))
|
||||
|
||||
if block_mode == 2:
|
||||
rcpt = waitFor(tx_hash_mint)
|
||||
if rcpt['status'] == 0:
|
||||
logg.critical('mint failed: {}'.format(tx_hash_mint.hex()))
|
||||
sys.exit(1)
|
||||
else:
|
||||
w3.eth.defaultAccount = w3.eth.accounts[0]
|
||||
logg.info('mint succeeded. gas used: {}'.format(rcpt['gasUsed']))
|
||||
|
||||
recipient = w3.eth.defaultAccount
|
||||
if args.r != None:
|
||||
recipient = web3.Web3.toChecksumAddress(args.r)
|
||||
nonce += 1
|
||||
|
||||
c.functions.mint(args.amount).transact()
|
||||
tx = c.functions.transfer(recipient, args.amount).transact()
|
||||
tx = c.functions.transfer(recipient, args.amount).buildTransaction({
|
||||
'chainId': network_id,
|
||||
'gas': 60000,
|
||||
'gasPrice': gas_price,
|
||||
'nonce': nonce,
|
||||
})
|
||||
|
||||
print(tx.hex())
|
||||
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
|
||||
tx_hash_mint = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
|
||||
last_tx = tx_hash_mint
|
||||
logg.info('transfer to {} tx {}'.format(recipient, tx_hash_mint.hex()))
|
||||
|
||||
if block_mode > 0:
|
||||
rcpt = waitFor(tx_hash_mint)
|
||||
if rcpt['status'] == 0:
|
||||
logg.error('trasnfer failed: {}'.format(tx_hash_mint.hex()))
|
||||
sys.exit(1)
|
||||
else:
|
||||
logg.info('transfer succeeded. gas used: {}'.format(rcpt['gasUsed']))
|
||||
|
||||
print(last_tx.hex())
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = giftable-erc20-token
|
||||
version = 0.0.6
|
||||
version = 0.0.7a1
|
||||
description = Simple ERC20 contract with deployment script that lets any address mint and gift itself tokens.
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
[{"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"}]
|
||||
[{"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":"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":"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"}]
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity >=0.6.12;
|
||||
pragma solidity >0.6.11;
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
#SOLC = /home/lash/build/solidity/build/solc/solc
|
||||
SOLC = /usr/bin/solc
|
||||
|
||||
all:
|
||||
solc --bin GiftableToken.sol | awk 'NR>3' > GiftableToken.bin
|
||||
$(SOLC) --bin GiftableToken.sol --evm-version byzantium | awk 'NR>3' > GiftableToken.bin
|
||||
truncate -s -1 GiftableToken.bin
|
||||
solc --abi GiftableToken.sol | awk 'NR>3' > GiftableToken.abi.json
|
||||
$(SOLC) --abi GiftableToken.sol --evm-version byzantium | awk 'NR>3' > GiftableToken.json
|
||||
|
||||
install: all
|
||||
cp -v *{json,bin} ../python/giftable_erc20_token/data/
|
||||
|
Loading…
Reference in New Issue
Block a user