Interact With Instances
Last updated
Last updated
The following functions provide utilities to support the interaction with module instances: checking whether a certain instance was created, reading instance's (as specified in the 'parameter' property in the Module's object) and calling its write functions.
To get the module's object from an instance address, use .
Check if a module is already deployed, using its creation arguments.
Arguments:
moduleId
- Module's ID.
hatId
- The target hat ID, as provided to the .
immutableArgs
- The module's immutable args, as provided to the .
saltNonce
- Salt nonce to use.
Response:
true
if the module was deployed, false
otherwise.
Get a module's instance live parameters.
Arguments:
instance
- Instance's address.
Response:
An array of objects, each containing a parameter's information:
label
- The parameter's name/description.
value
- The parameter's value, as was returned from the instance contract.
solidityType
- The parameter's Solidity type.
displayType
- The parameter's display type. Its purpose is for UIs to be able to render an appropriate component for the parameter. For example, rendering a date for timestamps.
Call a module's write function.
Arguments:
account
- Viem account (Address for JSON-RPC accounts or Account for other types).
moduleId
- Module's ID (implementation address).
instance
- Instance's address.
args
- The input arguments to pass the function.
Response:
status
- "success" if transaction was successful, "reverted" if transaction reverted.
transactionHash
- transaction's hash.
The parameters to fetch are listed in the (in the 'parameters' property), and their purpose is to display relevant information for each module instance.
The 'customRoles' and 'writeFunctions' properties of a enable to programmatically get all the write functions of a module, together with any necessary information to call them: expected input arguments and the roles (Hats) that have the permission to call each function.
func
- The function to call, provided as an object of type.