I am trying to fork Uniswap and deploy on Ropsten testnet for educational and testing purposes. From what I gathered, it seems that we need to first deploy the UniswapV2Factory contract, followed by the UniswapV2Router02 contract. I cloned both from here and here respectively. I haven't made any changes to the code. I can deploy the factory contract just fine using truffle. However, I am getting the following error while deploying the router contract.:
Error: *** Deployment Failed ***
"UniswapV2Router02" -- Cannot create instance of UniswapV2Router02; no code at address 0xXXXXXXXXXXXXXX.
This is the script I am using to deploy UniswapV2Factory:
const Factory = artifacts.require("UniswapV2Factory.sol");
module.exports = async function (deployer, network, addresses) {
await deployer.deploy(Factory, addresses[0]);
};
and the code to deploy UniswapV2Router02:
const Router = artifacts.require('UniswapV2Router02.sol');
module.exports = async function (deployer, network, addresses) {
const WETH_ADDRESS = '0x0a180a76e4466bf68a7f86fb029bed3cccfaaac5';
const FACTORY_ADDRESS = '{factory address}';
await deployer.deploy(Router, FACTORY_ADDRESS, WETH_ADDRESS);
}
I have changed the solidity compiler version to 0.5.16 for the factory and 0.6.6 for the router.