[Ethereum] Remix: This contract does not implement all functions and thus cannot be created error

contract-deploymentcontract-designcontract-developmentremixsolidity

I have 2 contracts:

pragma solidity ^0.4.18;

contract Coin {
    function transfer(address whom, uint256 amount) public;
}

contract ManagedWallet {
    event ReceivedEther(address source, uint256 amount);
    event ContractCalled(address theContract,uint256 value, bytes data);

    function () public payable {
        ReceivedEther(msg.sender,msg.value);
    }

    function sendEther(address whom, uint256 amount) public {
        whom.transfer(amount);
    }

    function sendToken(Coin token, address whom, uint256 amount) public {
        token.transfer(whom,amount);
    }

    function callContract(address theContract, uint256 value, bytes data) public {
        require(theContract.call.value(value)(data));
        ContractCalled(theContract,value,data);
    }

}

But when I try to deploy that Coin contract, I get this error in Remix.

This contract does not implement all functions and thus cannot be
created

What am I missing here? Really appreciate help because I'm new to smart contract development and Solidity.

Best Answer

The problem is clear but I can't quite extrapolate from the errant code to intent.

Coin won't deploy because it declares a function transfer without defining what's supposed to happen (the {} block isn't defined). This is a useful pattern when you get into inheritance but if was allowed to be deployed like this, then there would be a contract with an undefined function, and that won't do.

Since it's early days, I might suggest playing around with this simplified thingy that might help you form a mental picture of what's happening.

contract Test {

  event LogTest(address sender, address toWhom, uint amount);

  function test(address whom, uint256 amount) public returns(bool success) {
    LogTest(msg.sender, whom, amount);
    return true;
  }
}

Hope it helps.

Related Topic