ENVS:
PORT = port to bind to
AQUARIUS_URI = aquarius_uri to update metadata
PRIVATE_KEY = private key or seed to generate one account (will be auth by aquarius to update ddo)
NODE_URI = Node RPC Uri
Swagger available at localhost:8000/docs/
Add a rating or replace existing one
Params:
| Name | Example |
|---|---|
| did | "did:op:1234" |
| vote | 1 |
| comment | "mycomment" |
| address | "0x5CD7477d14F964F39949169E75C269965A953Bfc" |
| timestamp | 1583746239 |
| signature | "0x3dfefgafd43545" |
Returns:
200 - Vote added
400 - Missing parameters or errors in parameters
401 - Invalid signature
500 - Server error
Get rating for a did and address
Params:
| Name | Example |
|---|---|
| did | "did:op:1234" |
| address | "0x5CD7477d14F964F39949169E75C269965A953Bfc" |
Returns: Object :
{
vote,
comment,
datepublished
}
Deletes a vote for a DID from an address
Params:
| Name | Example |
|---|---|
| did | "did:op:1234" |
| address | "0x5CD7477d14F964F39949169E75C269965A953Bfc" |
| timestamp | 1583746239 |
| signature | "0x3dfefgafd43545" |
Returns:
200 - Vote added
400 - Missing parameters or errors in parameters
401 - Invalid signature
500 - Server error
Get all rating for a DID Params:
| Name | Example |
|---|---|
| did | "did:op:1234" |
Returns: Array of Objects
{
address,
vote,
comment,
datepublished
}
Every endpoint that needs to be authorized needs an timestamp and a signature.
Signature is composed using that timestamp as a message in function web3.eth.personal.sign
Use this sample to sign in js:
function gethash(message) {
var hex = ''
for(var i=0;i<message.length;i++) {
hex += ''+message.charCodeAt(i).toString(16)
}
var hexMessage = "0x" + hex
return hexMessage
}
var timestamp=Math.floor(new Date() / 1000)
var message=String(timestamp)
console.log("Message:"+message)
var accounts=await web3.eth.getAccounts()
var signature=await web3.eth.personal.sign(gethash(text), accounts[0], null)
console.log("Signature:"+signature)
To start local development:
npm install
npm run serve
This will launch the app under localhost:8000.
Content type
Image
Digest
Size
371.2 MB
Last updated
over 6 years ago
docker pull oceanprotocol/rating_backend