...by Daniel Szego
quote
"On a long enough timeline we will all become Satoshi Nakamoto.."
Daniel Szego

Wednesday, April 4, 2018

Solidity Tips and Tricks - debug mode with blocknumber


As we have seen in our previous blog, designing smart contract structure with debug features might be a pretty good idea. One possibility is to realize it with an explicit switch that can be manually switched on or off, however it might happen automatically as well, like based on the actual blocknumber. The following code demonstrates the idea: 

contract TestDebugMode2 
 {    
   uint public targetDebugNumber = 1111111111; 
   
   modifier isInDebug() {       
       require(block.number < targetDebugNumber);
        _;
  }

  function onlyInDebug() isInDebug {

  }