...by Daniel Szego
quote
"Simplicity is the ultimate sophistication."
Leonardo da Vinci

Sunday, February 4, 2018

Solidity and Truffle Tips and Tricks - order of modifiers


If you have several modifiers in a solidity function these modifiers might be dependent from each other, hence they might self modify the world state giving the possibility for another precondition for the next check. Anyway, the order of evaluation is from left to right as probably expected. So executing the test() function in the following code results "three"in the num variable. 

contract TestContract {
    string public num = "zero";
    
    modifier one(){
        num = "one";
        _;        
    }
    
    modifier two(){
        num = "two";
        _;        
    }

    modifier three(){
        num = "three";
        _;        
    }

    function test() one two three {
    }
}