Interoperability with a Private Ethereum blockchain network using Interchain.

Dragonchain’s Director of Engineering Dean Shelton demonstrates proof of a living dragonchain. Continue reading here for a textual play-by-play. Or feel free to experience this for yourself by watching the demo. Above all else try it for yourself! Please bear in mind some functionality/UI experience is not yet public, and all is (as usual) subject to change and improvement. Also please understand that the codeblocks to follow are specific to Dean’s own node. They will not work on anyone else’s, but anyone may easily substitute their own values in order to follow along.

Dean shows us Dragonchain’s flexibility, ease-of-use, and interoperability. He watches for transaction data on an Interchained chain (private ethereum), performs his own business logic on the data by smart contract, and then publishes this data back out to the chain.

The task to demonstrate:

Pull a transaction’s data from a private ethereum network’s blockchain, do something (whether logical or illogical, it’s your programming) with it, and then publish this result back out to the same (arbitrary, can be any/all) network(s). “It’s actually pretty straight forward, let’s just jump in and do it. In from and out to some network, with our own business logic in-between, pure blockchain, and we can do it with docker.”

Through the console, or in Dean’s demo directly via terminal/command-line, Dean interacts with a Level 1 business chain for testing and demonstration, which he names: demoOrDie. We very seriously encourage any readers to consider that smart contracts may be written in any language, but for this demo specifically, code is written in Nodejs.

We begin by querying some transaction’s data on the private ethereum network. As a reminder, transactions (on ethereum networks) are described in hexadecimal format, meaning some theoretical transaction might be defined/accessible publicly via 0xA1B2C3D4E5000000...

In the ethereumPublisher.js file, Dean defines the logic he needs in this instance. He chooses to sum the numerical value of digits (including and between 1 and 9) from an array of integers within a private ethereum transaction, and then publish/broadcast the resulting transactional data (the sum of those numbers) back to the same network.

Dean builds a docker container with the smart contract logic previously described, and pushes it to his dockerhub repo; deanshelton913/booyah:latest . It now sits there ready for use by a dragonchain. How does a dragonchain use it? There exist SDKs in multiple languages including node, python, and go. For this demo Dean chooses to use the command-line SDK (dctl).

He creates a contract he arbitrarily names BusinessLogic by linking the container url, simply executing the command:

dctl contract create BusinessLogic docker.io/deanshelton913/booyah:latest

Next we tell it how to run:

node / app / dist / index.js;

(this is simply the start command for whichever container we use)

Executing this command (assuming success) creates the contract and returns the contract details (txn\_type, id, status, etc.).

Dean proves for us on Console that the new contract does in fact now exist with status active, and so may be interacted with.

Now we need to provide the point of input data for the contract to use, and we do so by using one of Dragonchain’s pre-built “Ethereum Watcher” containers. Dean names it (arbitrary), tells it how often it should run (in seconds, arbitrary), and tells it the address he’d like to watch. This all may be performed interactively on console but Dean demonstrates Dragonchain’s flexibility and ease-of-use by simply running the command:

dctl c c “Watcher” “Dragonchain/interchain-watcher:1.0.1-dev” node index.js -n 2 --serial -e ‘{ “ethereumNetwork”: ”custom”, ”customNetworkURL”: ”http://10.2.1.179:8545”, ”address”: ”0x9df7aead32989b4b533d941d3d799eb302e5a804”, ”confirmationOffset”: ”0”, ”contract”: ”BusinessLogic” }’

This watcher is now active and live, and its characteristics are returned for us. The last piece involves creating a “Publisher” contract container, in order to actually output/return data to the private ethereum network. Again, this can be done on console, but Dean simply uses the command:

dctl c c “Publisher” “dragonchain/ethereum-publisher:1.0.1-dev” node index.js --serial -e ‘{ “ethereumNetwork”: ”custom”, ”customNetworkURL”: ”http://10.2.1.179:8545” }’

Which again creates the contract and outputs its characteristics. We now own the functionality of three contracts linked to our L1 dragonchain node. We make sure all are active, and then tail them by first creating a pipe to our watcher contract:

kubectl logs -n openfaas-fn contract-37b7fab7-3bc3-4329-8381-3263be6b71cc-5d5d59cd6b-tjq2n --context uw2-k8s1-faas-stage.api.dragonchain.com -f

Now we can see the contract running in accordance to the frequency we defined. We grep FOUND:

contract-37b7fab7-3bc3-4329-8381-3263be6b71cc-5d5d59cd6b-tjq2n --context uw2-k8s1-faas-stage.api.dragonchain.com -f | grep FOUND -A 10

We leave this running and then tail the logs for the BusinessLogic contract:

kubectl logs -n openfaas-fn contract-2058dc30-e93e-4020-a7ff-57fcaac8af5a-6876cbf6c-pfxrn --content uw2-k8s1-faas-stage.api.dragonchain.com -f

There is of course no output yet, as expected since the contract has not yet triggered. Lastly we tail the publisher contract logs:

kubectl logs -n openfaas-fn contract-c1f260fb-46bf-422e-82a9-e1b90b3d66d8-859cdfb859-vxwnb --context uw2-k8s1-faas-stage.api.dragonchain.com -f

Now all we do is input traffic (a transaction) within the network:

python3.7 ~/Desktop/create-private-eth-txn.py

Dean creates a transaction with the address he owns (in geth) and an array [2, 3, 6], and within moments all three contract log tails respond, indicating each participated. In the tail of the Publisher logs, we are able to see the status Success, the resultant TransactionHash, and the time it took (about 1 second).

To further prove our success, Dean opens a block explorer for the private network and inputs the TransactionHash value. We see a string of seemingly random data indicating our transaction. He pastes this in a hexadecimal-->utf8 converter, converting the string to:

\[{“inputHASH”:”transaction-hash-here”, ”input”:\[2,3,6\],”output”:11}\]

Which is precisely as we expected. “Input, output, private, nothing about our logic is public, and back out it goes.”

By now the transaction has been recorded on dragonchain and will process through the remaining levels of consensus, ending with an artifact-hash ledgered on Interchain-ed structures such as Bitcoin, Ethereum, NEO, private databases, etc.

“A pure blockchain solution which Interchains private Ethereum… and you can really do this with anything” Dean concludes.

We thank and wish you all the happiest of codings.