0

What should I do?

pragma solidity ^0.4.21;
contract ScoreInterface {
         function hit() public;
         function score() public view returns (uint);
}

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

  • You should do exactly what the deployment error tells you - implement those two functions, or avoid deploying the contract. Since the name of this contract ends with "Interface", I would guess that you should choose the latter option. – goodvibration Apr 7 at 12:21
1

That's an Interface contract.

They are useful but they can't be deployed. They contain function signatures with no code blocks, so the EVM wouldn't know what to do - unacceptable.

An interface can provide a layer of protection for developer error.

contract Score is ScoreInterface {
  // now we are committed to implementing each function in ScoreInterface
  function hit() public {
    // do something
  }
  function score() public view returns (uint) {
    // do something
  }
}

Score will be deployable when each of those functions is defined.

Interfaces describe the surface area of a contract without describing the internal code. This is useful for other contracts that want to interact.

contract Game {

  function recordHit(address scoreContract) public {
    ScoreInterface s = ScoreInterface(scoreContract);
    s.hit();
  }
}

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

0

You need to add some logic to your contract like this:

pragma solidity ^0.4.21;
contract ScoreInterface {
  function hit() public {
     // Some logic here
  }
  function score() public view returns (uint) {
     // Some logic here
  }
}

Actually, empty logic (as in my example) will work too, your contract will be able to deploy, but will do nothing when called.

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.