1

I want to read an ordinal transaction on the Bitcoin blockchain and see its payload data.

Say I use the getrawtransaction RPC Method for bitcoin receiving a JSON of the form specified here. Where would the ordinal data be assuming we received an ordinal transaction? Is it in vin.hex? If so how would you decode it? It would depend on if its a text or image or video right?

2

1 Answer 1

2

As Vojtěch writes in the linked topic, the inscriptions will be found in an unexecuted part of the leaf script of the taproot input. “The leaf script is the second to last element of the witness stack after removing the optional annex (which is currently non-standard and has never been used on mainnet)”¹, which you find in vin.txinwitness. The Ordinal Theory Handbook describes the serialization format.

You could take a look at the ord software to find an implementation of the deserialization of inscriptions there. This file may or may not be related:incription.rs


¹ Thanks to Vojtěch for correcting my answer and providing this more precise description.

4
  • 3
    The script is called "leaf script", not "witness script" (source), and it's the second to last element of the witness stack after removing the optional annex (which is currently non-standard and has never been used on mainnet). Commented May 22, 2023 at 14:51
  • 3
    Thanks, I’m glad you’re keeping me honest.
    – Murch
    Commented May 22, 2023 at 15:00
  • so pretty much have to call into Rust from whatever lang im using...
    – BAR
    Commented May 27, 2023 at 18:32
  • No, I was just pointing at an example for how inscriptions are deserialized which happens to be in Rust.
    – Murch
    Commented May 29, 2023 at 14:30

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.