Skip to content

Educational implementation of a cryptocurrency using C++

License

Notifications You must be signed in to change notification settings

javierramoss/cppcoin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cppcoin

cppcoin is an educational implementation of a cryptocurrency using C++. It is not meant to provide a reliable system to transfer value nor generating cryptographic keys for real life use cases.

Features

  • Simple to use menu using the command line
  • Create ECC public and private keys
  • Transfer money to and from local cppcoin addresses
  • Transactions performed on the blockchain are saved in the host's machine

Installation

  1. Clone the repo:
git clone --recurse-submodules -j8 https://github.com/javierramoss/cppcoin.git
  1. cd into the cppcoin folder
  2. Remove line 11 from ./lib/hash-library/sha256.cpp
  3. Create a bin folder
  4. Compile using the command:
make

Usage

  1. Click on the executable cppcoin.exe or use the command:
cppcoin.exe

menu

  1. Select option 1 to generate a new pair of public and private keys

a1

  1. Use the keys to mine blocks or transfer cppcoins

Explanation

The blockchain starts off by mining the genesis block and adding it to the ledger saved to blockchain.txt. A block contains an id, nonce, previous block, time of creation, and transactions if any. Since it is the first block, no transfer transactions have been performed and the previous block is "0".

b1

Address A mines a block for the first time, the block is immediately pushed to the blockchain but the reward coins will be pushed in the next mined block's transactions,

a3

block2

Address A mines another block, making the first 100 cppcoin reward for the first mined block available in their balance.

block3

Address A transfers 50 cppcoins to Address B, then Address A mines another block so the transaction is pushed with this block. Now the 50 cppcoins transaction is contained in this block along with the 100 cppcoin reward from the second block mined.

a2

b3

Now Address A's balance is 150 cppcoins and Address B's is 50 cppcoins.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b NewBranch)
  3. Commit your Changes (git commit -m 'Add x')
  4. Push to the Branch (git push origin NewBranch)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

About

Educational implementation of a cryptocurrency using C++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published