Building a Blockchain: What, How, and Why

DevOpsIndustry

Reading Time: 5 minutes

To put it mildly, cryptocurrency is an incredibly popular topic right now. Much of the hype around it tends to be focused on the physical value that these currencies represent. However, I believe something even more precious lies under the hood of cryptocurrencies: the concept of blockchain.

The ideas around blockchain are significant because they’re the engine that enables cryptocurrency to be so secure and cohesive. It’s crucial for us to differentiate their value from the actual data they usually contain, like Bitcoin transactions. Blockchain technology isn’t only for cryptocurrency; cryptocurrency is just what helped it break into the mainstream.

With all of this said, how do we sort through all of the buzz? I believe that by asking three questions, we’ll be able to understand the value of blockchains much more clearly:

  1. What exactly makes up a blockchain?
  2. How would we implement our own version of blockchain?
  3. Is using blockchain right for my company?

Dissecting a Blockchain

At a high level, a blockchain is a series of decentralized databases that are connected to a large, distributed network. Each database contains and generates records known as blocks. These blocks can contain literally anything, but they do have a few constant attributes:

  • An encrypted hash of the previous block
  • A timestamp
  • Payload data, eg, transaction data

Each of these pieces plays a crucial part in making the blockchain unique and secure. Most implementations use the encrypted hash of the previous block and timestamps to check the validity of a new block. No previous block can be modified without the complete change of every other block in the chain.

In other words, every block must be in chronological order and have the previous block referenced to it. Any modification of blocks outside of this wouldn’t be accepted by the blockchain at large.

Another thing that makes this architecture unique is its emphasis on decentralization. This means that an entire blockchain isn’t located on just one main machine or database. Individual blocks are distributed in numerous computers around the world.

In order for someone to maliciously control and alter a blockchain, they would have to control all blocks across all of its networked computers!

While this is certainly possible on smaller blockchains, the probability of achieving total ownership of a blockchain diminishes with each new computer added to the chain.

Reading about all of these higher-level ideas might seem like a satisfactory business pitch, but how would you actually build one from a technical perspective?

Creating a Blockchain

Bitcoin is actually a wonderful place to start on this subject. The entire framework of the cryptocurrency is open source and available online. Looking at Bitcoin’s implementation, we can see a few common themes:

  • We need something to store.
  • We need a distributed network of computers to power the transfer, creation, and verification of blocks.
  • We need a means of incentivizing other computers to join our blockchain.

Stored records

As I mentioned earlier, there’s a difference between a blockchain and the valuable things it stores. There is technical importance around what exactly is stored in each block. Historically, blocks have stored information that has a record-like format. For example, Bitcoin transactions are what Bitcoin’s blockchain stores.

However, one could argue that, due to the open-source nature of blockchain’s design, it could be extended and modified to store anything. We just need to make sure that whatever is being stored within a block can interact with previous copies or iterations of itself. This is why records tend to be the natural choice for storage on a blockchain. They’re unaffected by whatever comes before or after them; they’re simply a recording of something that occurred at a specific time.

Chained computers

Another thing we’ll need is a series of computers to power the entire chain. These computers will need to be constantly connected to each other and actively contributing computing power to the chain.

Many implementations encourage computers to help “mine” or create and verify new blocks as well as store existing ones. However, incentivizing other computers to invest all of this computing power can be tricky.

Participation incentives

This is where mining incentives come in. We need a means for our computing power to not only participate once, but also continue to participate in our blockchain.

The reason that cryptocurrency has been so popular in the past is because they’ve rewarded users with Bitcoin and the like in exchange for helping power various blockchains.

Now that we’ve explored what makes up a blockchain, why would we actually want to build one for ourselves or others? Furthermore, why would we choose this implementation over other solution architectures?

Understanding When to Utilize Blockchain

Blockchains are complex and expensive pieces of technology to build and maintain. They require a lot of computing power and the willing participation of networked computers. So, it’s safe to assume that they aren’t a solution for every problem we may have.

Public record

Furthermore, companies must ask themselves whether they want the information stored in the blockchain to be of public record or of private record. Depending on the answer, you would either have a public or private blockchain.

Both have their pros and cons, though it’s worth noting that the blockchain was designed from the public point of view, so private ones are somewhat new.

Public blockchains are chains that have a focus on incentivizing and enlisting the general public into joining their mining pools. They must not only have something valuable to the public at large, but also a valuable means to incentivize folks to help power it (again, why cryptocurrencies are so popular).

Private record

On the other hand, private blockchains are private networks that power decentralized databases. These chains are able to store information in a private and somewhat secure matter (since not everyone can join), but they increase the effort it takes to compromise a data set by quite a bit. It might be useful to store confidential transaction data, secure plans, or even simple assets like movies on these chains. These private blockchains might be able to prevent things like massive hacks of major companies in the future.

Both of these approaches come at different costs. You’ll be spending extra computing power and storage to simply verify and create the means for storing this information. Sure, technologies and methodologies for each of these aspects are getting better constantly, but whenever you jump into developing a blockchain, you’ll be committing to the current specs of the technology you’re using.

Its really important to ensure that the information you’re storing is valuable and worth putting all this effort into scattering and securing. Financial data makes a lot of sense — like many things we exchange, it has a value, and we often accumulate it privately. Yet, it would be quite costly if I just stored something like random cooking notes on a blockchain.

The computing costs are pretty high to secure pieces of information that aren’t really the valuable.

Wrapping Up

At the end of the day, the ideas behind cryptocurrency and the blockchain are very interesting. It’s just really difficult to see them at the moment because of the massive amount of attention around the value of cryptocurrency right now. If we can see through the hype and find the right use case, implementing a blockchain may very well change how many core technologies are structured and created.

Subscribe via Email

Over 60,000 people from companies like Netflix, Apple, Spotify and O'Reilly are reading our articles.
Subscribe to receive a weekly newsletter with articles around Continuous Integration, Docker, and software development best practices.



We promise that we won't spam you. You can unsubscribe any time.

Join the Discussion

Leave us some comments on what you think about this topic or if you like to add something.

  • Personally I feel this and most similar articles sort of miss the point and/or overstate the innovative nature of blockchains. From a purely technological perspective, a blockchain itself is pretty boring. After all, what is Git if not block hashes + timestamps + payloads (and other people have written about this way too much already, so I won’t go into details) and cipher block chaining has been standardized in 1981. You can also read “How to Time Stamp a Digital Document” from 1991, which many people consider an important precursor to blockchain/cryptocurrency as we know it today:

    https://www.anf.es/pdf/Haber_Stornetta.pdf

    “This means that an entire blockchain isn’t located on just one main machine or database. Individual blocks are distributed in numerous computers around the world.”: Every BTC or ETH full node does have a full copy of the chain and UTXOs, otherwise they couldn’t validate new blocks. If you’re a thin client like a wallet it’s ok to only store blocks that contain transactions by the addresses you control in their Merkle trees, but full nodes can’t get away with that. Individual blocks are GENERATED by computers around the world, but once they are added to the chain, they are stored on every full node.

    “In order for someone to maliciously control and alter a blockchain, they would have to control all blocks across all of its networked computers!” — In a PoW chain they’d need to control the majority of the hashing power, which is why it’s commonly called a 51% attack, though you can theoretically get away with less than that.

    https://learncryptography.com/cryptocurrency/51-attack

    “These computers will need to be constantly connected to each other and actively contributing computing power to the chain.” Sort of the whole point of building this on top of P2P protocols is that computers can drop in and out, they just need to update their copy of the chain when reconnecting. Plus it’s perfectly possible to run a non-mining full node.

    Also I think “They require a lot of computing power” is a big oversimplification that only applies to PoW. There are many other consensus mechanisms (PoS, PoA, BGT, PoWeight, DAGs etc) were this statement just doesn’t apply.

  • If you are thinking of how you can add blockchain to something like an ERP application then you could start by looking at http://www.multichain.com who have created a version of blockchain which uses data streams. A single blockchain can contain any number of streams, and each message in a data stream can contain up to 64MB of data. This is a private permissioned blockchain which does not require huge processing power to perform its mining, so you can install each Multichain server on an existing application server. There is a simple API which allows your application to talk to the local multichain server, and this server then
    handles all the communication with other nodes in the network including the
    mining or verification of each new block.

    The ERP application at https://geoprise.com/content/gm-x-blockchain
    has already been modified to include integration with Multichain. We transmit
    data between nodes as XML documents so that the GM-X database at each node can be kept synchronised. Each XML document can contain data from any number of database tables. We use this technique, for example, to send an RFQ from a Buyer to a group of Sellers, send Quotations from each Seller to the Buyer, send a Purchase Order from the Buyer to the winning Seller, then send a
    Shipment Notification from the Seller to the Buyer when the order is fulfilled.
    Although each message is sent to every node on the network there is a technique
    whereby encrypted messages can only be decrypted by authorised recipients.

    Due to the architecture of GM-X integration with Multichain took only four weeks, which is why GM-X was the first ERP application to include blockchain support.

  • Steve Button

    I still don’t get it. Can you supply some examples of where a company would like to use this? I keep seeing “innovative” fintech companies that are using blockchain, but I have never worked for any of them, so I have no clue what they are actually doing. Can anyone share a simple example?

    • Red

      Example of use for Blockchains Airline ticketing, Real Estate, Online Gaming, Fintech is a way of payment solution not Cryptocurrency adopted yet. But sooner it will be.

      Red

      • Blockchains can be used for much more than financial transaction and smart contracts. You can use the data streaming ability of MultiChain (www.multichain.com) anywhere where there is collaboration between two or more organisations. It has already been implemented in an ERP application to exchange RFQs, Quotations, Purchase Orders and Shipments, so the sky is the limit.

  • Pingback: Blockchain: Links And Resources (173) | Angel ”Java” Lopez on Blog()