1

Could anyone help me understand how one reads from a substrate chain the account that sent an extrinsic?

For example take this Kusama xcmpallet.reserve_transfer_assets extrinsic sent by address JHz14NmqDJZ3vGwWNZAAezW4KsiSofw8ptoeg3LtksDqU4L

I can parse from the XCM message the account address it's being sent to from the beneficiary section but in the XCM message I am unable to see which account sent the extrinsic.

Does anyone know where the sender address is being read from?

For context I am using py-substrate-interface to read data from the block chain using substrate.get_block(block_hash=block_hash) and then parsing the block for extrinsic data.

1
  • A block's extrinsic will always contain a signer, as long as it has a signature, something along the lines of this. This is probably some weird behavior about the python interface, hiding the extrinsic author somewhere hard to find. What is the exact output of this get_block?
    – kianenigma
    Commented Nov 10, 2022 at 2:15

1 Answer 1

3

The example in the py-substrate-interface README shows exactly how to do this.

https://github.com/polkascan/py-substrate-interface/tree/v1.3.3#method-1-access-serialized-value

# Set block_hash to None for chaintip
block_hash = "0x51d15792ff3c5ee9c6b24ddccd95b377d5cccc759b8e76e5de9250cf58225087"

# Retrieve extrinsics in block
result = substrate.get_block(block_hash=block_hash)

for extrinsic in result['extrinsics']:

    if 'address' in extrinsic.value:
        signed_by_address = extrinsic.value['address']
    else:
        signed_by_address = None
1
  • Thanks @joepetrowski!!
    – olliecorbs
    Commented Nov 10, 2022 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.