Ceramic anchor service - PoC
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" }
- Content:
-
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 }
- Code: 201
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 }
- Code: 200
-
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" }
- Code: 200
-
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 }
- Code: 200
-
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" } } }
- Code: 200
-
Error Response:
- Code: 404 NOT FOUND
Content:{ error : "Request doesn't exist" }
- Code: 404 NOT FOUND
IPFS explorer visualization
The image below represents requested CID IPLD document.
The image below represents anchor record IPLD document.
The image below represents anchor proof 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
Built With
License
This project is licensed under the MIT License - see the LICENSE file for details.
Team
Built with from 3Box team.