eth-erc20

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

commit 055710763e75e73b7c2dfeb1e61f5b9c35457114
parent 560e8d7bb13b823dbb45cf84081a2eb95c67c204
Author: nolash <dev@holbrook.no>
Date:   Tue, 29 Jun 2021 08:28:42 +0200

Add allowance handler

Diffstat:
Mpython/eth_erc20/erc20.py | 24++++++++++++++++++++++++
Mpython/setup.cfg | 2+-
2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/python/eth_erc20/erc20.py b/python/eth_erc20/erc20.py @@ -115,6 +115,25 @@ class ERC20(TxFactory): return o + def allowance(self, contract_address, holder_address, spender_address, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('allowance') + enc.typ(ABIContractType.ADDRESS) + enc.typ(ABIContractType.ADDRESS) + enc.address(holder_address) + enc.address(spender_address) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + o = j.finalize(o) + return o + + def transfer(self, contract_address, sender_address, recipient_address, value, tx_format=TxFormat.JSONRPC, id_generator=None): enc = ABIContractEncoder() enc.method('transfer') @@ -185,6 +204,11 @@ class ERC20(TxFactory): @classmethod + def parse_allowance(self, v): + return abi_decode_single(ABIContractType.UINT256, v) + + + @classmethod def parse_transfer_request(self, v): v = strip_0x(v) cursor = 0 diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-erc20 -version = 0.0.10a1 +version = 0.0.10a2 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