Warden
Creating a Simple Rule
The following example demonstrates how to create a rule that triggers an action based on a condition:
Explanation:
rule CheckThreshold
: Defines a new rule.when (balanceOf(user_address) > 1000)
: This condition checks if the userβs balance exceeds 1000 tokens.execute(action SendReward)
: Executes the predefined actionSendReward
if the condition is met.
Defining Actions
Actions specify the operations triggered when rules are satisfied. For instance, transferring tokens or interacting with another contract.
This action transfers 50 tokens from contractAddress
to user_address
.
Using Approvals
Some actions might require user approvals to ensure that only authorized users can trigger them.
Explanation:
approval(user_address)
: Ensures that the user has approved the action before it can be executed.call(contractAddress.methodName(), params)
: Calls a function on a contract with specific parameters.
Integration with Other Modules
The x/act
module can integrate with other modules, such as managing permissions or storing complex data. Here's an example of linking it to an on-chain data store:
Last updated