0

I am building a contract which integrates with an existing contract on mainnet.

  1. Are there any tools I can use to test my integration with this contract without spending real gas? Or is there an easy way to fork the contract and redeploy it on testnet? I'm not sure how to copy all the solidity code on etherscan as there are many dependencies, especially since it is a proxy contract.

  2. I understand that one way of interacting with an external contract within a contract, is to import the object from the solidity code. However, do I always need to import the full contract object from the solidity code, or is it possible to achieve the same thing just with the ABI?

3
  • You can deploy a new contract on testnet from the contract ABI but, if it is a proxy contract, there are likely several contracts you will need to get the ABI for to deploy/configure. Without more detail though it is hard to give more specific advice IMO. Dec 22, 2022 at 16:00
  • I'm planning to integrate with one of Alchemix's pools, by integrating with some of their deposit/withdraw functions from their contract at etherscan.io/address/… .
    – Jolow
    Dec 22, 2022 at 16:03
  • 1
    You can just copy the contract code into remix and deploy on testnet since it is open source. If you try to deploy just from the ABI/Bytecode you won't really be able to make changes if that makes since. Dec 22, 2022 at 16:18

1 Answer 1

1
  1. I think the best way forward would be to fork mainnet into your local environment, I've tested with hardhat and foundry and is quite straight forward, you can see the hardaht docs here https://hardhat.org/hardhat-network/docs/guides/forking-other-networks

  2. Actually you could instantiate the contract with the method you require. Imagine you want to call the transfer method from a ERC20 contract. Then you could create the interface like:

    interface IERC20 { function transfer(address to, uint256 amount) external; }

and then in your code:

IERC20(token address).transfer(to,amount);

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.