Skip to content

Latest commit

 

History

History
87 lines (63 loc) · 2.78 KB

File metadata and controls

87 lines (63 loc) · 2.78 KB

`# Supply Chain Emissions Application

WARNING

'''The demo public/private keys in this directory should not be used for any real encryption, since they are all publicly known.'''

Installing

Following the steps from data/postgres to install the emissions factors database.

Copy .env.SAMPLE to .env. You will need to fill in:

Make sure you are using node version 16.

Install dependencies here with

npm install

Install IPFS. Then start the daemon in another window.

ipfs daemon

Trying it

First generate one or more key pairs for encrypting and decrypting files on IPFS.

npm run cli -- -generatekeypair user1 -generatekeypair user2

Run by giving a JSON file of activities to process and one or more public key for encryption with:

npm run cli -- -pubk user1-public.pem [-pubk user2-public.pem] -f input.json

To create emissions requests instead of issue token with given input.json run:

npm run cli -- -f input.json -queue

To randomly assign emission auditors for new emissions requests, first make sure that you have run setTestAccountRoles (see Net Emissions Contracts Docs.)

Then load the emissions auditors with seedHardhatDemoWallets.sql from Net Emissions Contract API Server

Finally run:

npm run cli -- -processrequests

To get a more complete output use the -verbose flag, this will output the grouped activities by type, while shipments are further grouped by shipping mode.

npm run cli -- -pubk user1-public.pem [-pubk user2-public.pem] -f input.json -verbose

In this case the IPFS content ID can be retrieved in the group "token.manifest" eg:

...
"token": {
    ...
    "manifest": "ipfs://<content_id>/content.json",
    ...
},
.....

Try fetching the encrypted content from IPFS by specifying the IPFS content ID and the private key of one of the associated public keys that were used above:

npm run cli -- -pk user1-private.pem -fetch <content_id>/content.json

REST API

A REST API is provided for integration from another application, such as legacy shipping or ERP system, in the /api/ directory.

Examples for using the REST API is in the /example directory.

To start the API server:

npm run api