eth-erc20

ERC20 interface and example giftable token contract
Log | Files | Refs | LICENSE

commit fc9fa18e1c58a4100af7262976408e9d20ddb883
parent d218d93fbacfbb28341c7c406aedd5344db836c1
Author: lash <dev@holbrook.no>
Date:   Mon, 13 Feb 2023 15:06:02 +0000

Implement bytecode and contract constructor code for chainlib find tool

Diffstat:
Mpython/MANIFEST.in | 2+-
Apython/giftable_erc20_token/_clf.py | 21+++++++++++++++++++++
Mpython/giftable_erc20_token/factory.py | 18++++++++++++------
Mpython/requirements.txt | 1+
Mpython/setup.cfg | 2+-
5 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/python/MANIFEST.in b/python/MANIFEST.in @@ -1 +1 @@ -include **/data/ERC20.json **/data/GiftableToken.json **/data/GiftableToken.bin *requirements.txt CHANGELOG LICENSE WAIVER WAIVER.asc +include **/data/ERC20.json **/data/GiftableToken.json **/data/GiftableToken.bin *requirements.txt CHANGELOG LICENSE WAIVER WAIVER.asc **/data/.chainlib diff --git a/python/giftable_erc20_token/_clf.py b/python/giftable_erc20_token/_clf.py @@ -0,0 +1,21 @@ +# local imports +from .factory import GiftableToken + + +def code(v): + version = None + if v != None: + version = v[0] + return GiftableToken.bytecode(version=version) + + +def init(v): + if v == None or len(v) < 3: + raise ValueError('minimum 3 arguments required') + version = None + if len(v) == 4: + version = v[4] + return GiftableToken.cargs(v[0], v[1], v[2], version=version) + + +default = code diff --git a/python/giftable_erc20_token/factory.py b/python/giftable_erc20_token/factory.py @@ -24,16 +24,22 @@ class GiftableToken(TxFactory): __abi = None __bytecode = None - def constructor(self, sender_address, name, symbol, decimals, tx_format=TxFormat.JSONRPC): - code = GiftableToken.bytecode() + def constructor(self, sender_address, name, symbol, decimals, tx_format=TxFormat.JSONRPC, version=None): + code = constructor_arg(name, symbol, decimals) + tx = self.template(sender_address, None, use_nonce=True) + tx = self.set_code(tx, code) + return self.finalize(tx, tx_format) + + + @staticmethod + def cargs(name, symbol, decimals, version=None): + code = GiftableToken.bytecode(version=version) enc = ABIContractEncoder() enc.string(name) enc.string(symbol) enc.uint256(decimals) code += enc.get() - tx = self.template(sender_address, None, use_nonce=True) - tx = self.set_code(tx, code) - return self.finalize(tx, tx_format) + return code @staticmethod @@ -51,7 +57,7 @@ class GiftableToken(TxFactory): @staticmethod - def bytecode(): + def bytecode(version=None): if GiftableToken.__bytecode == None: f = open(os.path.join(data_dir, 'GiftableToken.bin')) GiftableToken.__bytecode = f.read() diff --git a/python/requirements.txt b/python/requirements.txt @@ -1,3 +1,4 @@ confini~=0.6.1 chainlib-eth~=0.4.15 +chainlib~=0.4.8 potaahto~=0.1.1 diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-erc20 -version = 0.5.4 +version = 0.5.5 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