Variadic Functions in Clarity Contracts

Hey everyone,

My goal is to implement a variadic function in Clarity, a function that accepts a variable number of arguments and then utilizes them in a contract-call to invoke a function.

I considered using lists in function signature but Clarity has no support for arrays or dynamic size lists which can be used to pass variable arguments.

I understand that Clarity doesn’t directly support variadic functions or dynamic sized data structures to maintain predictability and prevent runtime errors.

I would appreciate if anyone could suggest alternative approaches or workarounds to achieve this functionality within the Clarity language. Thank you in advance for your insights!

2 Likes

Is there any structure to the arguments that you could take advantage of? For example, if you define your outer function to take all possible arguments as optionals, then just pass none when one isn’t needed, or are you looking to take anything at all?

2 Likes