EatTheBlocks Forum

Router error while deploying contract in Flashloan course?

When I try to deploy my contract, it compiles ok, but under 2_deploy_contracts.js I get a “TypeError: Cannot read property ‘router’ of undefined” at addresses.uniswap.router ?
My 2_deploy_contracts.js :

const Flashloan = artifacts.require("Flashloan.sol");
const { mainnet: addresses } = require('../addresses');

module.exports = function(deployer, _network, [beneficiaryAddress, _]) {
deployer.deploy(
    Flashloan,
    addresses.kyber.kyberNetworkProxy,
    addresses.uniswap.router,
    addresses.tokens.weth,
    addresses.tokens.dai,
    beneficiaryAddress
  );
}; 

If I try to run arbitrage.js I get “TypeError: Cannot read property ‘address’ of undefined” at Flashloan.networks[networkId].address in run-arbitrage.js.
Does anybody have any idea what could be the issue ?
Thx

You need to deploy Flashloan first. Then for uniswap, what do you have in addresses/uniswap-mainnet.json?

Yes agreed, I have to deploy first with truffle migrate --reset --network mainnet the run run-arbitrage.js. Hmm in my addresses I only have
kyber-mainnet.json, tokens-mainnet.json and index.js, uniswap and dydx are missing :face_with_raised_eyebrow:. Should I create the missing .json files from the repo myself ? Thx

I figured it out, I had to add the dydx and uniswap require in index.js and add also the mainet :slight_smile:

1 Like