Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include function output types or entire ABI if available #130

Open
zemse opened this issue Nov 17, 2022 · 0 comments
Open

Include function output types or entire ABI if available #130

zemse opened this issue Nov 17, 2022 · 0 comments

Comments

@zemse
Copy link

zemse commented Nov 17, 2022

  • OS: osx
  • Python version (output of python --version):
  • Environment (output of pip freeze):

What is wrong?

Currently, www.4byte.directory does not include the interface for return type given a selector.

% curl https://www.4byte.directory/api/v1/signatures/?hex_signature=0xfaa75068
{
  "count":1,
  "next":null,
  "previous":null,
  "results":[{
      "id":847492,
      "created_at":"2022-11-17T12:50:56.132220Z",
      "text_signature":"killStinkyNigger(address)",
      "hex_signature":"0xfaa75068",
      "bytes_signature":"ú§Ph"
    }]
}

It would be great to include the entire ABI fragment in the response or a compact human readable ABI.

My use case is decoding execution trace. I do get the function signature which helps to decode the calldata, however the return data from the execution can't be decoded since we don't know it's interface.

STATICCALL UnknownContractAndFunction(
  to=0xfe0e4dc42f1e587bb20f1e664734d490852f6696,
  // input can be decoded
  input=0x5c60da1b, 
  // output cannot be decoded since we don't know the return interface
  ret=0x0000000000000000000000003cfd48e3dc7ee2519bc9b3374e3a8b8cf5cada3e
)

How can it be fixed

Include the output ABI in the selector response in www.4byte.directory.

There is a catch that output ABI is not unique, because the return signature is not baked into the selector, given a selector with same calldata signature, it can have various return signatures. e.g. name() mostly returns string, but for MKR token contract it returns bytes32 value. Hence, the return type for name() can include both types. The consumer can try using the suggested return signature from the directory, and proceed with whatever works for them.

@zemse zemse changed the title Function return types Include function output types or entire ABI if available Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant