Skip to main content

Define Function Results

You can use the optional results subsection to detail the results a function can produce. This setup aligns with the field definitions seen in the Params subsection.

Schema Tool Features

The Schema Tool assists in this setup by:

  • Creating a mutable structure that includes proxies for each result variable found in the Results map.
  • Enabling users to assign values to result variables via this generated structure during the function call.
note

If the results subsection is not used, no structure will be created or conveyed to the function.

For example, here is the structure generated for the mutable results for the getFactor function:

type MutableGetFactorResults struct {
proxy wasmtypes.Proxy
}

// relative division factor
func (s MutableGetFactorResults) Factor() wasmtypes.ScMutableUint64 {
return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultFactor))
}

Note that the Schema Tool will also generate an immutable version of the structure, suitable for accessing the results after by the caller of this smart contract function.