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
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
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.
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
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.