This API uses the hapi.js framework.
Blockchain API which handles POSTing of:
- Request for validation of Bitcoin Wallet address
- Validation of Bitcoin Wallet address via signature
- Creation of a block holding star data which the user wants to notarize
and GETting of:
- Block by height
- Block by hash
- Block(s) by Bitcoin Wallet address
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Clone the repository to somewhere you want to work on it.
git clone <git url>
Navigate to the directory inside terminal and then:
npm install
Then just run:
node app.js
to start the server.
Use Postman or Curl at http://localhost:8000
Use the following to interact with the API
Use this to POST your Bitcoin Wallet address to receive a message to sign within a 5 minute validation window.
http://localhost:8000/requestValidation
body:
{
"address": "YOURADDRESS"
}
Returns:
{
"walletAddress":"YOURADDRESS",
"requestTimeStamp":"1552415940",
"message":"YOURADDRESS:1552415940:starRegistry",
"validationWindow":300
}
Then do this:
Use this to POST your Bitcoin Wallet address Signature to receive a validated request, and a 5 minute window wherein you can POST a star.
http://localhost:8000/message-signature/validate
body:
{
"address": "YOURADDRESS",
"signature": "YOURSIGNATURE"
}
Returns:
{
"registerStar": true,
"status": {
"address": "YOURADDRESS",
"requestTimeStamp": "1552415940",
"message": "YOURADDRESS:1552415940:starRegistry",
"validationWindow": 300,
"messageSignature": true
}
}
Then do this:
Use this to POST your Star Data into a block to forever notarize it into an indelible and impermeable blockchain of infinite power.
Note X, Y and Z are just placeholders for numbers, not actual XYZ coordinates.
http://localhost:8000/block
body:
{
"address": "YOURADDRESS",
"star": {
"dec": "X° Y' Z",
"ra": "Xh Ym Zs",
"story": "WHEREYOUFOUNDTHESTAR"
}
}
Returns:
{
"hash": "BLOCKHASH",
"height": CURRENTHEIGHT,
"body": {
"address": "YOURADDRESS",
"star": {
"ra": "Xh Ym Zs",
"dec": "X° Y' Z",
"story": "YOURHEXSTORY"
}
},
"time": "1552415956",
"previousHash": "PREVIOUSHASH"
}
Then you can explore with the GET routes:
Use this to GET the block at given height.
http://localhost:8000/block/{index}
set index = the desired height:
index = int
Example:
http://localhost:8000/block/1
{
"hash": "BLOCKHASH",
"height": BLOCKHEIGHT,
"body": {
"address": "YOURADDRESS",
"star": {
"ra": "Xh Ym Zs",
"dec": "X° Y' Z",
"story": "YOURHEXSTORY",
"storyDecoded": "YOUR ASCII STORY"
}
},
"time": "1552415956",
"previousHash": "PREVIOUSHASH"
}
Use this to GET the block at given height.
http://localhost:8000/stars/hash:{hash}
set hash = the block hash:
hash = hash
Example:
http://localhost:8000/stars/hash:BLOCKHASH
{
"hash": "BLOCKHASH",
"height": BLOCKHEIGHT,
"body": {
"address": "YOURADDRESS",
"star": {
"ra": "Xh Ym Zs",
"dec": "X° Y' Z",
"story": "YOURHEXSTORY",
"storyDecoded": "YOUR ASCII STORY"
}
},
"time": "1552415956",
"previousHash": "PREVIOUSHASH"
}
Use this to GET the block at given height.
http://localhost:8000/stars/address:{address}
set address = Bitcoin Wallet Address:
address = address
Example:
http://localhost:8000/stars/address:BITCOINWALLETADDRESS
Returns array of blocks if multiple blocks submitted by same address.
[
{
"hash": "BLOCKHASH",
"height": 1,
"body": {
"address": "WALLETADDRESS",
"star": {
"ra": "Xh Ym Zs",
"dec": "X° Y' Z",
"story": "YOURHEXSTORY",
"storyDecoded": "YOUR ASCII STORY"
}
},
"time": "1552415887",
"previousHash": "PREVIOUSHASH"
},
{
"hash": "BLOCKHASH",
"height": 2,
"body": {
"address": "WALLETADDRESS",
"star": {
"ra": "Xh Ym Zs",
"dec": "X° Y' Z",
"story": "YOURHEXSTORY",
"storyDecoded": "YOUR ASCII STORY"
}
},
"time": "1552415956",
"previousHash": "PREVIOUSHASH"
}
]
Deploy it by rewriting and establishing the server connection to a real server lol.
- Udacity (lol)
- Code Editor (any one will do)
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning? psh.
- **Christian Le Doux - Best guy.
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to Udacity
- Inspiration to Udacity
- etc to Udacity