Constructing a transaction
Understanding transaction bitwise
We have already looked at the composition of a transaction. Now, let's dig a bit deeper.
Data structure of a transaction:
Data Structure of a BEEF formatted transaction:
The following image provides an example of a typical raw transaction (P2PKH transaction with two inputs and two outputs):
The colors help to differentiate every field present in the transaction. Input script is denoted as scriptSig, and output script is denoted as scriptPubKey (due to the nature of the input script being a signature and output being a script locking the funds to a public key).
Each field in the transaction is modularised i.e. you can build a raw transaction one by one by adding each of these fields in the right format and endianness. These transactions are usually built using well-defined libraries and functions available in various programming languages.
There will often be visualisation tools which will present the transaction details in a much more readable format; for example, below is the translated version of the input and output scripts for the raw transactions in discussion.
Once the transaction is constructed, it is submitted for timestamping. This can be done via an Overlay Service or directly to the node network. Currently, nodes provide an RPC endpoint (called bitcoind), which is made available for transactions to be submitted, but the ARC service provides an easy to use abstraction.
Last updated