How do you add an additional parameter in the Sophia call entry function?

How should I add a parameter in the call entry function?

For example, Transfer in AEX9:

stateful entrypoint transfer(to_account: address, value: int)

I need a third optional parameter instead of it.

I’m not sure I understand the question, adding an argument to a function is trivial:

stateful entrypoint transfer(to_account: address, value: int, another_argument: int)

Sophia does not have function overloading, so you can’t have transfer with two arguments and three arguments. If you want an optional argument one solution is to wrap it in an Option:

entrypoint foo(arg1: int, arg2: int, opt_arg3: Option(int))
1 Like

Thank you. I haven’t tried it yet, but I know it’s the answer.

@LiuShao.chain keep in mind that if you add additional parameters to a standardized function the contract won’t meet the standard any more and thus compatibility with 3rd party services, e.g. a DEX won’t work. It will be better to make a separate transfer function with a different name for that case or just alter the transfer logic without adding a separate parameter.

1 Like