polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 114 forks source link

ValueError: Call function 'ParasSudoWrapper.sudoScheduleParaInitialize' not found #181

Closed BulatSaif closed 2 years ago

BulatSaif commented 2 years ago

I am trying to register parachains https://github.com/paritytech/cumulus#register-the-parachain 99548884-1be13580-2987-11eb-9a8b-20be658d34f9

But python code gives me error:

try:
    substrate = SubstrateInterface(
        url="ws://127.0.0.1:9944"
    )
except ConnectionRefusedError:
    print("⚠️ No local Substrate node running, try running 'start_local_substrate_node.sh' first")
    exit()

keypair = Keypair.create_from_uri('//Alice')

call = substrate.compose_call(
    call_module='ParasSudoWrapper',
    call_function='sudoScheduleParaInitialize',
    call_params={
        'id': '200',
        'genesis': {
            'genesisHead': "0x00...",
            'validationCode': "0x00..",
            'parachain': True
        }
    }
)
Traceback (most recent call last):
  File "./balance_transfer.py", line 34, in <module>
    call = substrate.compose_call(
  File "/home/ubuntu/.local/lib/python3.8/site-packages/substrateinterface/base.py", line 1475, in compose_call
    call.encode({
  File "/home/ubuntu/.local/lib/python3.8/site-packages/scalecodec/base.py", line 706, in encode
    self.data = self.process_encode(self.value_serialized)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/scalecodec/types.py", line 1401, in process_encode
    raise ValueError(f"Call function '{value['call_module']}.{value['call_function']}' not found")
ValueError: Call function 'ParasSudoWrapper.ScheduleParaInitialize' not found

Is there any guidelines on how to convert call from https://polkadot.js.org/ to python code?

BulatSaif commented 2 years ago

Function names in GUI https://polkadot.js.org/ and in runtime are not match.
you can use this function to get list of all functions:

substrate.get_metadata_call_functions()

If someone will needs sudoScheduleParaInitialize functions the correct name is:


call = substrate.compose_call(
    call_module='ParasSudoWrapper',
    call_function='sudo_schedule_para_initialize',
    call_params={
        'id': '1000',
        'genesis': {
            'genesis_head': "0x000...",
            'validation_code': "0x000...",
            'parachain': True
        }
    }
)