KMD Labs spent the last few months of 2018 testing cross chain migrations, a CryptoConditions smart contract example which acts to move coins from one asset chain to another within the same cluster. Testing has continued into 2019, with an upcoming bounty challenge competition to stress test the migration per second threshold. Subscribe to Komodo's weekly 5 Bullet Friday for updates!

Though bash and python scripts have been created to make participation simpler, blindly using the scripts won't teach you how it works! To follow on from my previous post about the Oracles CC, here's a step-by-step walkthough of the CLI commands used in Ubuntu 16.04/18.04 to burn coins from one asset chain and have them rise like a phoenix on a different chain in the same cluster (or like the faces of a ludicrous Nic Cage and John Travolta movie).

The commands and variables returned to be used in subsequent steps are color coded for new user convenience, both in the images below and the sample bash script available on github. A more advanced python script is also available, capable of more than 3 migrations a second from a single node!

Get a passport and pack your bags

You'll need to install the Staked and PoS scripts, and if you need help or want to say hi, drop by the Komodo Discord community, where you might get some coins to test with (alternatively, they can also be mined with a CPU).

Once you have coins tokens in your wallet, you're ready to start the journey. As migrations are only possible on the same asset chain cluster, this journey can be viewed as travelling from one of the member states within the European Union to another...

In this metaphor, local chain addresses are cities in the same country, and the member states of the EU are the asset chains in the cluster.

If using the script linked above, you'll see your balances before lift off.

Buy the ticket

The first step is to call createrawtransaction. It has two required parameters, though the first ("transactions") can be an empty array, e.g. [].
The second required parameter ("addresses") is a json object in the format {"address": value} where address is the target R-address on the destination chain. Value is the number of coins to be migrated.

the raw hex is your bus ticket code

The raw transaction hex (rawtx) is effectively a bus ticket from Madrid to Barcelona - but we want to go to Budapest. This is done using migrate_converttoexport, which effectively trades our bus ticket across Spain for a flight from Spain to Hungary. It takes two parameters - rawtx (generated above) and dest_symbol (the destination asset chain).

upgrading to a plane ticket boarding pass

This returns exportTX, which we'll use to board the plane, and payouts, which we'll use to claim our bags on arrival.

Preparing for take off

To pay for changing the ticket, use fundrawtransaction with the exportTX hex we just generated as it's single parameter.

paying for the upgrade

We have to sign the transaction too (signrawtransaction), using the hex returned from funding it.

signed, sealed and ready to deliver

Now we deliver it to the system via the  sendrawtransaction method, using the signed hex generated above as the parameter. Now we're ready to transcend the boundary between asset chains.

proof of departure: the sentTxId

Goods in transit

At this stage, we've cleared the runway in Spain, but air traffic control in Hungary is yet to clear us to land. It takes a while for the network to acknowledge funds are in transit. To check if the export has been detected by the destination chain, use getransaction with sentTxId as the parameter.

if confirmations > 0: we're beginning the descent into Hungary

Side note: The "hex" attribute value of the json object returned by gettransaction can be returned as a string using the getrawtransaction on the same SentTxId, which is a handy way to make it a variable -

pure hex in the pocket

If you're using the script linked above, it will sleep and loop thought the descent like Denzel Washington (though land a little more gracefully). If you're running through the steps manually, and descend too long, the migration will expire and you'll have to start again. Funds will be safu.

brace for impact

Once we have confirmations, we can start making the importTx. This is done on the same chain we are departing using migrate_createimporttransaction, with signed hex as the first parameter, and the payouts value we generated earlier with the migrate_converttoexport method.

getting papers ready for customs

Cleared for landing

The last step before landing is the migrate_completeimporttransaction method, using importTx as its parameter. As the chains are connected in the cluster via Komodo's delayed proof of work notarisation (dPoW), we run the method on Komodo. It returns the completeTx hex.

Time to return your seats to an upright position

Komodo notary nodes are the customs officers. Once they validate the import, your coins are burnt on the source chain, and rise from the ashes on the destination chain. First though we have to use the sendrawtransaction method with the completeTx hex as its parameter.

Touchdown. The eagle has landed.

To review the migration, you can call the getimports method using the block height it was completed in on the destination (import) chain as the parameter.

TripAdvisor rating 13/10, would fly again

It's just as simple to send your coins back to where they came from.

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