mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2026-05-14 03:18:42 +02:00
Deploy script to package, dockerfile
This commit is contained in:
5
python/CHANGELOG
Normal file
5
python/CHANGELOG
Normal file
@@ -0,0 +1,5 @@
|
||||
* 0.0.2
|
||||
- Move deploy script to package
|
||||
* 0.0.1
|
||||
- Adapt Bancor ERC20 token contract
|
||||
- Add deploy-and-gift script
|
||||
1
python/VERSION
Normal file
1
python/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
0.0.1
|
||||
77
python/giftable_erc20_token/runnable/deploy.py
Normal file
77
python/giftable_erc20_token/runnable/deploy.py
Normal file
@@ -0,0 +1,77 @@
|
||||
"""Deploys giftable token, and optionally gifts a set amount to all accounts in wallet
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# third-party imports
|
||||
import web3
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
logging.getLogger('web3').setLevel(logging.WARNING)
|
||||
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('--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)')
|
||||
args = argparser.parse_args()
|
||||
|
||||
if args.v:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
|
||||
def main():
|
||||
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
|
||||
|
||||
f = open(os.path.join(args.contracts_dir, 'GiftableToken.abi.json'), 'r')
|
||||
abi = json.load(f)
|
||||
f.close()
|
||||
|
||||
f = open(os.path.join(args.contracts_dir, 'GiftableToken.bin'), 'r')
|
||||
bytecode = f.read()
|
||||
f.close()
|
||||
|
||||
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()
|
||||
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))
|
||||
|
||||
|
||||
if args.a != None:
|
||||
for a in args.a:
|
||||
if a == w3.eth.defaultAccount:
|
||||
continue
|
||||
tx_hash = c.functions.gift(a, args.amount).transact()
|
||||
rcpt = w3.eth.getTransactionReceipt(tx_hash)
|
||||
balance = c.functions.balanceOf(a).call()
|
||||
logg.info('balance {}: {}'.format(a, balance))
|
||||
|
||||
print(address)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
1
python/requirements.txt
Normal file
1
python/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
web3==5.12.2
|
||||
32
python/setup.cfg
Normal file
32
python/setup.cfg
Normal file
@@ -0,0 +1,32 @@
|
||||
[metadata]
|
||||
name = giftable-erc20-token
|
||||
version = 0.0.2
|
||||
description = Simple ERC20 contract with deployment script that lets any address mint and gift itself tokens.
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
url = https://gitlab.com/nolash/giftable-erc-token
|
||||
keywords =
|
||||
ethereum
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
Operating System :: OS Independent
|
||||
Development Status :: 3 - Alpha
|
||||
Environment :: No Input/Output (Daemon)
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
||||
Topic :: Internet
|
||||
#Topic :: Blockchain :: EVM
|
||||
license = GPL3
|
||||
licence_files =
|
||||
LICENSE
|
||||
|
||||
[options]
|
||||
python_requires = >= 3.6
|
||||
packages =
|
||||
giftable_erc20_token.runnable
|
||||
install_requires =
|
||||
web3==5.12.2
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
giftable-token-deploy = giftable_erc20_token.runnable.deploy:main
|
||||
4
python/setup.py
Normal file
4
python/setup.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
)
|
||||
Reference in New Issue
Block a user