Giter Club home page Giter Club logo

simple's Introduction

Blockchain Project 4

Prerequisites

  • level
  • crypto-js
  • express,
  • debug,
  • bitcoinjs-lib
  • bitcoinjs-message
  • body-parser.

There is also a web front-end that relies on jquery and bootstrap but pulls them in via CDN. Alternatively, one can simply test the web methods directly with curl or postman.

Installation

npm install

Endpoints

requestValidation

The requestValidation endpoint is used to start a request with the server. This generates a challenge message that the caller must follow up with a signature. This endpoint also begins a 5 minute timer and the full registration workflow must complete within that time. Only one request can be active at a time for a given address.

validate

The validate endpoint is used to prove the caller controls the address given earlier. The proof is offered by signing the message sent back from the previous call.

block (POST)

Finally, the caller is able to do a POST to the block endpoint to add an entry on the chain. This call expects a JSON object with the callers address, ra and dec for the star and optionally a story field describing the source of the coordinate information.

Example payload:

{
    "address":"1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN",
    "star": {
        "ra":" 05 55 10.30536  ",
        "dec":"+07 24 25.4304 ",
        "story":"This is the part when you say I don't wanna."
    }
}

stars/hash:[HASH]

A GET call to this endpoint extracts the requested hash value and finds the matching block.

stars/address:[ADDRESS]

A GET call to this endpoint parses the address and returns all blocks that were registered to it.

block/[HEIGHT]

A GET call to this endpoint returns the block at that blockheight index in the chain.

Testing

To test code:

  1. Open a command prompt or shell terminal
  2. Remove the chaindata folder, if present (optional)
  3. Run node index.js (or npm test will do the same thing)
  4. Browse to http://localhost:8000 to see the debug console for the service.

simple's People

Contributors

meeshbhoombah avatar

Watchers

James Cloos avatar  avatar Liwawil 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.