Angel \”Java\” Lopez on Blog

April 11, 2016

Building A Blockchain (4)

Filed under: Bitcoin, Blockchain, C Sharp, Ethereum, Open Source Projects — ajlopez @ 10:20 am

Previous Post
Next Post

In this post, I want to describe the key parts of a blockchain example I’m writing at:

https://github.com/ajlopez/BlockchainSharp

using C# and TDD (Test-Driven Development). The essential things to be implemented are:

– Blocks
– Transactions

the concepts of:

– Account
– Account State
– Smart Contracts (executed in a virtual machine)

and utilities for:

– Encode/Decode entities to be transmited/received via the network of nodes
– Hash calculations
– Immutable tries
– Sign transactions
– Verify transaction sign
– Verify block integrity
– Verify transactions are valid
– Proof of Work calculation (as usual in Bitcoin and Ethereum implementations)
– Store some entities: complete blocks, partial blocks (block headers in Ethereum), account state, … in general, tries with storage

Some days ago, I started to write a Transaction class, having pairs of accounts and values. I adopted Ethereum approach: instead of having inputs/outputs as in Bitcoin, I have accounts with balances/states. Each account is identified by an address (actually a random hexadecimal string):

Each transaction can have one or more inputs and outputs. Each input/output has an account address and a value. The values are instances of BigInteger, so I can manage large integer numbers. It’s the way the criptocurrencies implementations allow the use of value fractions: the unity is a power of 10, and the amounts are expressed in integer quantity of minimal fractions.

Next steps: add transactions to blocks, apply transaction to account states, validate that input values are available, store states in an immutable trie,…

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

2 Comments »

  1. […] Previous Post Next Post […]

    Pingback by Building A Blockchain (3) | Angel "Java" Lopez on Blog — April 11, 2016 @ 10:23 am

  2. […] Previous Post […]

    Pingback by Building A Blockchain (5) | Angel "Java" Lopez on Blog — April 17, 2016 @ 10:02 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: