Kyber Swap on Matic Network Plasma Chain

Manank Patni
Trellis Labs
Published in
2 min readSep 12, 2019

The guide shows how to deploy the Kyber Exchange on Matic Network.
Matic Network is a blockchain scalability platform which provides secure, scalable and instant transactions powered by PoS side chains.
KyberSwap allows anyone to convert tokens directly from their wallet in an instant, convenient and secure way. No order books, wrapping or deposits.

Deploying Kyber Smart Contracts on Matic Network

First we need to clone the Kyber Contracts using
git clone https://github.com/https://github.com/KyberNetwork/workshop.git

Edit the truffle.js file and add the below code to networks sections

matic: {                             
provider: function() {
return new HDWalletProvider("mnemonic",'https://testnet2.matic.network', 0,1) },
network_id: 8995,
gas: 8000000,
gasPrice: 0,
},

After this do truffle migrate -f 1 --to 3 --network matic |& tee output.txt This will migrate the first 3 migration files, which basically do the contract deployment, the rest of the files can be executed for further operations.

The migrations logs for the contract will be saved in output.txt which will be needed for the Kyber Swap Frontend.

Deploying the Kyber Swap Frontend

The Kyber Swap frontend is given in a similarly named repo which can be cloned by git clone https://github.com/KyberNetwork/KyberSwap

The repo is big so it might take some time.

After downloading the repo we need to first add a file in the directory env/config-env named matic.json The contents of this file will be same to what is in other files of the directory. Only the contracts address and various endpoints need to be changed.

The final file will look something like :-

Next step would be to add matic run commands in package.json

In the scripts section add the below two lines :-

"build-matic": "NODE_ENV=matic node webpack-wrapper.js",
"matic": "webpack-dev-server --content-base src --inline --hot --history-api-fallback --host 0.0.0.0 --port 3002 --env.chain=matic --env.logger=true",

Now run,

npm run build-matic

A new dist folder would be created with name matic. Copy all remaining files from dist/ropsten folder to dist/matic

Now finally do

npm run matic

The Kyber Swap will be running at localhost:3002

--

--