Giter Site home page Giter Site logo

fossabot / ceramic-anchor-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ceramicnetwork/ceramic-anchor-service

0.0 0.0 0.0 6.2 MB

Ceramic anchor service used for anchoring signed records in Ceramic protocol.

License: MIT License

TypeScript 97.45% JavaScript 1.47% Dockerfile 0.39% Shell 0.69%

ceramic-anchor-service's Introduction

Ceramic anchor service - PoC

FOSSA Status

Ceramic anchor service is a PoC of anchor service according to the Ceramic specification.

This implementation uses Ethereum blockchain but is built in order to be blockchain agnostic. It is fairly easy to add more modules to support other blockchains as well.

Prerequisites

In order to run the simulation you need to install Node.js.

Installing

Configuration file is located under ./config directory.

In order to build the application start the IPFS node locally and run the following commands:

docker-compose up -d

npm run build

npm run start

RESTful APIs

RESTful APIs are enabled on http://localhost:3000/api/v0/ by default.


Create Anchor Request

Creates CID anchor request.

  • URL

    /requests

  • Method:

    POST

  • Data Params

    • Content:
        {
        	"cid": "bafyreihgmyh2srmmyiw7fdihrc2lw2uodvpxb2hbpyxo7w2jlqizga6pne",
        	"docId": "doc_875c56f9-9d5d-4031-8d3d-d171a91b15aa" 
        }
  • Success Response:

    • Code: 201
      Content:
      {
          "id": "06a483c9-eb73-4e08-a019-7b5665588172",
          "status": "PENDING",
          "message": "Request is pending.",
          "cid": "bafyreihgmyh2srmmyiw7fdihrc2lw2uodvpxb2hbpyxo7w2jlqizga6pne",
          "docId": "doc_875c56f9-9d5d-4031-8d3d-d171a91b15aa",
          "createdAt": 1586438625,
          "updatedAt": 1586438625,
          "scheduledAt": 1586438625
      }

Get CID anchor request information

Creates CID anchor request.

  • URL

    /requests/:cid

  • Method:

    GET

  • URL Params

    Required:

    cid=[string]

  • Data Params

    None

  • Success Response - PENDING:

    • Code: 200
      Content:
      {
          "id": "06a483c9-eb73-4e08-a019-7b5665588172",
          "status": "PENDING",
          "message": "Request is pending.",
          "cid": "bafyreihgmyh2srmmyiw7fdihrc2lw2uodvpxb2hbpyxo7w2jlqizga6pne",
          "docId": "doc_875c56f9-9d5d-4031-8d3d-d171a91b15aa",
          "createdAt": 1586438625,
          "updatedAt": 1586438625,
          "scheduledAt": 1586438625
      }
  • Success Response - PROCESSING:

    • Code: 200
      Content:
      {
          "id": "06a483c9-eb73-4e08-a019-7b5665588172",
          "status": "PROCESSING",
          "message": "Request is processing.",
          "cid": "bafyreihgmyh2srmmyiw7fdihrc2lw2uodvpxb2hbpyxo7w2jlqizga6pne",
          "docId": "doc_875c56f9-9d5d-4031-8d3d-d171a91b15aa",
          "createdAt": "2020-04-08T12:10:06.000Z",
          "updatedAt": "2020-04-08T12:10:07.000Z"
      }
  • Success Response - FAILED:

    • Code: 200
      Content:
      {
          "id": "06a483c9-eb73-4e08-a019-7b5665588172",
          "status": "FAILED",
          "message": "Request failed. Staled request.",
          "cid": "bafyreihgmyh2srmmyiw7fdihrc2lw2uodvpxb2hbpyxo7w2jlqizga6pne",
          "docId": "doc_875c56f9-9d5d-4031-8d3d-d171a91b15aa",
          "createdAt": 1586438625,
          "updatedAt": 1586438625
      }
  • Success Response - COMPLETED:

    • Code: 200
      Content:
      {
          "id": "06a483c9-eb73-4e08-a019-7b5665588172",
          "status": "COMPLETED",
          "message": "CID successfully anchored.",
          "cid": "bafyreihgmyh2srmmyiw7fdihrc2lw2uodvpxb2hbpyxo7w2jlqizga6pne",
          "docId": "doc_875c56f9-9d5d-4031-8d3d-d171a91b15aa",
          "createdAt": 1586438625,
          "updatedAt": 1586438625,
          "anchorRecord": {
              "cid": "bafyreicq6rwooyi2dk24p52nutgysi4gpu2lvoeilooekqypk4h4f32wpy",
              "content": {
                  "path": "L/L",
                  "prev": "bafyreihgmyh2srmmyiw7fdihrc2lw2uodvpxb2hbpyxo7w2jlqizga6pne",
                  "proof": "bafyreid3fjhoybtbgzdt2afdrxzikprbmgvufn3z7oavodd37k2tnof5ry"
              }
          }
      }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: { error : "Request doesn't exist" }

IPFS explorer visualization

The image below represents requested CID IPLD document.

CID IPLD document

The image below represents anchor record IPLD document.

Anchor IPLD document

The image below represents anchor proof IPLD document.

Anchor IPLD document

Running the tests

Tests are located in the test directory. In order to run test start the following command:

npm run test

In order to run tests with coverage run:

npm run coverage

Maintainers

@simonovic86

Built With

License

This project is licensed under the MIT License - see the LICENSE file for details.

FOSSA Status

Team

Built with from 3Box team.

ceramic-anchor-service's People

Contributors

fossabot avatar oed avatar simonovic86 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.