In TypeScript, an aptos transaction payload is like this:
const payload = {
type: "entry_function_payload",
function: `xxx`,
type_arguments: [],
arguments: [str1, str2],
};
In order to call the below entry function from TypeScript:
public entry fun myfun(account: &signer, a: u64, b: u64, c: Option<address>)
I try to pass in a std::option::Option
argument. While serializing u64 is as simple as num_a.toString()
and num_b.toString()
, I haven't figured out how to pass in an std::option::Option
argument to transaction payload.
Any help?
At this point in time, the only types allowed in an entry function are primitive types (integers, vectors, addresses) and the string type. The team is actively exploring how we might introduce more types.
The reason is that types must also have a means for a user to them. For example, a user can not trivially generate a coin. If there were no checks on what types can be passed into an entry function, a user theoretically could define a coin as part of their entry function and generate new coins just by calling that function.
For now, you can simulate an option by using a Vector. In fact, the current option implementation uses vector under the hood.