Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in ContractObserver: result_handler() takes 1 positional argument but 3 were given #6

Open
stiiifff opened this issue Apr 16, 2021 · 2 comments

Comments

@stiiifff
Copy link

stiiifff commented Apr 16, 2021

When trying to run the Quickstart, and using an ERC20 contract already on-chain (deployed using Redspot), I am getting the following error:

TypeError: result_handler() takes 1 positional argument but 3 were given

To test this, I am using a local Europa instance, and I have previously created, compiled and deployed an ERC20 contract using Redspot, and copied the erc20.json & erc20.wasm files to a res subfolder (as expected by the tutorial code).

Below is the test code:

    substrate=SubstrateInterface(url='ws://127.0.0.1:9944', type_registry_preset="default", type_registry={'types': {'LookupSource': 'MultiAddress'}})

    alice = Keypair.create_from_uri('//Alice')
    bob = Keypair.create_from_uri('//Bob')
    
    erc20_ins = ContractAPI.create_from_address(
        "128vhr5RJeWBnkh36NaMKAE7PP57hkFAYVBGzTAhecvWsnYw",
        os.path.join(os.path.dirname(__file__), 'res', 'erc20.json'),
        substrate
    )
    observer = ContractObserver(erc20_ins.contract_address, erc20_ins.metadata, substrate)

    res = erc20_ins.transfer(alice, bob.ss58_address, 100000, gas_limit=20000000000)
    print('transfer res', res.is_success)

    def on_transfer(num, evt):
        print("on_transfer in {} : {} {} {}".format(num, evt['from'], evt['to'], evt['value']))

    def on_approval(num, evt):
        print("on_approval in {} : {} {} {}".format(num, evt['owner'], evt['spender'], evt['value']))

    observer.scanEvents(handlers={
        'Transfer': on_transfer,
        'Approve': on_approval
    })
@polkadev
Copy link
Contributor

This package have upgrade to v0.3.1, and it contain some examples in https://github.com/patractlabs/py-patract/tree/master/examples/erc20, you can use it for example to test

@stiiifff
Copy link
Author

Great thx !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants