0

I'm still new with the solidity and it seems to be a very basics question. What i'm trying to do is to call the link the compound smart contract with mine. And when i try to compile is complaining : "This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly." while i try input into the testnet .I would appreciate greatly if anyone could help:

pragma solidity ^0.5.12;

contract testCompound {

    address cethAddress = 0x42a628e0c5F3767930097B34b08dCF77e78e4F2B; //Ropsten - Mainnet 0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5
    address cusdcAddress = 0x43a1363AFB28235720FCbDF0C2dAb7759091F7e0; //Ropsten - Mainnet 0x39aa39c021dfbae8fac545936693ac917d5e7563

    ERC20 usdc = ERC20(0xFE724a829fdF12F7012365dB98730EEe33742ea2); //Ropsten - Mainnet 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
   // ERC20 eth = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee); 

    address owner;
    //CompoundERC20 private cethCompound;
    CompoundERC20 private cusdcCompound;

    constructor() public {
        owner = msg.sender;
        usdc = ERC20(0xFE724a829fdF12F7012365dB98730EEe33742ea2);
      //  cethCompound = CompoundERC20(cethAddress);
        cusdcCompound = CompoundERC20(cusdcAddress);
    }

    function mint(uint256 mintAmount) external returns (bool){
        //cethCompound.mint(_mintAmount);
        //usdc.approve(cusdcAddress, mintAmount);
        cusdcCompound.mint(mintAmount);
        return true;
    }

}

contract CompoundERC20 {
  function approve ( address spender, uint256 amount ) external returns ( bool );
  function mint ( uint256 mintAmount ) external returns ( uint );
}

contract ERC20 {
    function totalSupply() external view returns (uint supply);
    function balanceOf(address _owner) external view returns (uint balance);
    function transfer(address _to, uint _value) external returns (bool success);
    function transferFrom(address _from, address _to, uint _value) external returns (bool success);
    function approve(address _spender, uint _value) external returns (bool success);
    function allowance(address _owner, address _spender) external view returns (uint remaining);
    function decimals() external view returns(uint digits);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
}
1
  • 1
    can you explain what did you do, what are you expecting to happen and what is the result you got.
    – Sanjay S B
    Commented Nov 10, 2019 at 14:40

4 Answers 4

0

I did not completely understand your requirement or issue you are facing, but I copied the contract you shared to remix. I am able to reproduce the error you have mentioned...

This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly.

This is when you try to deploy the Contracts, ERC20 or CompoundERC20. In your code, these are mere definitions or interfaces that are just the abstractions, an implementation should be following. Your code itself has the application of such abstractions. The line

ERC20 usdc = ERC20(0xFE724a829fdF12F7012365dB98730EEe33742ea2);

basically tells the compiler that there is a contract at the address 0xFE724a829fdF12F7012365dB98730EEe33742ea2 that will have implemented the functions whose signatures are specified later in your code as contract ERC20 { ... }. This enables you to use the usdc variable to write code that enables your contract to send messages(call functions in another contract).

4
  • Hi Sanjay, what I'm trying to achieve is to link the call ERC20 and Compound Smart contract functions in my own smart contract. From my understanding, we need define the the function we want to call e.g. mint function in Compound contract. So I was wondering how come the error is occuring "This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly." If you could help me understand better? Thank you.
    – I Yeu C
    Commented Nov 11, 2019 at 4:57
  • In your CompoundERC20 contract there is only the signature of the functions. You have to define some logic for the functions to be actually callable.
    – Sanjay S B
    Commented Nov 11, 2019 at 8:46
  • Hi Sanjay, could you share some examples with me to allow me to have a better idea?
    – I Yeu C
    Commented Nov 11, 2019 at 13:35
  • there are a bunch of examples here github.com/OpenZeppelin/openzeppelin-contracts/tree/master/…
    – Sanjay S B
    Commented Nov 12, 2019 at 4:46
0

I managed to find out what the issue with the compile, I always been deploying to the wrong contract:Deployment of smart contract

It seems like the list highlighted is in alphabetical order, therefore unknowing I always have been trying to deploy the abstract/interface contract which prompt the error. All I need to do is to go to the drop down and select my contract and it would work.

1
  • I had the same problem and when deploying, I was not chosing the correct contract. Commented Oct 23, 2020 at 12:43
0

your CompoundERC20 is only an abstract contract.

you should import from https://github.com/compound-finance/compound-protocol/tree/master/contracts

0

Here is your error:

    cusdcCompound = CompoundERC20(cusdcAddress);

cusdcAddress is type of address and CompoundERC20 type is being assigned to it

you can save it by replacing:

address cusdcAddress = 0x43a1363AFB28235720FCbDF0C2dAb7759091F7e0;

to

CompoundERC20 cusdcAddress = 0x43a1363AFB28235720FCbDF0C2dAb7759091F7e0;

Your Answer

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

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