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

KeyError: 'gasRequired' when reading contract data from a chain #200

Open
minhnd-dev opened this issue Feb 28, 2022 · 1 comment
Open

KeyError: 'gasRequired' when reading contract data from a chain #200

minhnd-dev opened this issue Feb 28, 2022 · 1 comment

Comments

@minhnd-dev
Copy link

I'm trying to read data from a substrate chain (Jupiter A1 testnet), I got this error:

Traceback (most recent call last):
  File "shibuya_interface.py", line 31, in <module>
    result = contract.read(keypair, 'get')
  File "/home/minhnd/anaconda3/lib/python3.8/site-packages/substrateinterface/contracts.py", line 796, in read
    contract_exec_result.gas_required = response['result']['gasRequired']
KeyError: 'gasRequired'

This is my code:

from substrateinterface import Keypair

substrate = SubstrateInterface(
    url="wss://ws.jupiter-poa.patract.cn/",
    ss58_format=42
)

contract = ContractInstance.create_from_address(
    contract_address="3g2kZxvk8XT8XLoDgJHYuNnEPN1t6yfP8vFj4jgxSWrUxGqJ",
    metadata_file="./flipper_metadata.json",
    substrate=substrate
)

keypair = Keypair.create_from_mnemonic("my secret phrase")

result = contract.read(keypair, 'get')
print('Current value of "get":', result.contract_result_data)
print(result)

This file runs perfectly on a substrate node template on my computer.

@minhnd-dev
Copy link
Author

I hardcoded a value for the gas_required in the contracts.py and it did temporarily fix the problem.

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

1 participant