Deploying dydx To Matic Network

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

Matic Network is a blockchain scalability platform which provides secure, scalable and instant transactions powered by PoS side chains. This will make dydx protocol to work on Plasma chain make transactions fast.

The guide shows how to deploy the dYdX V2 Margin Trading Protocol solo on Matic Network.

Clone the solo repository git clone https://github.com/dydxprotocol/solo.git

Edit the truffle.js file and all the code below to networks section

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

Open migrations/helpers.js and add || network.startswith(‘matic’);at the end of the function isDevnetwork() so that we have a basic development network ready for testing onto which further customizations can be done.

The function will finally look like :-

function isDevNetwork(network) { 
verifyNetwork(network);
return network.startsWith(‘development’)
|| network.startsWith(‘test’)
|| network.startsWith(‘test_ci’)
|| network.startsWith(‘develop’)
|| network.startsWith(‘dev’)
|| network.startsWith(‘docker’)
|| network.startsWith(‘coverage’)
|| network.startsWith(‘matic’);
}

We also need to add the chainId for Matic Network. Find the function getChainId and add the below code in it.

if (network.startsWith(‘matic’)) { 
return 8995;
}

Finally run truffle migrate --network matic to migrate the contracts to Matic Network

Links

Github Repo :- https://github.com/Trellis-Lab/solo
Deployed Contracts Address :- https://github.com/Trellis-Lab/solo/blob/master/output.txt

--

--