Designing Namespace and Address for Hyperledger Sawtooth Transaction Family

  • Implementing Hyperledger Sawtooth Transaction Family

    After the namespace and address scheme is defined for the transaction family, the state, transaction, and payload encoding scheme can be defined.

    To define the state, you should analyze the data requirements for your organization and follow an appropriate modeling process to define the semantic data model for the system. For example, you could use entity-relationship modeling to represent conceptual data logic in your enterprise. In our example, the state is as follows:

    hyperledger sawtooth transaction family 5


    This can be explained as follows:

    • House APN (Key): The Assessor Parcel Number (APN) for a house is a unique number assigned to each parcel of land by a county tax assessor. The APN is based on formatting codes, depending on the home’s location. Local governments use APNs to identify and keep track of land ownership for property tax purposes.
    • House Owner: The name of the person who currently owns the house.

    Defining transactions involves analyzing all your business use cases and the attributes used to perform these business operations. In our example, transactions and their payloads are as follows:

    • House APN (Key): The key attribute for the state.
    • Action: This can be either the create keyword or the transfer keyword.
    • House Owner: The name of the house owner.

    To define payload encoding schemes, you could choose from one of the following methods:

    • JSON Encoding: JavaScript Object Notation (JSON) is a lightweight data-interchange format that is popularly used in software systems as an alternative to XML. The standard JSON package for Python can be found here: The advantages of using JSON are that it is human-readable, it is supported in most programming languages, and it is easy to encode and decode using libraries.
    • Protobuf Encoding: Protocol buffers are Google’s language and platform-neutral mechanism for serializing data. With protobuf encoding, you define the message formats in a .proto file and compile them using the protocol buffer compiler. To find out more, you can follow the guide that can be found here: It is small, fast, and simple, but it is not human-readable. Like JSON, it is also supported in many languages, such as Java, Python, C++, and Go.
    • Simple text encoding: This involves defining your own message format and carrying out character encoding using your own protocol with a special delimiter, or following common formats, such as .csv or base64, to represent data in an ASCII format or string. These are human-readable, simple, easy, fast, and language- and platform-neutral.

    For our example, the encoding for the state and payload is simple text encoding that encodes the data with UTF8 and the CSV format. We are using the Sawtooth XO family as a template.

    For hash collisions, the colliding state will be stored as the UTF-8 encoding of the string with a delimiter, |, such as entry 1|entry 2:

    ‘|’.join(sorted([‘,’.join([house, owner])

    for house, (owner) in house_list.items()])).encode()

  • Related:

    • No Related Posts

    Leave a Reply