Chains & entries
Data in a blockchain is stored into files called blocks. Blocks are organized into a linear sequence over time. Each block in the blockchain contains a fingerprint of the block that came immediately before it, a timestamp, and transactions that users wish to associate with that timestamp. By linking blocks together with these fingerprints - otherwise known as hashes - it is possible to fix in place the data in the blockchain; if a block is altered, it will change the hash of every block that comes after it, and will be immediately noticed and rejected.
Introducing Chains
Traditional blockchains often allow you to submit arbitrary data into a block. For example, bitcoin transactions contain the OP_RETURN field, where users can insert any data they wish into a transaction. This data is included in the block hash, and is therefore fixed permanently in the blockchain. However, whilst the bitcoin blockchain naturally chains each of its blocks together, it is much harder for users to chain their own arbitrary data transactions together. You can write immutable data into the bitcoin blockchain, but you cannot associate that data directly with other data you had written in the past.
Factom solves this problem. It allows users to create their own unique chains where they can group data that is specific to their application over a sustained period of time, thereby creating a transparent history of ordered state changes. This is a powerful feature, and can be used for various purposes: you can track the state of arbitrary data such as a file or database, write tamperproof logs, create supply chains records, or track the state of an application, which creates opportunities for smart contract development.
ChainID and ExtIDs
- Each chain has a unique identity —
ChainID
. - Each chain has metadata known as
ExtIDs
which the user adds when creating the chain. - The
ChainID
is unique and calculated based onExtIDs
and their ordering. - Using the
ChainID
, a user can read all the data that has been entered into a chain.
The examples below illustrates the relationship between the ExtIDs
and the ChainID
. It has two ExtIDs
, Factom Pro and Tutorial, which combine to generate the ChainID
b36c1c4073305a41edc6353a094329c24ffa54c0a47fb56227a04477bcb78923
.
Chain with ChainID b36c1c4073305a41edc6353a094329c24ffa54c0a47fb56227a04477bcb78923
+----------+--------------+
| ExtID[0] | Factom PRO |
| ExtID[1] | Tutorial |
+----------+--------------+
This is a real chain, which you can view on the blockchain.
If you change ordering of chain's ExtIDs
, it will create a new chain with a different ChainID
:
Chain with ChainID c550f72df8087c65b29241988b4407bb31e2162e9db63e60ad40df6957acbc2e
+----------+--------------+
| ExtID[0] | Tutorial |
| ExtID[1] | Factom PRO |
+----------+--------------+
A ChainID
depends only on the contents and order of its ExtIDs
. If you try to create two chains with identical ExtIDs
in the same order, the second chain will be rejected by the protocol.
Entries
An entry is a type of transaction that is used to write data into the Factom blockchain. Each entry is always associated with exactly one chain. If chains are like directories, then entries are the files that go into those directories.
Entry structure
ChainID
– an ID of the chain, which the entry is associated with[]ExtID
– one or multiple tags (external IDs)Content
– payload content
Entry with EntryHash 1bd5955a72f8696416ac3ca39f7aa6a054e7209aa2f9a5f95d601640b8d047a5
+----------+-------------------------------------------------------+
| ChainID |
| b36c1c4073305a41edc6353a094329c24ffa54c0a47fb56227a04477bcb78923 |
+----------+-------------------------------------------------------+
| ExtID[0] | Tag #1 of entry |
| ExtID[1] | Tag #2 of entry |
| ExtID[2] | Tag #3 of entry |
+----------+-------------------------------------------------------+
| Content | This is useful content of the entry. You can save |
| | text, hash, JSON or raw ASCII data here. |
+----------+-------------------------------------------------------+
Each entry has EntryHash
, calculated from the params above.
As with a ChainID
, an EntryHash
does not depend on a timestamp. That means if you create an entry with exactly the same params ( ChainID
, ExtIDs
and their ordering, Content
) as an existing entry, the new entry will have the same EntryHash
.
Unlike chains, entries are not unique – you can write duplicate entries to a chain. For example, if you're tracking a building's security system, the operation of a secure door will generate the same EntryHash
each time it is opened. However, whilst duplicate entries have the same EntryHash
, they will be placed into different blocks on blockchain, because they were created at different times. A duplicate entry created within an hour of its predecessor will be rejected.
The first entry of the chain
When you create a new chain, the first entry is also created at the same time.
Let's look back at the tutorial chain we examined earlier:
Chain with ChainID b36c1c4073305a41edc6353a094329c24ffa54c0a47fb56227a04477bcb78923
+----------+--------------+
| ExtID[0] | Factom PRO |
| ExtID[1] | Tutorial |
+----------+--------------+
When you create a new chain, you specify the ExtIDs
and Content
of the chain.
- A new chain is created based on
ExtIDs
and their ordering - The chain has its own unique
ChainID
- The first entry of this new chain is created based on
- The
ChainID
of the chain - The
ExtIDs
of the chain - The
Content
you sent
- The
The first entry of our tutorial chain has the same ExtIDs
as its chain, but it also has a payload written in the Content
:
Entry with EntryHash acc6e29258ae8461aa2fe314d8ab74df97092baf348d7f9e869a8573d7490657
+----------+-------------------------------------------------------+
| ChainID |
| b36c1c4073305a41edc6353a094329c24ffa54c0a47fb56227a04477bcb78923 |
+----------+-------------------------------------------------------+
| ExtID[0] | Factom PRO |
| ExtID[1] | Tutorial |
+----------+-------------------------------------------------------+
| Content | This chain is used for factom.pro educational |
| | materials. |
+----------+-------------------------------------------------------+
Conclusion
This is the first tutorial of the set of educational materials of how to use Factom. In the next tutorials you will learn how to:
- use digital signatures to protect your data
- create and use digital identities
- create fungible & non-fungible tokens
- create smart contracts
- …and many others!