Oracle Service
Commands
Usage
Environmental Variables
Make sure all the environment variables are provided and correct
zen_path
: path of the oracle committerzen_wallet_password
: password of the f# walletzen_node_uri
: uri of the nodeoracle_api
:uri:port
api port for oracle requestsmongo_connection
: MongoDB (optional. defaults to "mongodb://127.0.0.1:27017")
Commit
To commit use the command:
or the shorthand
This command has a parameter <file>
and the following flags:
--timestamp
,-t
<timestamp>
Time of the committed data (in milliseconds since the Unix epoch - 00:00:00 UTC on 1 January 1970).
--notx
,-x
Don't create a commitment transaction, just return the message body.
--stdin
,-i
When this flag is used - get JSON string from standard input (can't be used along with
-f
).
For the <file>
parameter use the name of a JSON data file you want to commit.
The JSON file should be a record with names and values, like this:
Attest
To attest use the command:
or the shorthand
This command has the following flags:
--root
,-r
<root>
Root of the committed Merkle tree.
--timestamp
,-t
<timestamp>
Time of the committed data (in milliseconds since the Unix epoch - 00:00:00 UTC on 1 January 1970).--commit
,-c
<commit>
Commit ID of the committed data.
--publickey
,-p
<pk>
Public key of the recipient address.
--contract
,-d
<cid>
Contract ID of the recipient contract.
--notx
,-x
Don't create an attestation transaction, just return the message body.
--address,
Address of the recipient (either a contract address or a public key hash address)
You have to use either --commit
or both --root
and --timestamp
.
You can only have at most 1 recipient (either publickey
or contract
).
If you don't provide a recipient the attestation token will be sent to the sender.
Query
To query use the command:
or the shorthand
There are 2 things you can query for - the oracle public key or information about committed data.
Oracle Public Key
To get the public key of the oracle run:
Committed Data
To get information about committed data run:
This command has the following flags:
--low
,-l
<low>
Lower time bound.
--high
,-h
<high>
Upper time bound.
--key
,-k
<key>
Key to search the value for.
--skip
,-s
<n>
Skip the first <n> items.
--take
,-t
<n>
Take only the first items (after the skip if there is one).
--count
,-c
Return the total amount of items satisfying the query.
It will provide you information about all the values committed by the server for the given keys within the given time bounds.
If no key is provided it will provide information about all the values within the time bounds regardless of keys.
If no time bounds are provided it will provide information about all the values committed by the server for the given keys, regardless of time bounds.
Audit Path
To get an audit path in the Merkle tree of a committed data set use the command:
or the shorthand
This command has a parameter <item>
and the following flags:
--commit
,-c
<commit>
Commit hash.
--root
,-r
<root>
Root hash.
--stdin
,-i
When this flag is used - get item's JSON string from standard input.
For the parameter use the name of a JSON file which contains items for which you want to get audit paths in the given commit.
The JSON file should be a record with names and values, like this:
Server
To run the server use the command:
or the shorthand
The server will run on a port specified with the zen_api
environment variable.
Database Structure
The server
command supports the following flags:
Collections
--bind
,-b
<address>
API port
--chain
,-c
<chain>
Node chain
--origin
,-o
<origin>
CORS origin
--maxtake
,-l
<n>
Maximum size of take (default:
1000
)--maxbodysize
,-s
<n>
Maximum size of body for the
getValues
endpoint (default:1000
)
The oracle service uses the following MongoDB collections, within the oracle
database:
Commits
Commits
The commits the server have made, sorted by commitId
.
fields:
commitId
- commit ID of the committimestamp
- (in milliseconds since the Unix epoch - 00:00:00 UTC on 1 January 1970)root
- hash of the root of the committed Merkle treeitems
- list of committed items
Items
Items
The committed items, sorted by name
.
fields:
name
- name of the itemroot
- hash of the root of the Merkle tree this item was committed incommitId
- commit ID of the committimestamp
- (in milliseconds since the Unix epoch - 00:00:00 UTC on 1 January 1970)item
- serialization of itemproof
- proof of inclusion of the item in the committed Merkle tree, which contains:index
- index of the item in the Merkle treepath
- audit path of the item in the Merkle tree
TimeCommits
TimeCommits
The commits (given by root and commit ID) sorted by timestamp
.
This collection purpose is to make fast querying by timestamp.
fields:
timestamp
- (in milliseconds since the Unix epoch - 00:00:00 UTC on 1 January 1970)root
- hash of the root of the committed Merkle treecommitId
- commit ID of the commit
PublicKey
PublicKey
The public key of the oracle in the blockchain.
fields:
pk
- the public key of the oracle in the blockchain
For the api follow the link here.
Oracle's APILast updated