I have a mapping with 0 to 10. I have values stored in this mapping. If I want to get the information stored on map<5> it gives me the details. Is it possible to get the transaction id and block in which this information is stored using either ink or polkadot-js
1 Answer
Not directly. If you want to know in which block the storage changed you would have to scan the Blockchain to try to find the extrinsic that make this storage change. You can do that using for example the Subscan API to query the events and filtering with the event your pallet emits after store the data in your storage or if you are not emitting events just querying the extrinsics.
But is more efficient to store the Transaction Hash that you get after the signAndSend
function in PolkadotJS, or event better the unique identifier of the transaction (see the explanation in this StackExchange old question) which is the block# + the extrinsic index in that block
(See this old response on StackExchange to see how to get it using PolkadotJS).
-
I am aware of the
signAndSend
method that returns these details. In such cases, we have to store the information in off-chain databases. I want to know whether we can get that information from on-chain. I came across an option calledcreatedAtHash
while using polkadot-js. But not sure how to use it. Feb 27 at 15:06