2

What is the best practise to write require error messages with parameters?

Currently I have

uint8 public constant MAX_PER_USER; 
<..>
require(
            balance + value <= MAX_PER_USER,
             "You can only have" +  MAX_PER_USER  + "per user"
        );

which gives me an error:

TypeError: Operator + not compatible with types literal_string "You can only mint" and uint8

should I change my error message and do not use any parameters or add type conversion?

  • See here, https://ethereum.stackexchange.com/questions/6591/conversion-of-uint-to-string – Ben Dec 09 '21 at 10:49

0 Answers0