paoloo / blockchain

A clojure implementation of a blockchain based on "Learn Blockchains by Building One"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

blockchain

Travis CI

A clojure implementation of a blockchain based on Learn Blockchains by Building One

Prerequisites

You will need Leiningen 2.0.0 or above installed.

Running

To get the dependencies, run:

lein deps

To start a server for the application, run:

lein ring server

Usage

  • Requesting the whole Blockchain:
$ curl -X GET 127.0.0.1:8090/chain
  • Mining coins:
$ curl -X GET 127.0.0.1:8090/mine
  • Make a new transaction:
$ curl -X POST -H "Content-Type: application/json" -d '{
    "sender": "d4ee26eee15148ee92c6cd394edd974e",
    "recipient": "someone-other-address",
    "amount": 5
}' "http://127.0.0.1:8090/transactions/new"
  • Register a new node:
$ curl -X POST -H "Content-Type: application/json" -d '{
    "node": "http://127.0.0.1:8091"
}' "http://127.0.0.1:8090/nodes/register"
  • Resolving Blockchain differences in each node:
$ curl -X GET 127.0.0.1:8090/nodes/resolve

Tests

lain test

Docker

  • Create a self contained version of application with: lein ring uberjar;
  • Run docker build -t paoloo/blockchain . to create image;
  • And finally, run docker run -p 8090:8090 paoloo/blockchain to instantiate it.

License

MIT

Copyright (c) 2017 Paolo Oliveira

About

A clojure implementation of a blockchain based on "Learn Blockchains by Building One"

License:MIT License


Languages

Language:Clojure 97.4%Language:Dockerfile 2.6%