I am using substrate-contracts-node. I've uploaded and instantiated the smart contract. I would like to interact and query the function using py-substrate-interface. However, I ran into an error while following this guide - https://polkascan.github.io/py-substrate-interface/usage/ink-contract-interfacing/#deploy-a-contract
This is my code:
contract_address = '5Guya7pPPJC5bDy6yjpLZQ6Tw4D3pow8pvebEnFxMsyd5d31'
# Create contract instance from deterministic address
contract = ContractInstance.create_from_address(
contract_address=contract_address,
metadata_file=os.path.join(os.path.dirname(__file__), '/home/<name>/TODO-List/todo_list/target/ink', 'metadata.json'),
substrate=substrate
)
result = contract.read(keypair, 'get_owner')
This is the error message:
Traceback (most recent call last):
File "/home/<name>/TODO-List/myenv/lib/python3.8/site-packages/scalecodec/types.py", line 1232, in process
enum_type_mapping = self.type_mapping[self.index]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 24, in <module>
result = contract.read(keypair, 'get_owner')
File "/home/<name>/TODO-List/myenv/lib/python3.8/site-packages/substrateinterface/contracts.py", line 766, in read
call_result = self.substrate.runtime_call("ContractsApi", "call", {
File "/home/<name>/TODO-List/myenv/lib/python3.8/site-packages/substrateinterface/base.py", line 1258, in runtime_call
result_obj.decode(ScaleBytes(result_data['result']))
File "/home/<name>/TODO-List/myenv/lib/python3.8/site-packages/scalecodec/base.py", line 874, in decode
self.value_serialized = self.process()
File "/home/<name>/TODO-List/myenv/lib/python3.8/site-packages/scalecodec/types.py", line 1755, in process
value = super().process()
File "/home/<name>/TODO-List/myenv/lib/python3.8/site-packages/scalecodec/types.py", line 1245, in process
raise ValueError("Index '{}' not present in Enum type mapping".format(self.index))
ValueError: Index '202' not present in Enum type mapping
Smart contract was tested and built without any issue. get_owner()
is a simple function in a smart contract that returns an AccountId.