Giter Site home page Giter Site logo

blockchain-example's Introduction

Blockchain example

This is a Rust implementation of a simple blockchain example based on Daniel van Flymen's blog post Learn Blockchains by Building One.

The example was written purely out of curiosity and for educational purposes. We advice not to run this in a production setup.

Prerequisite

  • rust (tested with 1.36.0)

Running

Start the server locally on port 5000:

cargo run

More nodes can be started on separate ports with:

cargo run -- --p 5001

Usage

If you have jq installed on your machine, the output can be turned into a more human-readable format by appending | jq '.' at the end of the commands.

Mine a new block:

curl http://localhost:5000/mine

Creating a new transaction:

curl -H "Content-Type: application/json" --request POST --data '{"sender":"e79fcabd1d70433191701d17c4d13112", "recipient":"some-other-address", "amount":5}' http://localhost:5000/transactions/new

View the full chain:

curl http://localhost:5000/chain

Add a new node:

curl -H "Content-Type: application/json" --request POST --data '{"nodes":["http://localhost:5001"]}' http://localhost:5000/nodes/register

Reaching consensus with other registered nodes in the network:

curl http://localhost:5000/nodes/resolve

TODO

  • add tests
  • change nodes/resolve endpoint from .to -> .to_async
  • enable CI

Contribution

Contributions are welcome, feel free to submit a pull request.

blockchain-example's People

Contributors

koura avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.