polkascan / substrate-interface-api

Substrate Interface API Application
https://documenter.getpostman.com/view/9969999/SWT5iLXH?version=latest
GNU General Public License v3.0
4 stars 13 forks source link

get extrinsic by hash API #6

Closed gutenye closed 3 years ago

gutenye commented 3 years ago

Hey Arjan,

Is there an API that supports get extrinsic data from <extrinsic-hash> or <block-height>-<extrinsic-index>? It's a common use case that you want to query that extrinsic for the information.

AFAIK, the node RPC doesn't provide a direct method, but you can get the block data first, then get the transaction data from the block by index.

Thanks a lot.

arjanz commented 3 years ago

Yes there is and it's called Polkascan :) You can also run the application yourself (https://github.com/polkascan/polkascan-os) and this will provide API endpoints just like our hosted version.

Examples: https://explorer-31.polkascan.io/polkadot/api/v1/extrinsic/<extrinsic-hash>?include=events or https://explorer-31.polkascan.io/polkadot/api/v1/extrinsic/<block-height>-<extrinsic-index>?include=events

Note that the public hosted versions can be used freely (fair use) but may be subject to change in the near future. And you are right, the RPC doesn't maintain indices to access extrinsics directly.

gutenye commented 3 years ago

Thanks.