BUILDING A CRYPTOCURRENCY WITH BLOCKCHAIN
If you have a cryptocurrency, then you own something digitally, you have an asset, considered to be a coin because it is relatively rare, hard to get and everybody also wants to have it. That’s what makes this digital property be considered money, hence has value and you can exchange for other things (goods or services) that you also desire.
Basically, that’s the same thing that happens with the printed paper you have in your wallet/pocket, it has value because the govern (the owner of the printer) it says so, and you trust them (don’t you?). Let’s not forget our internet banking account balance, that numbers are completely virtual (digital, there’s nothing concrete behind), it is money because you (and the others) trust in your Bank (as long as they are considered economically “healthy”).
In its not-so-technical version explanation, normally directed to business people interested in this subject, usually, blockchain is presented as a distributed ledger, a decentralized database with encrypted transactions. That’s perfectly fine, there’s no centralized server controlling the information (like a Bank, Govern, etc.), there’s no master, every participating node has its own copy, and when new data is appended, all of them has to come to a consensus that the new block is trustable, valid and consistency to be part of the chain. With the word consensus I mean, a complex mathematical cryptographic calculation that must be solved, otherwise the block is not valid and will not be appended.
By the way, the blockchain it is an append-only repository, nothing can be modified, only added.
For us, as software engineers, regarding this subject the most interesting to check out, is actually, what’s behind the scenes, that is, the technology that makes possible the existence of cryptocurrencies, the blockchain, I am referring to the software pattern called blockchain.
The blockchain is a pattern that allows constructing interconnected information (blocks) that are linked to each other using cryptography to ensure security and integrity. Any modification to any one of the blocks will turn all the chain invalid. It was made to be resistant to modification, getting the characteristic of being an append-only repository.
Check the image below, they are interconnected by their hashes, each block generates its identification (its hash) based on the identification of the previous one (previous hash), any modification on one of them impacts them all, invalidating and turns the chain untrustable.
In addition to that, the generation of the block’s hash might also take into consideration in the equation some other data (for instance, the total amount of the transactions in the block), this way the integrity would be impacted if any of the transactions is touched.
With this vision in mind… sounds like it is something suitable to build a chain of money transactions, isn’t it? So, let’s do it!
Here in this article, the aim is to analyze blockchain with a software perspective, and we will perform this implementing our own simplified version of a cryptocurrency.
CODING OUR CRYPTOCURRENCY
Let’s start with the Block, defining the data necessary that it should have to work a chain of blocks. The attributes below represents the block header information.
public abstract class AbstractBlock {
@Getter @Setter(AccessLevel.PUBLIC) private Integer height;
@Getter @Setter(AccessLevel.PROTECTED) private String hash;
@Getter @Setter(AccessLevel.PUBLIC) private String previousBlock;
@Getter @Setter(AccessLevel.PUBLIC) private String nextBlock;
@Getter @Setter(AccessLevel.PROTECTED) private Long timeStamp;
@Getter @Setter(AccessLevel.PROTECTED) private Integer nonce;
@Getter @Setter(AccessLevel.PROTECTED) private String merkleRoot;
...
}
We generalize all the information of a block in an Abstract Class, this way we can create later other types of blockchains for different scenarios, we’ll see (in a future article, hope so) that cryptocurrency is only one of them, and we will use this same abstraction to handle blocks for different solutions of Blockchain...
Read the whole article at... (the source code is at GitHub)
https://ualterazambuja.com/2018/05/15/building-a-cryptocurrency-with-blockchain/
PMO, PMO Consultant & PMO Trainer Implementing PMO, IA, Blockchain, Web3, NFT Advisor-Speaker-Author Top 4 (2022) & Top 8 (2021) PMO Global Influencer by PMOGA PMP PMI-PMOCP PMO-CC PMO-AU PMO-SR PMO-BR PMO-ST PMO-FO
6 年Ualter Otoni Azambuja Junior muy buen artículo porque no lo compartes en el grupo PMOfficers?