How to integrate your smart contract with the Forte Rules Engine
policy.json
file that defines our Policy. We have pre-created it for you here to match the described scenario. For more information on how to configure policies yourself, check out the Policy Configuration Guide.
mint(address to, uint256 quantity)
, but the encodedValues
also includes an address owner
field. So, in this case we need to pack in additional data to send from the calling contract to the policy.
Also note the ForeignCalls
defined in the policy, which are used in the rule evaluation as well as an effect for the positive mint outcome path.
ClaireNFT.sol
contract, create a new file named injectModifiers.ts
and add the content below.
src/RulesEngineClientCustom.sol
and diff.diff
. It will also update the existing ClaireNFT.sol
file by adding the modifier to the mint
function.
diff.diff
file will show exactly what was changed in the ClaireNFT.sol
file for your
reference.policy.json
file, the modifier automatically added in the owner
field into the modifer file for you.
(show the modified ClaireNFT.sol relevant piece of code).
And that’s it! The ClaireNFT.sol contract is now ready to use for this policy.
owner
value is not a function argument and must be explicitly added to the modifier attached to the mint
function. This was accomplished by manually editing the RulesEngineClientCustom.sol
and ClaireNFT.sol (Updated)
files to include this extra function argument.
Refer to the code examples in the tabs above to see exactly how to do this. You can include any extra state variables in your smart contract that you want to leverage in your rule condition using this method.