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

Please allow to encode calls to functions using variable sized arrays/tuples as parameters. #14861

Closed
ytrezq opened this issue Feb 16, 2024 · 1 comment
Labels

Comments

@ytrezq
Copy link

ytrezq commented Feb 16, 2024

Currently, if 1 has to call a Solidity function that takes a variable sized array as parameter, he/she is asked to do it off‑chain or rewrite his code so that the function he/she intend to call use fixed size arrays instead.
But 1 popular exchange which called 0x is using external functions taking variable‑sized arguments : they can’t be called on chain if the parameters building has to be done on‑chain.

Specification

Preferably allow abi.encode or abi.encodewithselector like functions to support telling an argument isn’t taking a fixed‑size array/tuple.

Backwards Compatibility

This would be a language extension using an additional possible syntax and wouldn’t affect old code encoding fixed‑size arrays.

@ytrezq ytrezq added the feature label Feb 16, 2024
@matheusaaguiar
Copy link
Collaborator

Hi @ytrezq.
Thanks for the report, but in the link you posted, the most upvoted answer shows an example of a function with variable sized arrays being called using abi.encode.
The Solidity documentation also explains about non-fixed-size types and tuples:

The following non-fixed-size types exist:

    bytes: dynamic sized byte sequence.

    string: dynamic sized unicode string assumed to be UTF-8 encoded.

    <type>[]: a variable-length array of elements of the given type.

Types can be combined to a tuple by enclosing them inside parentheses, separated by commas:

    (T1,T2,...,Tn): tuple consisting of the types T1, …, Tn, n >= 0

It is possible to form tuples of tuples, arrays of tuples and so on. It is also possible to form zero-tuples (where n == 0).

@ethereum ethereum deleted a comment from GAMECHANGE Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants