blockchain-api

a Sails v1 application

How to Run

npm install
node app.js

# get block 0
curl http://localhost:8000/block/0

# create a new block
curl -H 'Content-Type: application/json' -d '{"data": 123}' -X POST http://localhost:8000/block

API Endpoints

  1. GET /block/:id Get info about block id. id should be integer between 0 to current block height. Upon success, it'll return something like
{
"hash":"49cce61ec3e6ae664514d5fa5722d86069cf981318fc303750ce66032d0acff3",
"height":0,
"body":"First block in the chain - Genesis block",
"time":"1530311457",
"previousBlockHash":""
}

Otherwise, it'll return error.

  1. POST /block Create block. The content type should be application/json and contains body field such as { body: "some data" }. Upon success, it'll return something like
{
  "hash": "ab8f447e71c079687943b47f42f8028640cbde86bfad008af177c91f1d971a1b",
  "height": 5,
  "body": "a",
  "time": "1541970141",
  "previousBlockHash": "8aad83bafe8dee69a7126eb409ab63225b1b76dffa1e3563f864fb5d6edf4ea7"
}

Otherwise, it'll return error.

Version info

This app was originally generated on Sat Nov 10 2018 13:21:17 GMT+1100 (Australian Eastern Daylight Time) using Sails v1.0.2.

This project's boilerplate is based on an expanded seed app provided by the Sails core team to make it easier for you to build on top of ready-made features like authentication, enrollment, email verification, and billing. For more information, drop us a line.