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
Unique function identifiers for use in the function selector in contracts #96
Comments
A function selector will be composed of the function name and then the types of its parameters concatenated and hashed via SHA256, and then truncated to 4 bytes. A contract ABI function should have some additional requirements due to the nature of it being an FFI. No generic or delayed-resolution types can be allowed due to the necessity of a known type at the time of interaction. In addition, we need a consistent way to represent types that will be easily maintainable, so that we may include them in the hash for the function selector. Some options would be to rely on the default To summarize:
|
@sezna could you provide an example of how a generic type would look when made concrete in the ABI string? |
That domain separator works for me. And yes, everything will be UTF-8. |
I was thinking we would not allow generic types at all in the ABI. So, if somebody writes:
They would get an error along the lines of |
For structs and enums, we could use the syntax: |
We have forgotten about return types. How about:
? |
I don't think return type is needed, since it's irrelevant to the function signature (e.g. in C++ you can't have two overloaded functions differ only in their return type). |
Ok, I will remove it. |
In the Solidity world, functions are hashed using a specific algorithm and then truncated for 4 bytes. We need to decide if we want to follow the same scheme (it sounds like we do), and implement it. These will then be baked into the contract preamble section in the ABI/"switch statement" for contracts.
Assigning Victor for now since he seemed to have interest, but feel free to reassign if that is not the case.
The text was updated successfully, but these errors were encountered: