0

I'm having an issue using an instance of a deployed smart contract in my code. This could easily be me being a solidity novice, but perhaps some of you might be able to point out what I am missing.

I am trying to integrate the contract deployed here. The contract has a number of functions but I only need to use a couple. I am using solidity 0.6 and here is how I am integrating it...

First here is the functions I am pulling out of the contract to use.

contract IOneSplit {
    
    constructor(address _oneInchAddress) public {
        IOneSplit(_oneInchAddress);
    }
    
    function getExpectedReturn(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 parts,
        uint256 flags // See contants in IOneSplit.sol
    )
        public
        view
        returns(
            uint256 returnAmount,
            uint256[] memory distribution
        );
    
    function getExpectedReturnWithGas(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 parts,
        uint256 flags, // See constants in IOneSplit.sol
        uint256 destTokenEthPriceTimesGasPrice
    )
        public
        view
        returns(
            uint256 returnAmount,
            uint256 estimateGasAmount,
            uint256[] memory distribution
        );
    
    function swap(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 minReturn,
        uint256[] memory distribution,
        uint256 flags // See contants in IOneSplit.sol
    ) public payable returns(uint256);

}

Next, here is how I am attempting to instantiate a version of the deployed contract to call on the functions.

contract ExampleContractCall {

    constructor(address ONE_SPLIT_ADDRESS) public {
        IOneSplit oneInchContract = IOneSplit(ONE_SPLIT_ADDRESS);
    }

    oneInchContract.swap(*insert parameters here*)
}

This is how I try to call it but when I compile I get "TypeError: Contract "IOneSplit" should be marked as abstract." Any ideas how to integrate this contract?

  • You have declared a bunch of functions in contract IOneSplit, but you haven't implemented a single one of them! – goodvibration Nov 25 '20 at 19:02
  • Is this the wrong way to use functions from another contract? Essentially, I am trying to call the functions from another smart contract already deployed. I thought this was done by passing the mainnet contract address to the IOneSplit contract? Is this the wrong way to call functions from another contract? – pcuser10456 Nov 25 '20 at 19:07
  • I have been trying to use this tutorial which seems to suggest to implement in the way I have above Tutorial – pcuser10456 Nov 25 '20 at 19:10
  • No, it's the right way, but just like the compilation error-message tells you - that contract should be marked as abstract. In other words, add abstract before contract. – goodvibration Nov 25 '20 at 21:02
  • It appears you were right, the error message explained exactly that. Perhaps there are not many examples utilizing abstract class syntax. It must be in newer versions of solidity. Older examples do not feature the use of "abstract" identifiers or "virtual" identifiers for the functions. – pcuser10456 Nov 25 '20 at 22:49

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.