6

I'm a bit puzzled about the ethereum.org/token example which states further down in the advanced examples that it can be coupled to proof-of-work. I really like the idea of mining a token. The example looks something like this:

function giveBlockReward() {
  balanceOf[block.coinbase] += 1;
}

Now my question is, this looks like a honeypot for malicious inflation. Isn't it possible to execute giveBlockReward() multiple times per block? Would a simple mechanism to make sanity checks on blocknumber be sufficient to make this possible?

6

You should keep track of the last block to "mine" its reward to prevent abuse:

uint lastBlockRewarded;
function giveBlockReward() {
  if (lastBlockRewarded >= block.number) 
    throw;
  lastBlockRewarded = block.number;
  balanceOf[block.coinbase] += 1;
}
2

Take a look at EIP 918: Mineable Token Standard. Proposed interface:

contract ERC918  {

   function mint(uint256 nonce) public returns (bool success);

   function getAdjustmentInterval() public view returns (uint);

   function getChallengeNumber() public view returns (bytes32);

   function getMiningDifficulty() public view returns (uint);

   function getMiningTarget() public view returns (uint);

   function getMiningReward() public view returns (uint);

   function hash(uint256 _nonce, address _minter) public returns (bytes32 digest);

   function _reward(address _minter) internal returns (uint);

   function _epoch() internal returns (uint);

   function _adjustDifficulty() internal returns (uint);

   event Mint(address indexed from, uint rewardAmount, uint epochCount, bytes32 newChallengeNumber);
}

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.