Nerd For Tech
Published in

Nerd For Tech

How to build a proof of existence blockchain with Substrate?

The Substrate is a framework that allows users to create custom blockchains. This contrasts traditional blockchain development, which requires you to develop peer-to-peer networks, a JSON RPC layer, consensus algorithms and other features. This framework provides you with enterprise-ready software that you can customize as per your requirements.

To illustrate the simplicity of developing with Substrate, Let’s try to build a proof-of-existence blockchain. But before that, Let us understand Substrate and Proof-of-Existence consensus briefly.

What is Substrate?

The Substrate is an open-source modular framework that can be extended and modified to build interoperable blockchain networks like Polkadot. It is a software development kit (SDK) that was created to give developers access to all the essential elements of the blockchain and allow them to focus on the logic that will give your chain its creative features. The following attributes make Substrate stand out among all other distributed ledger platforms.

  • Open — The entire Substrate architecture and toolkit are available under an open-source license. Substrate’s core elements use open protocols such as json-RPC and libp2p, giving you the freedom to create your own blockchain architecture. The Substrate also has an active, supportive, and helpful community that contributes to its ecosystem. You can add more features to your blockchain as the community grows.
  • Flexible — Many blockchain platforms have strongly linked sub-systems that are difficult to disengage from. Chains built on forks of other blockchains can have unobvious couplings, making it difficult to disconnect. The Substrate can be used to create a customized blockchain that can adapt to your needs, and it can also grow with them as their needs change.
  • Future-proof — The Substrate was created to be modular and flexible. The Substrate state transition logic, which is a WebAssembly object, is a standalone WebAssembly runtime. Your nodes may be granted the power to modify the runtime, resulting in network runtime upgrades. Forkless updates are possible since nodes need not take any action to use the new runtime. Your network’s runtime protocols may change gradually and possibly dramatically to meet your users’ needs.
  • Interoperable — Many blockchain systems offer very limited interoperability with others, and cross-consensus messaging allows all Substrate-based blockchains to communicate. Parachains can be attached to Substrate to share the security of relay chains and can also be used to create autonomous networks by attaching to them.

What is Proof-of-Existence?

As the name implies, proof-of-existence is about recording and providing evidence that certain data or entities exist. It works in a very simple way, which gives you more insight into PoE. A timestamp and signature can be attached to a digital entity to provide Proof-of-Existence, and this is done so that authorized viewers can see the record’s creation date and time.

How do you build a Proof-of-Existence blockchain using Substrate?

This module is used to store online distributed proof-of-existence files.

Scope

This module allows users to submit proof that a file exists. This proof of existence can also be used to determine the owner’s soft measure. Files are not uploaded directly to the blockchain; a file digest is created and stored on a chain, including the upload date and the claimant.

Anyone with the source file can generate the same digest and also check the proof of existence on the chain.

Dependencies

Traits

This module depends on the implementation of the Currencytrait. This can be done by the Substrate Runtime Module Library (SRML) Balances module.

Modules

This module depends on the SRML Timestamp module.

How to do installation?

Runtime Cargo.toml

For adding the module to the runtime, you need to include the following to your runtime’s Cargo.toml file:

[dependencies.poe]

default_features = false

package = ‘proof-of-existence’

git = ‘ GitHub — substrate-developer-hub/substrate-proof-of-existence: Proof of Existence Blockchain built on Parity’s Substrate

After the above step, update your runtime’s std feature to include it in this module.

std = [

‘poe/std’,

]

Runtime

Lib.rs — home for Rust crates

To implement its trait, you should do the following:

impl poe::Trait for runtime {

type Currency = Balances;

type Event = Event;

}

Then, include it in your construct_runtime! macro:

POE: poe::{Module, Call, Storage, Event<T>},

You can view the reference docs for this module by running:

cargo doc — open

Final thoughts

As you can see, Substrate allows you to create custom blockchains with minimal effort. The Substrate provides all infrastructure needed to create a node, and SRML provides a set of pre-built tools you can add to your blockchain.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
LeewayHertz

LeewayHertz

413 Followers

Fullstack software and web3 development company building custom software solutions, dApps, metaverse platforms, etc. https://www.leewayhertz.com