1

Thanks to py-substrate-interface I can create extrinsics with something like:

payload = substrate.compose_call(
    call_module='Balances',
    call_function='transfer',
    call_params={
        'dest': 'EaG2CRhJWPb7qmdcJvy3LiWdh26Jreu9Dx6R1rXxPmYXoDk',
        'value': 1000000000000
    }
)

Then I can also see the rpc_request and ws_request in their documentation, which I assume I can use to broadcast a signed extrinsic.

The missing step would be the signing of the extrinsic. Does anyone know how to do this in python?

FaustoW
  • 632
  • 7
  • 15

1 Answers1

1

At the moment signing is not (yet) possible directly from the Python library, but you can try to pass the call payload from the compose_call() function to the subkey command (https://substrate.dev/docs/en/ecosystem/subkey), for example:

subkey sign-transaction --call "0x200400011074657374" --nonce 0 --suri "<secret_seed_or_words>" --password "" --prior-block-hash 0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b

You can use subprocess.run in Python to fetch the result of subkey from your Python code (https://docs.python.org/3/library/subprocess.html)

Hope this helps!

Arjan
  • 301
  • 1
  • 4