O'Reilly logo

Blockchain for Enterprise by Narayan Prusty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing

Now we have the smart contracts ready for conducting atomic swaps between the assets of two different blockchains. Next, let's write some JavaScript code to test the preceding contracts and conduct an atomic exchange. The following code allows you to do this. For testing and simulation purposes, you can run the following code in one single Quorum node with four accounts:

var generateSecret = function () {    return Math.random().toString(36).substr(2, 9);};var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));var RBI_Address = "0x92764a01c43ca175c0d2de145947d6387205c655";var FRS_Address = "0xbc37e7ba9f099ba8c61532c6fce157072798fe77";var BOA_Address = "0x104803ea6d8696afa6e7a284a46a1e71553fcf12";var ICICI_Address ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required