1

Background

I am fairly new to smart contracts and am currently experimenting using Ganache and Truffle to test on my local machine.

My goal would be to have the smart contract interacting with other existing smart contracts on the Ethereum Mainnet, for example the UniswapV2Factory.sol, WETH9.sol and others. To test if my methods are working correctly, I also need to deploy those contracts to my local blockchain. This is where I am having trouble.

Problem

I have tried different things:

  1. Create one truffle project and put every contract, library and interface i need in the contracts directory. This gives me trouble compiling the contracts, since some need solidity version 4.xx, 5.xx and 6.xx.

  2. Create a seperate truffle project for each contract 'group' and set the solidity compiler version accordingly. This compiles and migrates fine and I can see all contracts appearing in the Ganache GUI. But when using the Truffle console I can only interact with the contracts from one project at a time.

Question

What is the best approach when trying to test your smart contract against currently existing ones on mainnet locally?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.