Interact With Instances
The following functions provide utilities to support the interaction with module instances: checking whether a certain instance was created, reading instance's display parameters (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 this function.
isModuleDeployed
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 instance creation function.immutableArgs
- The module's immutable args, as provided to the instance creation function.saltNonce
- Salt nonce to use.
Response:
true
if the module was deployed, false
otherwise.
getInstanceParameters
Get a module's instance live parameters.
The parameters to fetch are listed in the Module's registry object (in the 'parameters' property), and their purpose is to display relevant information for each module instance.
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.
callInstanceWriteFunction
Call a module's write function.
The 'customRoles' and 'writeFunctions' properties of a Module's object 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.
Arguments:
account
- Viem account (Address for JSON-RPC accounts or Account for other types).moduleId
- Module's ID (implementation address).instance
- Instance's address.func
- The function to call, provided as an object of WriteFunction type.args
- The input arguments to pass the function.
Response:
status
- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash
- transaction's hash.
Last updated