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 when using ERC20 wrapper: No module named 'patractinterface.contracts' #7

Open
stiiifff opened this issue Apr 16, 2021 · 2 comments · Fixed by #8
Open

Error when using ERC20 wrapper: No module named 'patractinterface.contracts' #7

stiiifff opened this issue Apr 16, 2021 · 2 comments · Fixed by #8

Comments

@stiiifff
Copy link

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

ModuleNotFoundError: No module named 'patractinterface.contracts'

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 = ERC20.create_from_address(
        "128vhr5RJeWBnkh36NaMKAE7PP57hkFAYVBGzTAhecvWsnYw",
        os.path.join(os.path.dirname(__file__), 'res', 'erc20.json'),
        substrate
    )

    # read total supply
    total_supply = erc20.totalSupply()
    print("Total supply: {}", total_supply)

    transfer
    erc20.transfer_from(alice,
        from_acc=alice.ss58_address, 
        to_acc=bob.ss58_address, 
        amt=10000)

    erc20.transfer(alice, bob.ss58_address, 10000)

    # get balance
    alice_balance = erc20.balance_of(alice.ss58_address)

    # approve
    erc20.approve(alice, spender=bob.ss58_address, amt=10000)

    # get allowance
    alice_allowance = erc20.allowance(alice.ss58_address, bob.ss58_address)

@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

@polkadev polkadev linked a pull request May 17, 2021 that will close this issue
@polkadev
Copy link
Contributor

#5 #6

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

Successfully merging a pull request may close this issue.

2 participants