Coder Social home page Coder Social logo

Revert reason about multicall HOT 3 CLOSED

mds1 avatar mds1 commented on August 15, 2024
Revert reason

from multicall.

Comments (3)

mds1 avatar mds1 commented on August 15, 2024 1

Yep that is correct, custom errors can be decoded basically the same way calldata can be decoded—you know the signature to get the 4 byte selector, and with the signature you know how to decode the rest of the args

from multicall.

mds1 avatar mds1 commented on August 15, 2024

It is possible! If the call fails, the Result.returnData (or just returnData depending on which method) contains the ABI encoded failure reason.

If that reason is an Error(string) from a require, you can decode it like this: https://github.com/Uniswap/v3-periphery/blob/6cce88e63e176af1ddb6cc56e029110289622317/contracts/base/Multicall.sol#L16-L23

If it's a panic you can ABI decode the Panic(uint256) and map it to an error code. More info here: https://docs.soliditylang.org/en/latest/control-structures.html#error-handling-assert-require-revert-and-exceptions

from multicall.

gigamesh avatar gigamesh commented on August 15, 2024

Awesome thank you - are custom errors surfaced in returnData as well, or only require() error strings & panic codes?

EDIT: I was just informed that if its a custom error, I can decode the first 4 bytes (error function selector) of returnData but I'll need to know the signature to decode it. That should work for what I'm trying to do but lmk if it doesn't sound right.

from multicall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.