Code Monkey home page Code Monkey logo

sharpchain's Introduction

SharpChain

SharpChain is a simple blockchain implementation for educational purposes, written in C#. It is a simpler, smaller model of the Bitcoin blockchain. I believe it makes it easier to see how the blockchain actually works nicely.

Prerequisites

.NET Core 2.0 SDK

Build Instructions

If you have Visual Studio, just open the .sln file and build as usual. Alternatively, you can do:

dotnet build

in the folder where the .sln file is.

API Reference

Query Description
SharpChain/Register Gets the user an ID to use with their requests.
SharpChain/Mine/{ID} Mines a block using the Hashcash algorithm. The default difficuly is 4, and the reward is 1 SharpCoin.
SharpChain/GetBalance/{ID} Gets the balance of {ID}.
SharpChain/SendCoin/{senderID}/{recipientID}/{amount} Send {amount} of SharpCoins to {recipientID}. The {senderID} should be your ID.
SharpChain/GetChain Gets the whole blockchain as JSON.

How to Use

First you need to get and ID, like so:

localhost:9532/SharpChain/Register

This will return an ID, like 723e83c4-8f43-4e96-a1e2-af895d041a46. After that, SharpChain works exactly like the Bitcoin blockchain. You need to mine blocks with:

localhost:9532/SharpChain/Mine/723e83c4-8f43-4e96-a1e2-af895d041a46

Blocks are needed to store transactions & send coins to someone. You can send coins with:

localhost:9532/SharpChain/SendCoin/723e83c4-8f43-4e96-a1e2-af895d041a46/f6b88148-b0e9-439c-b246-21e7a55e0c11/5

This will send 5 SharpCoins to f6b88148-b0e9-439c-b246-21e7a55e0c11, from 723e83c4-8f43-4e96-a1e2-af895d041a46. The transaction will be added to the next mined block.

You can see your balance anytime with:

localhost:9532/SharpChain/GetBalance/723e83c4-8f43-4e96-a1e2-af895d041a46

If anytime, you want to see the whole chain, you can do:

localhost:9532/SharpChain/GetChain

What Is Missing?

  • Consensus
  • Persistance
  • UI

sharpchain's People

Contributors

umutseven92 avatar

Stargazers

rhff1024 avatar  avatar Funthing avatar Tugcan Olgun avatar GuruPoo avatar

Watchers

James Cloos avatar GuruPoo avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.