Quickstart
See the Rules Engine in action in minutes
This Quickstart is a work in progress. If you see this message, there are a few engineering details we are cleaning up before you’ll be able to follow it.
This Quickstart includes a repository with everything you need to get an example rule up and running quickly and easily.
Get Started
Create a copy of this template repository in your own github account by navigating here: https://github.com/thrackle-io/fre-quickstart and clicking the “Use this template” button on GitHub.
Next, clone the freshly created repository to your local machine:
Install Dependencies
Start Local Anvil Chain
Use the provided anvil state file to get a local anvil chain running with the rules engine deployed.
Environment File
Add a file named .env
to the repository and set the following values:
With your .env
file ready you can make the values available to your command line shell with the following command:
Add Demo Policy
The fre-quickstart
repo includes a demo policy to get started quickly. Deploy it by running the following provided script:
Deploy Example Contract
The repository you cloned includes an example smart contract with the necessary modifier included. Deploy this contract using the provided script with this command:
Note the contract address, add it to your .env file and re-run the source command:
Now, you need to set the rules engine address for the contract you just deployed. This enables the contract to hook into the protocol for rules evaluations.
If you deployed to a testnet then you’ll need to replace the first address
(0x68B...
) in that above command to match that of your deployed contract
address.
Apply the Policy
Now it’s time to apply a premade policy to the transfer function of the sample contract. A script is provided to make this very easy, simply run the following command:
This will apply a policy that requires transfer amounts be greater than 10,000.
Test Success Condition
You should receive a revert with the text “Passed Test”
Test Failure Condition
You should receive a revert with the text “Failed Test”
Conclusion
That wraps up the quickstart! In a few short minutes you were able to see the rules engine in action. Continue through the guides to learn how to apply the power of rules in your own projects.