1

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.

0

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.

0

Read about Abstract Contracts you will get some more in depth understanding why this error is coming. https://solidity.readthedocs.io/en/v0.5.3/contracts.html#abstract-contract

Your Answer

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

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