How to capture the revert from the calle contract?

I have a Logic contract(caller), which calls a another contract named StorageContract (calle). I’m call a function of Storage contract through the LogicContract and I have put a require inside that function, which doesnt satistfy. But im unable to get thet require message in my Logic Contract

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "hardhat/console.sol";

error InsufficientBalance(string data);

contract Storagecontract{
    address public owner;
    function set(string memory _name)public view {
        revert InsufficientBalance({data: "Nothing"});


contract Logiccontract{
    string public stat;

    function changename(address add, string memory name)public {
         (bool send, bytes memory data)"set(string)", name));


Please elaborate!

For example:

  • What is your execution flow?
  • What is the outcome of that flow?
  • How is it different from the outcome that you’re expecting?

Also, there seems to be a lot of code which is irrelevant to your question.

For example - onlyOwner, changeOwner, etc.

Please include only the relevant information, so that your question is easier for readers to address.

I have updated the above code, please have a look. All i want is when i make a call from logicContract to StorageContract (set func). I need that custom error back in my Logic contract

Revert is not a state-changing operation.

Perhaps you’re confusing it with emitting an event (similar spelling in a way)?

1 Like