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)
When trying to use the ERC20 wrapper, and using an ERC20 contract already on-chain (deployed using Redspot), I am getting the following error:
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: