Foundations of Traceability on the Blockchain

Foundations of Traceability on the Blockchain

Edward Honour

Abstract: Product traceability is an important component of any supply chain. The ability to trace products within a supply chain can dramatically reduce the social and economic effects of products recalls. According to the United States Food and Drug Administration (FDA) about 48 million people are sickened by foodborne illness causing Billions of dollars in economic damage each year. The purpose of this document is to present the technical foundations for a blockchain network for product traceability.

This document defines a platform for a useful traceability system built from proven blockchain technologies and will present industry standard and best-practices necessary to provide a useful tracability system that can be easily adopted. The foundations of the blockchain are defined in Satoshi Nakamoto’s 2009 whitepaper, bitcoin.pdf.

The original Satoshi whitepaper defined a peer to peer cash transfer system that does not require a central authority operate. By creating additional functionality that operates using the principles of the original blockchain to support assets other than a coin, the blockchain provides an effective framework for product traceability.

1.1 Blockchain Basics

1.1 Blockchain Basics

To build a foundation to use the blockchain for traceability, it is important to understand how blockchains are used to securely transfer assets and protect the integrity of data.

The Blockchain provides a peer to peer cash transfer system deployed on a distributed network. There is no central authority managing the system to handle disputes or guarantee the integrity of the data on the network. The blockchain structure and the core technologies that support it must provide all the authentication, validation, and security of the transactions and data on the network.

A coin is defined as a chain of digital signatures. Coins are transferred from one party to the next in transactions. The input to each transaction is the unspent output from a previous transaction. Outputs from a transaction that have not been spent are part of the owners account balance and are available to be spent in future transactions.

When a coin is transferred it is digitally to provide validity of the transfer. The receiver of the coin can verify its authenticity and the history of the coin can be traces through the transactions that affected it. The chain of ownership provided by the blockchain is the foundation of the traceability blockchain.

Copies of the entire Blockchain are maintained on every node and consensus rules are used to synchronize the nodes and validate transactions. Nodes communicate directly with other nodes in the network using peer-to-peer communications. Peer-to-peer communications do not require a centralized computer to operate since each node can receive the information it needs from the other nodes it is directly connected to.

Theoretically each node on the network can establish a connection with every other node on the network, although this is not practical. An active node must be connected to at least 2 other active nodes and are usually connected to at least 20 other nodes in a large network.

The traditional blockchain technologies that support the distributed network and transaction model described in this section are used to support the traceability blockchain.

1.1.1 Transactions, Blocks and Hashes

1.1.1 Transactions, Blocks and Hashes

Data is stored in blockchains following a basic higherarchy. Assets are transferred and maintained in transactions, transactions are stored in blocks, and blocks are connected using hashes. Blocks may contain one or more transactions and are created by miners on a schedule determined by the difficulty of the network. The time interval between blocks is determined when the blockchain is launched. Bitcoin creates blocks approximately every 20 minutes and most other blockchains create blocks every 1 to 2 minutes.

As transactions are created on the blockchain network, they are ordered by the time they were created and validated by the network. Once they are validated, they are written to the network in blocks. Blocks are cryptographically linked to the prior block using a hash. A hash is value created a one-way function to identify the block hash not changed. If a block is changed by even a single byte the hash will change noticeably. Most discussions related to blockchain structures focus on the relationship between nodes on the network and the cryptography between blocks and hashes. For traceability, the focus needs to be on the relationship between assets and transactions and the identification of assets within the blockchain.

1.1.2 Distributed Ledger

1.1.2 Distributed Ledger

Since each node on the network receives every new block as they are created to create copies the blockchain distributed all over the world, transactions must be represented in a format that can support this type of network. In an large distributed network it would be hard to change transactions once they are written. In an accounting ledger, transactions are also not changed once they are written. An incorrect transaction is corrected, or reversed, using another entry to the ledger. Although having thousands of copies of data helps protect the network from fraud, it also creates the requirement that data be represented as a distributed ledger.

1.1.3 Immutable Ledger

1.1.3 Immutable Ledger

The term "immutable" means cannot be changed. The basic architecture of the blockchain makes Immutability protects the blockchain by fraud by allowing transcation in previous blocks to be trusted. Once a block has been processed by an application using the blockchain, it is no longer necessary to check the block again to determine if transaction in the block has changed. This is important for building useful application that use the blockchain. Since blockchains become very large over time, it is important that application only need to read new blocks as they are created.

1.1.4 Public vs. Permission Blockchains

1.1.4 Public vs. Permission Blockchains

The Satoshi whitepaper defines a public network that operates using consensus and is designed around the premise that nobody trusts each other. A mechanism called "proof of work" was established to prevent the blockchain from being overwritten by anyone attempting to forge transactions and blocks. The distributed network is protected by "miners" who solve the proof of work algorithm on the network.

Within the last few years permission blockchain have been introduced where the blockchain is located on a private network and proof of work is replaced by different authentication methods. Although the decision between a public blockchain or private blockchain does not matter for traceability, this document assumes the blockchain is a public blockchain conforming to the 2009 Satoshi whitepaper. The fear of public blockchains is unfounded. Once a stakeholder understands how a public blockchain protects data, the need for a private or permission blockchain is no longer necessary.

2.0 Transactions

2.0 Transactions

Each transfer from one party to another is represented by a transaction. As we stated in the prior section, a coin is defined as a chain of digital signatures and the transactions are stored in blocks. The foundational algorithm used to structure transaction is called UTxO which stands for Unspent Transaction Output.

In this section we will present an analogy that makes it easier to understand how assets are handled and transactions are structured in the Blockchain.

2.1 Envelope Analogy

2.1 Envelope Analogy

Imagine a cash system where anytime you receive a payment it comes to you in an envelope. The envelope is completely secure and cannot be opened by anyone but you. You are not allowed to open the envelope until you decide to spend the money inside the envelope. Written on the outside of the envelope amount of money contained, and a number identifying the transaction where you received the envelope, and a signature that validates the transaction. If you want to know how much money you have in your wallet, you add the amounts written on your unopened envelopes. Every transaction in this system must follow rules that ensure the transactions are fair and that nobody spends money they don’t have.

To illustrate a payment in this system, let’s say Alice wants to buy a case of tomatoes from Bob for $40. In a standard payment system, Alice would remove $40 from her wallet and give it to Bob. In this system, Alice must find as many envelopes as necessary to find $40 to pay Bob.

In many cases, Alice won’t have an envelope with the exact amount of money in it. She may have one envelope with more than $40, or she may have to use multiple envelopes to get enough money to pay Bob. In this scenario, Alice finds two envelopes. The first envelope contains $20 and the second envelope contains $30. She can also see on the envelopes that she received the $20 envelope from Mary and the $30 envelope from Eve, although this doesn’t matter for making the payment, but it is very helpful if she wants to trace the payment later.

The transaction starts with Alice using the envelopes as inputs to the transaction. Each transaction is given a unqiue number and in the case we will call it transaction 660. Once the envelopes are used in this transaction the envelopes can not be used in future transactions. This ensures Alice does not spend $40 with Bob and then spend the same $40 with Mary. The transaction algorithm takes the money from the envelopes and creates a new envelope for Bob with $40. The system seals the envelope so it can only be used by Bob, writes the information on the envelope, and gives the envelope to Bob as payment.

At this point in the process, there is still $10 left that is owed as change. The system creates an envelope for Alice containing the $10 in change. The system seals the envelope so only Alice can open, puts the information on the envelope and signs it with Alices’ signature.

This provides a basic illustration of the Unspent Transaction Output Algorithm (UTxO). The transaction starts with the outputs of prior transactions where Alice received cash. Since the outputs were not spent, they can be used to create a payment. The transaction ends with two outputs. $40 to Bob and $10 to Alice. These output are unspent allowing them to be used as inputs to another transaction. The figure below shows the result of the transaction. The original envelopes Alice used in the transaction are no longer in her wallet. Alice has a new envelope marked with transaction 660 for $10 and Bob has a new envelope with $40 also marked with transaction 660.

The Unspent Transaction Output Algorithm provides traceability as a byproduct. The output envelope that Bob receives containing $40 was created by a transaction with one or more input transactions. Each of the input transactions also has one or more transactions that link it to previous transactions. This flow continues until the point at where the cash used in Bob’s $40 was minted.

The UTxO algorithm provides a system where money can be transferred but cannot be spent more than once. Each transaction has a timestamp it is placed it time order before it is validated and put on the blockchain. Bob will not receive the cash from Alice until the blockchain has verified that it is a valid transaction.

2.2 Traceability of Transactions

2.2 Traceability of Transactions

In the previous we illustrated how cash in a blockchain network is managed as a series of inputs and outputs to transactions. Each transaction is uniquely identified and has one or more inputs and one or more outputs. This structure provides the benefit of traceability from any point in the blockchain. To provide transparency, blockchain networks like bitcoin provide a block explorer people can see the transactions in each block and view the inputs to each transaction.

2.3 Blockchain Supporting Technologies

2.3 Blockchain Supporting Technologies

In previous sections, we have discussed how transaction are created and stored in the blockchain network but we have not discussed any of the technologies that support the blockchain network. When a coin is transferred from one party of another each party must be unqiuely identified in the system by an address.

2.3.1 Blockchain Address

2.3.1 Blockchain Address

The blockchain address is a public number that is used just like the post office uses your physical address to deliver mail. The blockchain address is number which takes different formats depending on the blockchain platform. For our purposes we define an address as a 64 character hexadecimal number which is the public key in a public/private key pair. In most blockchains, the blockchain address is the public key and the account owner has a private key that is mathematically related to the public key. Key pairs are the foundation to cryptography and digital signatures and allow transactions to be signed without sending the private (secret key) across the network. The technologies behind public/private key pairs is beyond the scope of this document. The users wallet is used to maintain keys and perform the cryptography necessary to sign and create transactions on the blockchain.

2.3.2 Wallets

2.3.2 Wallets

The blockchain wallet has two primary purposes. The wallet maintains the user’s private key and performs the cryptographic functions necessary to create a digital signature without sending the private key to the network. The second function of the wallet is to maintain the user’s balance and available transaction outputs without requiring the wallet to rescan the entire blockchain each time it is used. Since a user’s account balance is the sum of all the unspent transactions, the method used to calculate the balance requires scanning the blockchain from the first block all the way to the current block. With a large blockchain this process may take hours so the wallet keeps track of what blocks have been scanned and what transactions have been found.

3.0 Other Types of Assets

3.0 Other Types of Assets

In the prior sections we described how cash in a blockchain system is tracked as a series of inputs and outputs. The provides everything necessary if the system supported by the blockchain maintains cryptocurrency only. When a transaction transfers currency, any unspent transactions where the user received currency can be used in a transactions. Although this has been proven to be a useful currency transfer system, it is not suitable for tracking products.

In our previous analogy, Alice paid Bob $40 for a case of Tomatoes and the blockchain was to manage the payment. The next step of the analogy is to include the Tomatoes in the blockchain transaction. Alice will transfer $40 to Bob and Bob will transfer a case of Tomatoes to Alice. To manage this process on the blockchain, the blockchain must identify tomatoes as something different than cash.

3.1 Tokens

3.1 Tokens

One mechaniuusm presented in blockchain like Ethereum is to represent non-monetary assets like Tomatoes as tokens. A token represents an asset on the blockchain that is not the cryptocurrency of the blockchain. In most cases Tokens have been used to represent an alternate currency, but in our analogy, we want to use a token to represent a case of tomatoes. In Ethereum and other platforms, tokens are managed using smart contracts that define the rule that apply to each token. In a traditional, satoshi style blockchain, tokens would be managed using rules and validation requirements of cryptocurrency.

3.2 Using Tokens to Identify Asset Types

3.2 Using Tokens to Identify Asset Types

In the tomato analogy, we will introduce the TOM token that represents one case of tomatoes. If we were to define a useful currency, tomatoes would probably not be a currency for several reasons. They are perishable and hard to handle. They also don’t divide into smaller units nicely which is something necessarty in both currency and asset tracking.

To expand on the original envelope analogy, envelopes will contain tomatoes and white envelopes will contain currency. Bob is selling one case of tomatoes to Alice for $40. Like the previous example, Alice starts with a white envelope containing $20 and another white envelope containing $30. Bob has a red envelope containing 5 TOM tokens that represents the 5 cases of Tomatoes Bob has in inventory. The inputs to the transaction are Alices’ two white envelopes and Bob’s one red envelope. The outputs of the transaction are the $40 paid to Bob in a white envelope.

One case of tomatoes transferred to Alice in a red envelope, along with the change due in both cash and TOM tokens. Alice receives a white envelope with $10 in change and Bob receives a red envelope with 4 TOM tokens. The transaction is a success with Bob receiving payment and Alice receiving tomatoes.

This illustrates the basics of using a token system to identify a non-monetary asset traceable on the blockchain. Tomatos are identified by a token that is treated like a currency with complete traceability. f Bob was a distributor and received the tomatoes from Mallorie’s farm, the transaction where he received the tomatoes would allow them to be traced back to Mallory.

Unfortunately, this system is not suitable for a real world use-case for several reasons.

3.3 How assets really need to be tracked

3.3 How assets really need to be tracked

In our illustration we created a TOM token to represent tomatoes. If Bob is a distributor that also sells lettuce, Bob could represent lettuce with a different token. Unfortunately, the tracking of products is much more complicated. If Mallory is a tomato farmer and Mallory's neighbor Stan also is a tomato farmer growing identical tomatoes, Mallory's tomatoes and Stan's tomatoes must be tracked separately by Bob. It wouldn’t make any sense for the system to use one token for Mallory’s tomatoes and a different token for Stan's tomatoes.

To make this even more complicated, even tomatoes sold by Mallory and Stan need to be tracked separately if they are packaged on a different dates representing different batches of tomatoes. In order to provide an effective asset tracking system, products must be tracked on the blockchain in a way compatible with industry requirements and standard.

3.4 Numbering Standards

3.4 Numbering Standards

In data science an important element for success is the ability to standardize identifiers which requires a standards organization. GS1 is a non-profit organization formed in 1974 that creates a numbering standard used world wide in several industries. When you purchase a product from a retail store and scan the UPC barcode on the package, it is GS1 that created and manages the numbering standard used to create the create the number representing the product and the barcode.

GS1 Prefix

When a company joins GS1 and adopts the standard, they receive a company prefix that is used for all the numbers created by the company. This ensures that the identification number is unique worldwide. There are several numbers that GS1 establishes that are very important to global trade, but the most import identification number for traceability is the Global Trade Identification Number it GTIN.

Global Trade Identification Number

Each product produced by a company is identified by a GTIN. GTINs are defined for every product, including wholesale products and intermediary products. An example of an intermediary product is a giant batch of guacamole that has been created and is not yet packaged into its final packaging. A product packaged in different packaging will have a different GTIN for each product package. Companies using GS1 may create many different GTINs which may be represented in different kind of barcodes.

Since GTIN are created based on the Prefix of the company generating it, the same product create by different companies will have different GTINs and the GTINs are not related in any way other than they are all 14 digits. Three farms growing and packaging tomatoes will have three different GTINs even though they are interchangeable in a recipe. In a transitional computer system having many number representing the same item would cause difficulty, the structure of the blockchain makes handling this a simple product.

Lot Numbers

Each time a company creates a product they create a lot number representing the batch of product created. Within the company, the GTIN represents the product and the combination of a GTIN and a LOT number is required to identify specific inventory. When inventory is received, the receiver will receive both a GTIN and a LOT number. If the company is GS1 compliant, the barcodes used to represent the GTIN and LOT number follow the GS1 standards.

4.0 Industry Requirements

4.0 Industry Requirements

The Food Safety Modernization Act (FSMA) passed in the United States Congress in 2010 to help ensure the US food supply is safe since each year 1 in 6 people becomes sick each year from food borne illness.

4.1 One Up, One Back Traceability

4.1 One Up, One Back Traceability

FSMA requires all businesses handling food to be able to track where the food was received from and where it went. Achieving one-up-one-back traceability can be performed using the blockchain even neither the business shipping the product to the business or receiving the product from the business is also on the blockchain.

5.0 Blockchain Identifiers

5.0 Blockchain Identifiers

Blockchains and cryptography in general are based on very large numbers. UA blockchain identifier may be a hexadecimal number that is 64 characters. What is important with these giant numbers is that they are unique, cannot be guessed, and they are not sequential. In our examples so far we have identified the need to be able to identify non monetary assets on the blockchain in a way more sophisticated than using tokens. To this we propose handing assets in the Blockchain using two classifications. An asset is either a coin or it is not a coin. Coins will be handled as they currently are within the Blockchain. Other assets will be identified using asset identifiers. Any non monetary asset can be an n input to any other non monetary asset as long as all the Blockchain rules are followed. We will use the standard functions and processes used in the Blockchain to create identifiers. Start with hash functions.

5.1 Hash Functions

5.1 Hash Functions

A key element in cryptography are one-way functions. These functions are used to create identifiers that cannot be reversed to determine the inputs used to create them. These functions allows us to create numbers that seem meaningless but can be recreated easily if you know the inputs to the functions. For our purposes we will use the SHA-256 function to create 32 byte identifiers. A 32 byte identifier is 64 characters in length.

5.2 Identifier Requirements

5.2 Identifier Requirements

All identifiers used within the blockchain are public. Everyone can see them but no one can figure out what they mean. For traceability in the Blockchain a transaction affecting an asset contains one or more inputs. In most cases the inputs to the asset are other assets unless the asset is a new asset that was not created from other assets. In that case, the input to the asset is the Blockchain Address of the creator of the asset.

5.3 Asset Identifiers

5.3 Asset Identifiers

In our tomato scenario we created a token called TOM to represent tomatoes which would allow us to trace the tomatoes we receive. Since in the real world we need to track potentially millions of different things separately, we blockchain system needs an asset identifier that can replace a token identifier. To do this we are going to use a one way function “f” that has three variables, the GTIN, the LOT number and the blockchain address of the owner of the asset, defined as:

f(GTIN,LOT,ADDRESS)
The function returns a unique 64 digit hexadecimal number as the output.

When most people first look at this function, they wonder why the blockchain address is used in the function to create an asset identifier, when GTIN and lot number uniquely define the asset. In a short while this will be obvious so we will not cover it now.

5.4 Blockchain Address

5.4 Blockchain Address

In any blockchain system coins or other assets are transferred from one blockchain address to another. In most blockchains an address is generated by a mathematical function since the blockchain addresses have mathematical properties that are beyond this discussion. In the case of traceability, a blockchain address must be more like a physical address than a standard blockchain address. With a standard blockchain everyone involved in a transaction is using the blockchain. This is not the case with a traceability blockchain. Alice may be purchasing tomatoes from Bob and only one of them is using the blockchain. If Alice is using the blockchain but Bob is not, Alice must be able to figure out what Bob’s blockchain address would be if he was using the blockchain.

To do this, we are going to derive blockchain addresses from physical addresses. The blockchain address generated by function "A" where longitude, latitude are required variables, and GLN is an optional variable.

A(lng,lat,GLN)

5.4 Example – Sending and Receiving

5.4 Example – Sending and Receiving

Let’s go back to our example of Alice buying tomatoes from Bob. From now on we are not going to include the currency in any of the transactions. The transaction is now simply, Bob transfers a case of tomatoes to Alice.

First let’s create the transaction as Bob transferring the tomatoes to Alice. This time, Bob's red envelope does not have the TOM token label on it. The token is replaced by an asset identifier that was calculated using a function. The input to the function was the GTIN of the tomatoes, the lot number, and Bob's blockchain address.

The GTIN and LOT number are both on the barcode of the tomatoes because the tomatoes were packaged using the standard defined by the Produce Traceability Initiative or PTI. Bob knows his blockchain address, so the asset identifier was easily calculated. When Bob transfers the tomatoes to Alice, the asset identifier that Alice uses is different than the one Bob uses for the same GTIN and lot combination. Alice's blockchain address is used in the function to calculate the identifier.

Let’s say Bob doesn’t know Alices' blockchain address or Alice isn't using the blockchain. Alices' blockchain address can be easily calculated from the address where Bob is shipping the tomatoes. Bob would send the physical address to the API and the Alices' blockchain address would be returned.

Figure X, shows the transaction. Bob’s input to the transaction has the asset identifier that starts with 5. The output of the transaction is Bob’s asset with the same asset identifiers and Alice’s tomatoes with the asset identifier that starts with a 9.

This shows why we included the address when we calculated the asset identifier. Bob’s asset is an input to Alice’s so we can trace Alice’s tomatoes back to Bob. From now on, Alice needs to manage her tomatoes separately from Bob. If Alice were to accidentally do something bad to the tomatoes she received, having a different asset ID helps us when it is time to trace the tomatoes.

Now that we have created the transaction forh Bob shipping tomatoes to Alice, we can create a transaction with Alice receiving the tomatoes from Bob. The transfer of the tomatoes can be performed either way or both ways.

5.5 Overlapping Transactions.

5.5 Overlapping Transactions.

In many cases transactions on a traceability blockchain will need to overlap with different parties transferring the same information. It is important that the blockchain only maintain a single copy of the traceability structures, so it becomes a requirement of the blockchain to merge overlapping transactions.

6.0 Transformation Functions

6.0 Transformation Functions

In our examples we have focused on transferring an asset from one place to another. The next requirement of a useful system is to handle the transformation of an asset from one product to another. A transformation occurs any time a new GTIN or Lot number is created. Transformation transactions have the same source and destination owners and may occur when a new product is created or a product changes packaging.

A transformation function containing the same source and destination address is not new to blockchains. In cases where a user receives many transactions in very small amount they transactions may need to be merged to create a transaction where the user transfers a large amount of money. For example, if a person receives 1000 transactions of $1 each, it would require 1000 inputs to make a payment of $1000. Blockchains support a transformation function called a fusion transaction to create a larger output from many small inputs. The figure below, shows how fusion transactions would be used combine 1000 transactions into a single transaction in multiple steps.

6.1 Manufacturing Example – Make Guacamole

6.1 Manufacturing Example – Make Guacamole

In the next example, we will illustrate a transformation transaction by creating a batch of guacamole from tomatoes, onions, and avocados. If Alice wants to create guacamole, she needs to have inventory of the ingredients on hand. Each of the ingredients necessary become inputs to the transaction. If Alice is using tomatoes that came from Mallory and tomatoes that came from Stan, the both are inputs to the the transaction.

In transformation transactions, the output of the transaction includes a product with a new GTIN and LOT number that was not one the inputs. The functions we use to create asset identifiers allow all non-monetary assets to be tracked in the blockchain with worry about keeping the assets straight.

In this illustration, we see 2 different tomatoes in input, an input of onions, and an input of avocados. The main output is the new Guacamole and the and the left-over onions tomatoes and avocados. Notice that quantities are not required for the inputs. For traceability we need to know the products that were used in the batch, but we don’t need to know how much of each input. Therefore the ingredient inputs will always be included in the output even if all of the product was used.

Now we have created a giant new batch of guacamole and given it a lot number and identified it by its intermediate GTIN. Next we need to package the guacamole so it can be shipped and sold to stores. This is also handled by a transformation function.

6.2 Packaging Example – Package Guacamole.

The transformation function to package the guacamole takes the big batch of guacamole we just created, and outputs a new GTIN with the same lot number representing the 16 ounce packages of guacamole. These packages we labeled with the UPC barcode so they can be sold in stores. The output also contains the original large batch we used as input.

The original batch may be used as an input again to create 8oz packages, 3 pound packages, and wholesale packaging. If necessary, non-food related inputs can be added to the asset. Maybe Alice needs to track the actual packaging that is used for each product. If so, it is easy to add the packaging as an additional input.

6.3 The effect on Traceability

6.3 The effect on Traceability

From a blockchain standpoint transformation transaction can be traced exactly like transfer functions. Everything is an input and output. If we look back at the asset identifiers we see that each input is a 64 character number and each output is also a 64 character number. Although the numbers do not look human readable, they are perfect for the blockchain.

7.0 Traceability Processes

7.0 Traceability Processes

In order to build an effective traceability system, we need to establish procedures to trace assets using the Blockchain once assets have been stored on the blockchain. In a cryptocurrency blockchain and blockchains storing non-monetary assets like tokens, there is no need to trace specific assets in the blockchain. In our case we must be able to trace an asset both forward and backward from the current state of the asset.

7.1 Finding the Current State of an Asset

7.1 Finding the Current State of an Asset

In order to illustrate the issue, let’s look at an asset on the blockchain and explore how a system would find the asset. In this example, Alice is taking the tomatoes that she received from Bob and packaging them as sliced tomatoes.

In the first step, transaction 1000, Bob ships the tomatoes with asset identifier TLB (tomatoes, lot, Bob) to Alice where her asset identifier is TLA (tomatoes, lot, Alice). Figure 7 shows transaction 1000 representing this transfer. TLA is the new asset with TLB as the input to TLA and TLB is also an output. At the end of transaction 1000 Alice’s asset TLA is stored showing 1 input and no outputs.

Next, Alice creates transaction 2000 to package the tomatoes as sliced tomatoes giving it a new GTIN of “S”. The asset identifier SLA represents the new asset. Transaction 2000 contains one input which is the asset TLA and two outputs, the new asset SLA and the new state of the asset TLA.

At the end of transaction 2000, the asset TLA contains one input and one output. The sliced tomatoes have become an output of TLA.

If Alice wants to trace asset TLA, it is necessary to find the current state of the asset. The current state of an asset is found in the latest transaction where the asset is an output.

If the blockchain is scanned from beginning to end, searching for any transaction where SLA is an output, the last transaction where it is found will contain the current state. Although this is a possible way to search for an asset, it can be improved dramatically by introducing a key value store.

7.2 Key Value Stores

7.2 Key Value Stores

A key/value store provides an indexing mechanism for finding a value from a key. Key/value stores are used extensively in blockchain wallets to maintain a list of transactions where the wallet address is involved. In this case, a key value store can be easily maintained to provide the latest transaction for any asset. The same key value store can also be used to find which block contains the transactions.

The process for finding the asset SLA on blockchain would follow a simple process shown in figure 9. First, the asset identifier is calculated using the asset identifier function. Next the asset identifier is used to find the transaction number, and then the transaction number is used to find the block. This key value store allows any asset to be found on the blockchain using two queries of the key value store.

7.3 Tracing an Asset

7.3 Tracing an Asset

In order to trace an asset, the first step is to find the asset on the blockchain using the process outlined in the prior section. Once the asset has been found a list of inputs and outputs is available to perform a forward and backward trace. Tracing our example follows this process.

First the Asset is found with the list of inputs and outputs. To trace backwards, each input will follow the same process. The asset is found, and then each of its inputs are traced until a tree of inputs has been created.