Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hbarcelos/udacity-private-blockchain

Implentation of Udacity's Blockchain Developer Nanodegree Private Blockchain project
https://github.com/hbarcelos/udacity-private-blockchain

blockchain blockchain-demos javascript

Last synced: 4 days ago
JSON representation

Implentation of Udacity's Blockchain Developer Nanodegree Private Blockchain project

Awesome Lists containing this project

README

        

# Private Blockchain

This is my implentation of Udacity’s Blockchain Developer Nanodegree Private Blockchain project.

## Prerequisites

- `node`: >=8.9.4 <12.0.0.

## Install dependencies

```
npm install
```

## Testing

This project as a full test suite implementing all validation described in the probject’ rubric. To run it:

```
npm test
```

## Running

Set the desired values for the environment variables in the `.env` file, for example:

```bash
PORT=8000
BLOCKCHAIN_DATA_STORAGE_DIRECTORY=./chaindata
VALIDATION_REQUEST_WINDOW=300
VALIDATION_EXPIRATION=1800
```

Now you can start the server:

```bash
npm start
```

## Endpoints



Path
Response Code
Response Body




GET /block/{height}
200: when block exists for height


{
height: Number,
time: UnixTimestamp,
body: Any,
hash: String,
previousBlockHash: String,
}




404: when block does not exist for height


{
error: {
message: String,
code: String,
cause?: {
message: String,
}
}
}




POST /block
200: when body .body is valid


{
height: Number,
time: UnixTimestamp,
body: Any,
hash: String,
previousBlockHash: String,
}




422: when body .body is invalid


{
error: {
message: String,
code: String,
cause?: {
message: String,
}
}
}




POST /requestValidation
200


{
walletAddress: String,
requestTimeStamp: UnixTimestamp,
"message": String,
"validationWindow": Number,
}




POST /message-signature/validate
200: when signature is valid for the address


{
"registerStar": true,
"status": {
"address": String,
"requestTimeStamp": UnixTimestamp,
"message": String,
"validationWindow": Number,
"messageSignature": true
}
}




404: when there is no pending validation for the address


{
error: {
message: String,
code: String,
cause?: {
message: String,
}
}
}




403: when the signature is invalid


{
error: {
message: String,
code: String,
cause?: {
message: String,
}
}
}




GET /stars/hash:{hash}
200


{
height: Number,
time: UnixTimestamp,
body: Any,
hash: String,
previousBlockHash: String,
}




GET /stars/address:{address}
200


[
{
height: Number,
time: UnixTimestamp,
body: Any,
hash: String,
previousBlockHash: String,
}?
...
]



## Remarks

- This project uses Express.js