docker, komodo,

Pre alpha komodo utxo smart contracts notes

Follow Aug 22, 2018 · 5 mins read
Pre alpha komodo utxo smart contracts notes
Share this

This is not even a blog post about Komodo’s UTXO Smart Contracts based on the IETF’s Crypto Conditions standard (which is currently in draft).  It’s just some notes on the path to working with Komodo Smart Contracts when they are released around Q1 2019.  If you are a dev, there’s nothing to do but have a read.  Upcoming posts will give details on writing blockchain apps using komodo’s new utxo smart contracts system.

Why do it like this?

Front end devs really don’t want to build server side software from source, let alone learn about getting a blockchain up and running, even though it is only two commands on different servers.  They just want to use the libraries and see the results.  This is the start of that journey.  The end goal is to get new devs into Komodo and the new UTXO Smart Contracts in less than 10 minutes.

Why would a developer use Komodo?

Komodo lowers the barriers to blockchain and recycles bitcoin’s energy to secure independent chains.  There is also the ecosystem, app development, security, scalability, interoperability.  A white label wallet, white label dex, and soon a white label crowd funding app with no middle man for peer to peer social venture capital.

What does Pre-Alpha mean?

Lead dev of Komodo, jl777, is working on his github repo/branch which we are following.  Sometimes there are breaking changes whilst komodo utxo smart contracts are in heavy development.  To help with my own workflow, I’ve started straight away with docker so I can test the same stuff between a linux server and a mac laptop.

The docker file is also on github which when you build it for yourself, pulls the latest and compiles everything.  You end up with an image similar to the one on dockerhub depending on when you built it.

Build your own docker komodo utxo smart contracts image

This is what I’ve done for a first attempt at publishing to docker hub with a reasonable naming convention.  Whilst I was learning the workflow, I made non-sustainable naming 🙂

Some badly named docker images <figcaption class="wp-caption-text">Don’t put dates in image names. Also when building from different branches, too broader name doesn’t really describe enough at a glance.</figcaption></figure>

Get started in 10 seconds, open a terminal, go to your dev directory and:

git clone https://github.com/imylomylo/docker-komodo-smartcontracts

cd docker-komodo-smartcontracts

sudo docker build -t imylomylo/kmd-jl777-dev:20180822a .

Depending on the speed of your internet/machine, I’m building on an atom server in france, shouldn’t take long (maybe 5 mins).  Time to keep hydrated or stimulated – courses for horses, you’ve got some time to get up stretch.

Otherwise, onto the javascript RPC lib I’ve been making to simplify dev.

 

Komodo RPC from localhost

As a contributor to the Komodo project, I’ve had a chance to give my opinion when the time has been appropriate – and that is to make it easier to develop with this blockchain project.  The work of jl777 on this utxo smart contracts system really needs to be easy to use.  There is no easier way to get started than directly with the daemon’s RPC (remote procedure call).

All blockchains offer this, so this is kind of portable.  You make an app for one blockchain, a lot of the RPC calls will be similar.  Building on top of a the stdrpc lib, and going through all of Komodo’s RPC methods (there’s more than most other chains) to flesh out a skeleton.

Skeleton RPC library <figcaption class="wp-caption-text">Skeleton RPC library. Note faucet, rewards, assets and dice. These are the first 4 smart contracts and their corresponding RPC commands for interacting with them.</figcaption></figure>

The only calls that have been tested from both nodejs (the komodo-rpc-lib project is by default a nodejs app) and a vuejs app at the moment are getinfo and stop.  The others that don’t take any arguments, like help, listunspent, getnewaddress etc. probably work too.

[edit, clarify some points in following paragraph]

I want to take a look at the smart contracts written in C++.  The easiest is the faucet smart contract.  It is well commented and although I can read it and understand it – it’s been 15+ years since I’ve done any C++ work.  So the next best thing to provide is access to the already available “reference” smart contracts.  They are “reference” because for any new use case of a smart contract, the Komodo Platform envisions a dev to pick the contract-of-closest-fit and modify to their needs.

Pushing an image to docker for utxo smart contract testing

Being such a noob at docker, I still haven’t configured to use it without sudo on the linux server 🙂

Push a smart contracts image to docker hub <figcaption class="wp-caption-text">Note that I also call history because I’m not familiar with docker commands like a hardened devops engineer.</figcaption></figure>

But it’s there hosted on docker hub now!  So I can test on my laptop, and give a more detailed tutorial on getting up and running in < 10 mins being a blockchain app developer.  It takes too long just to document this part of it – but it needs to happen for … the journey!

Written by