Skip to main content

Function Parameters

The optional params subsection contains field definitions for each of the parameters that a function takes. The layout of the field definitions is identical to the state subsection field definitions with one addition, the field type can be followed by a question mark to indicate that the parameter is optional.

The Schema Tool will automatically generate an immutable structure with member variables for proxies to each parameter variable in the Params map. It will also generate code to check the presence of each non-optional parameter, and it will also verify the parameter's data type. This checking is done before the function is called. The user will be able to immediately start using the parameter proxy through the structure that is passed to the function.

When this subsection is empty or completely omitted, no structure will be generated or passed to the function.

For example, here is the structure generated for the immutable Params for the member function:

type ImmutableMemberParams struct {
proxy wasmtypes.Proxy

// address of dividend recipient
func (s ImmutableMemberParams) Address() wasmtypes.ScImmutableAddress {
return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress))

// relative division factor
func (s ImmutableMemberParams) Factor() wasmtypes.ScImmutableUint64 {
return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamFactor))

Note that the Schema Tool will also generate a mutable version of the structure, suitable for providing the parameters when calling this smart contract function from any Call Context.

In the next section, we will look at the results subsection.