January 24, 2026

Capitalizations Index – B ∞/21M

Atomic-swap for smart-contracts – Share&Charge – Medium

Atomic-swap for smart-contracts – Share&Charge – Medium

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.

Identifying pairs

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-pair which 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:

var request = require("request");

var options =
,
form:

};

request(options, function (error, response, body) );

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.

Conclusion

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.

Published at Mon, 18 Mar 2019 07:00:36 +0000

Previous Article

Bitcoin’s Price and Network Activity: One is Outpacing the Other

Next Article

Bitcoin Won’t Be $3,000 Cheap Again, Crypto To Trend Higher In April

You might be interested in …