- Foreign data – As part of expressions in rules or trackers
- Foreign effects – As actions triggered by rules
Configuring Foreign Calls
To call a foreign contract from the Rules Engine, you will need to specify everything needed to call that function, in particular:- the foreign contract’s address
- the function signature to be called
- expected return type
- the arguments of the function to pass (numerical index of argument(s), starting with 0)
A foreign call may be leveraged by anyone until it is registered as a permissioned foreign call.
It is highly recommended that the foreign call be immediately registered with the Rules Engine
after deployment to decrease the potential that a policy can leverage it prior to it being
registered. If a policy utilizes a foreign call prior to permissioned foreign call registration,
it may continue to leverage it until the policy is modified.
Using Foreign Calls
Once you have a foreign call configured as part of your policy, you can use it in any expression. For example, you could use it in a rule that calls an external oracle to verify if an address is on the OFAC sanctions list, and reverts the transaction if it is. Or you could use a foreign call to an AMM price feed, to update a tracker that measures volatility or some other aggregate metric related to price. You can also use foreign calls as an effect, an outcome of a rule. For example, you might update a foreign oracle based on activity with a token that is subscribed to your policy. Foreign Calls can also be used as inputs for other foreign calls or mapped trackers.Foreign calls used in expressions must return immediately usable values—only read/view functions
are supported.