By:  Omar Metwally, MD
University of California, San Francisco

In a recent post I demonstrated how I used DDASH to deploy a private Ethereum network and create an IPFS environment on an underlying Ethereum blockchain with a single command. Concretely, this functions as a shared drive (like Dropbox or Google Drive) where every change that happens to the data is registered as a transaction on an Ethereum blockchain. Hosting data using DDASH lets anyone issue private net Ether and lets network participants pen business logic in the form of Ethereum contracts deployed on a private network. In other words, issue your own Ether as tangible proof of the existence, authenticity, and integrity of an organization’s data and a record of how it’s used,

But while development on private networks has the tangible advantages of being faster and cheaper (and more secure) than main net deployment, one question that arises is,

what value does Ether on a private network have?

A private net blockchain cannot directly communicate with the main Ethereum network, and this is the reason why you can’t simply mine a billion dollars worth of Ether on a test net then transfer it to a real Ethereum account. USD, Euros, and many other fiat currencies can be exchanged for Ether, but this main net Ether is isolated from private net Ether, such that real Ether cannot be converted into private net Ether and vice versa.

To solve this problem and allow conversion between private net and main net Ether, I implemented the SWAP contract below, which has also been integrated in the Distributed Data Hyperledger Protocol (DDASH). The SWAP.sol contract is mined to both the private net blockchain and the main net blockchain. Let the addresses representing these mined contracts be 0xPNB and and 0xMNB, respectively. The SWAP contract defines the SwapTransactionObject:

SWAP.sol
contract Swap {

 struct SwapTransactionObj {        
        uint pvn_to_ether_amt;  // amount to send from private network to main net    
        uint eth_to_pvn_amt;    // amount to send from main net to private net
        address eth_addr;       // main net Ethereum address
        address pvn_addr;       // private net Ethereum address
        uint exchange_rate;     // exchange rate; e.g. (private net Ether) : (main net Ether)
        uint timestamp;         // timestamp from mined block
        bytes32 hash;           // hash generated from above attributes
        bool isTx; 
}    
...

and the swapTransactionList array is indexed by each SwapTransactionObject’s hash:

SWAP.sol
mapping (bytes32 => SwapTransactionObj) swapTransactions;    
bytes32[] public swapTransactionList;    
mapping (address => uint) eth_balance;  // main net Ether balance
mapping (address => uint) pvn_balance;  // private net Ether balance

The hash attribute is a unique hash generated from all attributes in the struct as inputs. Each blockchain sequentially writes to file a hash table mapping each SwapTransactionObject’s hash with the corresponding struct, and then each blockchain sequentially reads the other blockchain’s hash table to synchronize real Ethereum and private net Ethereum accounts on both blockchains.

The result is a marketplace where private net Ether and real Ether can be bought, sold, and exchanged.

Introducing a seamless way to transfer value across Ethereum networks. Get a head start deploying your own private network and codifying business logic as Ethereum smart contracts with DDASH, or send me a line for help with your organization’s implementation.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s