What does it mean when a Solidity contract includes a comment starting with // dev: after a revert or require statement?

For example:

contract Example {
    function greet(){
        revert(); // dev: Hello World        

1 Answer 1


This is called a developer revert comment. From the Brownie documentation:

Each revert string adds a minimum 20000 gas to your contract deployment cost, and increases the cost for a function to execute. Including a revert string for every require and revert statement is often impractical and sometimes simply not possible due to the block gas limit.

For this reason, Brownie allows you to include revert strings as source code comments that are not included in the bytecode but still accessible via TransactionReceipt.revert_msg. You write tests that target a specific require or revert statement without increasing gas costs.

To write a test that handles the example in the question, use the entire revert comment starting with dev:

import brownie

def test_greet(example):
    with brownie.reverts("dev: Hello World"):

For more information:

Disclosure: I am the lead developer for Brownie.

  • 1
    This answer would make a great example within the docs =)
    – Justin
    Commented Apr 21, 2021 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.