Skip to main content
Version: v1.4

Define Function Parameters

You can use the optional params subsection to specify the parameters a function accepts. This section can define both mandatory and optional parameters. Optional parameters are denoted with a question mark ? following the field type.

Schema Tool Automation

The Schema Tool streamlines the creation of functions by:

  • Generating an immutable structure holding parameter proxies from the Params map.
  • Checking the presence and data type of non-optional parameters before the function call.

These functionalities allow users to directly use parameter proxies in the structure passed to the function.

note

Omitting the params subsection results in no structure generation or parameter passing 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))
}

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.