> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfwriteup/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfwriteup/rareskills-puzzles/yul-puzzles/02-simplerevert.md).

# 02 - SimpleRevert

**Goal:** Trigger a revert without any message from Yul.

```solidity
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {SimpleRevert} from "../src/SimpleRevert.sol";

contract SimpleRevertTest is Test {
    SimpleRevert public c;

    function setUp() public {
        c = new SimpleRevert();
    }

    function test_SimpleRevert() public {
        vm.expectRevert();
        c.main();
    }
}
```

To revert execution (e.g., indicate an error), Yul provides the `revert(p, s)` opcode, which stops execution and returns an error code to the caller. A simple revert with no message can be done by specifying a memory pointer and length of zero (`revert(0, 0)`). This is equivalent to a Solidity `revert()` with no reason string.

```solidity
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;

contract SimpleRevert {
    function main() external pure {
        assembly {
            // Revert execution with no data (equivalent to revert())
            revert(0, 0)
        }
    }
}
```

**Explanation:**

We do not need to store any data in memory for an empty revert. By convention, the pointer can be 0

and length 0 to signify no return data. This will roll back all state changes and signal an error.

<figure><img src="/files/iyXnDciiMr1msDYdDeU6" alt=""><figcaption></figcaption></figure>

Run test:

```bash
forge test --mp test/SimpleRevert.t.sol -vvvv
```

<figure><img src="/files/PT03ozc0v4QoVcY1olYx" alt=""><figcaption></figcaption></figure>
