Codementor Events

Build a blockchain with C++

Published Jan 02, 2019
Build a blockchain with C++

As a freelance programmer and software development mentor, I have seen posts on various sites (including Codementor) of potential clients requesting freelancers to develop some solution that involves blockchains for one reason or another.

Well, mostly due to latest craze in cryptocurrency, I suppose.

I never have applied for any of these freelance opportunities because I had no inkling what a blockchain was -- let alone how blockchains were implemented or operated.

So I decided it was time for me to expand my knowledge and learn about blockchains

I know that the Bitcoin code is open-source but I really did not want to dive into that source code just yet. I just wanted to get a basic understanding of the concepts behind blockchains.

So finally I decided to google "blockchain C++" and I ran across this fascinating blog post by Dave Nash.

This blog post not only explains in very simple terms what a blockchain is. But Mr. Nash also shows step-by-step how actually to create a blockchain and how to create a mining simulation similar to how Bitcoin mining works -- in C++ no less!

I typed out the code Mr Nash provided as I read through his blog post. Then I ran it though my debugger several times so I could understand how the code works.

This blog post really does provide a very simple explanation and implementation of blockchains and it really does gives one a basic understanding how blockchains work.

I plan to do further research into blockchains -- maybe now delve into the Bitcoin source code at this point.

If this is the barebones simplicity behind blockchains then I definitely want to know more about it!

Discover and read more posts from Anton Anderson
get started
post commentsBe the first to share your opinion
floydsvarmints
2 years ago

I know this post is a couple of years old. Have you delved any deeper into this? Smart contracts on the EOS and Wax ecosystems are done in C++ and there is a big demand.

Anton Anderson
2 years ago

Yes, I have. The more I researched into it; the more I saw that cryptocurrencies can be more likened to a video game.

Mining is nothing more than “guessing the encryption sequence of a blockchain”. Once one cracked the encryption sequence, there may be “gold” (in the case of Bitcoin: satochis, bits or bitcoin underneath that lair
so one can then sell on the “cryptocurrency” market).

Now if you asking me if I want to build my own cryptocurrency? No, I am really not that interested. Everyone now wants to be the next “Bitcoin” and the field is fast becoming glutted with “copycats”.

However, “smart contracts” sound interesting but could you tell me how they are in demand?

(I had to research that term by the way. I was not aware of this technology)

According to Investopedia (https://www.investopedia.com/terms/s/smart-contracts.asp):

“A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. The code controls the execution, and transactions are trackable and irreversible.”

So how and why is this technology being in the EOS or WAX ecosystems?

floydsvarmints
2 years ago

So right now the big thing is NFTs, which stands for Non Fungible Tokens, and instead of being a coin or fungible token, NFTs are unique sets of immutable data that can be attached to media or used as a record that can’t be altered and sold for crypto as sort of a transferrable digital certificate of authenticity.

The way smart contracts are being used in this space ranges from creating marketplaces to creating entire games that use the blockchain as a database to record digital assets.

A basic example would be a website that has a video or picture for sale. The buy button initiates a command to communicate with a crypto wallet that sends a transaction to the smart contract on the blockchain and when that contract processes the transaction, it automatically assigns ownership of that video or picture to the wallet of the buyer.

Now let’s say you have a video game where you fight a boss, when you defeat that boss it drops a reward such as sword or a helmet. The game code can send a transaction to a smart contract that will automatically create a digital game asset of that sword that can be assigned to the player’s crypto wallet. Now that player can use the sword in the game or if they want, can take that sword and sell it on the marketplace for crypto.

Really the possibilities are endless, and this space is going to blow up in the next few years.

Even now, the demand for people who know how to write smart contracts is so high, it’s hard to find people who have the time to do it for hire.

Anton Anderson
2 years ago

Well, that is interesting.

I will look into it but it doesn’t sound too difficult to implement.

Do you know anyone who is looking for C++ developers who this type of work.

floydsvarmints
2 years ago

As a matter of fact I am looking for a C++ developer for my project, and I know several other project creators who are probably looking for someone as well. I’ll send you a private message.

Show more replies