In our previous post about sending Dai between chains we did not mention smart-contracts. We showed how to send Dai from an account on Kovan to the same account on Tobalaba. This does not work if your tokens sit in a multi-sig smart-contract or are held by a uPort identity.
REGISTERING ADDRESS PAIRS
In order to transfer a token from an address on Kovan to a different address on Tobalaba, the origin and destination addresses need to be paired. The challenge is to make such pairs safe for production use.
To avoid complex signing, registration and authentication mechanisms, we opted to require that both the origin and destination addresses be smart-contracts and both have to be created by the same account.
We are aware that this rules out wallets created from factories but that is a limitation of this first version. In the future, we might add an address registration contract which will enable a user to prove the control of a particular contract.
Posting a Pair
An additional dedicated end-point has been added
address-pairwhich must be called with a POST, to comply with Restful paradigms.
Here is an example of how to create an address pair with node.js:
If you look at the transactions behind the hashes in the code (click on them to open etherscan), you will notice that both have been sent by the same address 0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef. This is what makes the oracle accept the smart-contracts as pairs.
Using Address Pairs
Once registered, an address pair will just work. It can be used in the same manner as with an account. Follow the steps in the Try Out section of the previous post.
We now have an easy to use atomic-swap facility that allows the sending of tokens from ethereum accounts and smart-contracts. If you want to contribute or review or simply are curious, head over to the git repo, it’s all open-source.
Please create an issue in bitbucket if you spot a bug or have an idea on how to make this better.