Contract-Design

可開采的代幣可能嗎?

  • December 21, 2018

我對 ethereum.org/token 範例感到有些困惑,該範例在高級範例中進一步說明它可以與工作量證明相結合。我真的很喜歡探勘代幣的想法。該範例如下所示:

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

現在我的問題是,這看起來像是惡意通貨膨脹的honeypot。不是giveBlockReward()每個塊都可以執行多次嗎?對區塊號進行完整性檢查的簡單機制是否足以使這成為可能?

您應該跟踪最後一個區塊以“探勘”其獎勵以防止濫用:

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

看看EIP 918: Mineable Token Standard。建議介面:

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);
}

引用自:https://ethereum.stackexchange.com/questions/15972