0

enter image description here

How can I pass the externalics ID in the picture. Get the details of the deal. Through RPC method.

1 Answer 1

1

Is there a need to really use RPC directly? If so, you can start by:

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlockHash", "params": [10463935]}' https://kusama-rpc.polkadot.io
>>>
{"jsonrpc":"2.0","result":"0x87bf173b7c6edfe811e5e584ce50c9a6056b62c7b87472d8ecb23ae9a706c5e5","id":1}

And then:

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock", "params": ["0x87bf173b7c6edfe811e5e584ce50c9a6056b62c7b87472d8ecb23ae9a706c5e5"]}' https://kusama-rpc.polkadot.io

Here you will get a bunch of data that you'll have to decode to get what you want.

But you don't have to bother about that and just use PolkadotJS or py-substrate-interface, eg:

from substrateinterface import SubstrateInterface


def get_extrinsic_by_id(substrate, block_number, extrinsic_id):
    result = substrate.get_block(block_number=block_number)
    if result and len(result['extrinsics']) > extrinsic_id:
        return result['extrinsics'][extrinsic_id]
    else:
        print('Extrinsic ID: {extrinsic_id} not found.')

substrate = SubstrateInterface(url="wss://kusama-rpc.polkadot.io")
ext = get_extrinsic_by_id(substrate, block_number=10463935, extrinsic_id=2)

ext:

<GenericExtrinsic(value={'extrinsic_hash': '0x624efb20b7aac1ba4666f9396f5b051443f8e809ab6cc8988c62b977b63bb388', 'extrinsic_length': 147, 'address': 'Cb2QccEAM38pjwmcHHTTuTukUobTHwhakKH4kBo4k8Vur8o', 'signature': {'Ed25519': '0x191a8c70f984732d9fbf7eb18f362a2c179ec8c687dfcda9ae0654390f6c605b259d8597bb3d21efa95c46e0e0970843ed2a238a85c0d64c8bca18efdc144100'}, 'era': (64, 59), 'nonce': 41569, 'tip': 0, 'call': {'call_index': '0x0400', 'call_function': 'transfer', 'call_module': 'Balances', 'call_args': [{'name': 'dest', 'type': 'LookupSource', 'value': 'EaXAkn5ZwmMdnQa8vQx5rU9YZN8XAsACTUTCssGX5XvC22b'}, {'name': 'value', 'type': 'Balance', 'value': 230100000000}], 'call_hash': '0xb58c1473c8556163167d1c4fad6d0811a40d56e50912468a8444e774c7f85d10'}})>
8
  • Thank you, but what I want to know is. (get_external_by_id) if this is an RPC, which RPC is it?
    – Andy
    May 9, 2022 at 7:22
  • 1
    I don't think so... But you can check all the available RPC methods using curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods"}' https://kusama-rpc.polkadot.io. And polkadot.js.org/docs/substrate/rpc May 9, 2022 at 17:31
  • What's your answer? What's the use of all the RPC methods you gave me? What I want is which RPC is used at the bottom? bottom! Do you understand?
    – Andy
    May 11, 2022 at 6:46
  • Like I said, I don't think that there is a single RPC method to fetch an extrinsic data. You'll have to fetch the whole block data (chain_getBlock) and then decode its content to get what you want. Do you understand? May 11, 2022 at 8:28
  • I know it needs to be parsed, but you write (get_external_by_id) this is just a method name! What is in this method? This is what I want!
    – Andy
    May 12, 2022 at 6:49

Your Answer

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

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