In 2018, Komodo Platform added cryptoconditions to thier codebase, and lots of testing has taken place leading to  a new suite of dApps. I've been busy working on the Dragonhound dApp (for asset tracking) in the KMD Labs, a community Skunkworks project.

Dragonhound offers a cartographic interface using LeafletJS to display the GPS location data history of a Asset Tracker, which is stored in a tactical pouch attached to a OneTigris K-9 Harness, and worn by a wandering hound with a lust for freedom who I've bailed out of lock up more than once.
Sgt Skrunch in basic training

Tying all this together is a Komodo assetchain (currently in testnet) which uses an Oracle Crypto-conditions smart contract to store GPS data emitted from the device, and retrieve it for display with python RPC functions via the Django framework.

As this is new tech, simple to understand documentation is in short supply. Below I'll walk through the steps for creating an oracle from Ubuntu 18.04 command line, and then storing and receiving data on it.

Creating an Oracle

After installing the KMD Labs (Staked) repository, and saying "Hello world" to the Komodo Discord community, start with this CLI command -

substitute CFEKX for the name of your asset chain

oraclescreate takes 3 parameters - name, description and format. The example above uses "S", which will allow us to store a string up to 65536 characters long.
It returns a hex, which is broadcast to the network using sendrawtransaction

Behold the oracle transaction id (oracletxid)

The Oracle Transaction ID
To confirm your oracle has been created, use oraclesinfo to view its details, using the oracletxid as a parameter.

unregistered oracle

To register as a publisher on the oracle, use oraclesregister. It's parameters are the oracletxid and a data fee, which is expressed in satoshis and should be more than the network transaction fee.

More raw hex

Make sure to broadcast the raw hex to the network using sendrawtransaction. Once the transaction has been processed (you can check this with getrawmempool), if you run oraclesinfo again, you'll see your registration details.

Funds are emptu!

To use the oracle, it needs to be funded. This is done using oraclesubscribe, with the parameters oracletxid, publisher and amount.

more hex for sacrifice to the oracle

After you've done sendrawtransaction with the hex above, and the network has validated it from the mempool, the subscriber funds can be viewed using oraclesinfo.

Funds are safu!

Preparing Data
Sending data is a little more tricky. Our string needs to be converted to hex, and include a portion to indicate it's length. So to begin, we need to get the byte length (in hex) of the data we want to write to the oracle.

Borrowing tops £10bn in race to attract students

The oracle data being sent is prefixed with a four char hex string indicating the length of the data being sent. Depending on the byte length, padding may be required to fill this prefix. The added padding is as follows :

python > bash

So in the example pictured, bigend would be 0045. Now we have to convert the prefix from big endian to little endian :

I knew this cat named Darrell

Now we combine the prefix 4500 to the hex string of the data you want to write to the oracle.

almost there...

Now we have our string data in a format the oracle will accept!

Sending Data
Data is sent to the oracle using oraclesdata, which takes oracletxid and the hexstring which we created in the last step. This returns a raw transaction hex which we broadcast using sendrawtransaction.

put that hex in your pipe and broadcast it

Once the raw transaction has been validated by the network, we'll be able to query the oracle to retrieve it.

Receiving Data
Data stored on the oracle is using oraclesamples. Its parameters are the oracletxid, its batontxid, and num. The batontxid is a reference point for what our starting point is for the records we want returned, and num is how many records back from the reference batontxid. You can get the latest batontxid using oraclesinfo

just the tip...

This batontxid is the tip of all the data stored in the oracle. If the num parameter is 1, it will return the most recent data sent to the oracle.

where will we be on Jan 3rd 2029?

What next?

As the data I'm working with is sensitive location intel, the GPS data is encrypted before being stored - this is optional, most oracles would be data intended to be publicly accessible to subscribers.
Shouldn't have used Google Maps...

This is more easily done in python, and will be explained in a future post. If you're interested now, an example is available on the Dragonhound github repository.

Note: The repo linked above uses CherryPy and has been abandoned in favour of using Django.

Got questions? Drop into the Komodo Discord and ask away!