Skip to main content

Transaction Data Output

Data outputs allow applications to store small pieces of data in Hathor transactions. They are useful when a system needs to add traceability to business operations, assets, or events.

A common pattern is to combine data outputs with a custom token. The token acts as a grouping mechanism for the related transactions, while each transaction can store additional metadata as a data output.

This makes it easier to browse the full history of an operation or asset in the Hathor Explorer, instead of having unrelated data outputs scattered across the blockchain.

How data outputs work

When a transaction includes a data output, the transaction can record metadata directly on the blockchain. This metadata can be:

  • A plain string.
  • A hash of external data.
  • A reference to data stored elsewhere, such as an IPFS link.

Adding a data output requires spending 0.01 HTR, similar to the data output used when creating an NFT.

For traceability use cases, the custom token is usually created with amount 1. This unitary token does not represent a fungible asset. Instead, it works as a marker that links all related transactions together.

Traceable Transaction History

The following example creates a traceable chain of transactions:

  1. Create a custom token and store the first data output.
  2. Transfer the token and store a second data output.
  3. Transfer the token again and store a third data output.

At the end of this flow, the token details page in the Hathor Explorer shows all transactions associated with the token.

Step 1: Create the traceable data token

The first request creates a custom token called Traceable Data Token with the symbol TDT.

This transaction also stores the first piece of data on-chain through the data field.

curl -X POST \
-H "X-Wallet-Id: gitbook-wallet" \
-H "Content-Type: application/json" \
--data '{
"name": "Traceable Data Token",
"symbol": "TDT",
"amount": 1,
"data": "some-data-to-store"
}' \
http://localhost:8000/wallet/create-nft

This follows the same transaction model used for NFT creation. However, instead of storing metadata related to images, videos, or collectibles, this example stores business-specific data.

You can view the transaction in Hathor Explorer:

https://explorer.testnet.hathor.network/transaction/000002bd1179254ac53153708dfd099b9937865a44180085ebf4cf30f66cf754

The created token ID is:

000002bd1179254ac53153708dfd099b9937865a44180085ebf4cf30f66cf754

Step 2: Add another data output

The second request transfers the TDT token and stores another data output in the same transaction.

curl -X POST \
-H "X-Wallet-Id: gitbook-wallet" \
-H "Content-Type: application/json" \
--data '{
"outputs": [
{
"type": "data",
"data": "some-data-to-store-2"
},
{
"address": "WeLE2cETBNUr46S2UREwr4LZJsjiDJ1Guu",
"value": 1,
"token": "000002bd1179254ac53153708dfd099b9937865a44180085ebf4cf30f66cf754"
}
]
}' \
http://localhost:8000/wallet/send-tx

This transaction contains two main outputs:

OutputPurpose
Data outputStores some-data-to-store-2 on-chain.
Token outputTransfers 1 unit of the TDT token.

The transaction also spends 0.01 HTR for the data output. If the selected HTR input is larger than the required amount, the wallet creates a change output with the remaining HTR balance.

You can view the transaction in Hathor Explorer:

https://explorer.testnet.hathor.network/transaction/000000004f4d6ae0cef1d4ee1a147ef60dfc25c5f6d6a631c857645977f9a11d

Step 3: Add a third data output

The third request repeats the same pattern. It transfers the TDT token again and stores another data output.

curl -X POST \
-H "X-Wallet-Id: gitbook-wallet" \
-H "Content-Type: application/json" \
--data '{
"outputs": [
{
"type": "data",
"data": "some-data-to-store-3"
},
{
"address": "WeLE2cETBNUr46S2UREwr4LZJsjiDJ1Guu",
"value": 1,
"token": "000002bd1179254ac53153708dfd099b9937865a44180085ebf4cf30f66cf754"
}
]
}' \
http://localhost:8000/wallet/send-tx

You can view the transaction in Hathor Explorer:

https://explorer.testnet.hathor.network/transaction/00000000fd95cc99c0718944f1bbe51f6b38ae7b1604a1ae4e34bd62baf512cb

Full Transaction History

After the three transactions are created, the token details page in Hathor Explorer shows the full history of the TDT token:

https://explorer.testnet.hathor.network/token_detail/000002bd1179254ac53153708dfd099b9937865a44180085ebf4cf30f66cf754

This is the main benefit of using a custom token to group traceability events. Each transaction can store a new data output, while the token history provides a single place to inspect the full sequence of related operations.

Without the token, the data outputs would still exist on the blockchain, but they would not be naturally grouped together. Applications would need an external index or database to connect those transactions.