Foreign Contracts
Connect your policy to external contracts for data lookups or on-chain actions.
Foreign contracts allow your policy to access external on-chain data or call external contract functions. This makes the Forte Rules Engine highly composable and extensible.
Foreign contracts can be used in two ways:
- Foreign data – As part of expressions in rules or trackers
- Foreign effects – As actions triggered by rules
Using Foreign Data
You can reference values from an external contract inside any expression. To do so, you’ll define:
- Contract address
- Method name
- Arguments – Each one an expression
- Expected return type
Example
Foreign calls used in expressions must return immediately usable values—only read/view functions are supported.
Using Foreign Effects
Foreign effects invoke methods on external contracts as part of rule outcomes.
You’ll define:
- Contract address
- Method
- Arguments (as expressions)
Example
Use foreign effects for list updates, triggering oracles, or any cross-system integration.
Naming & Off-Chain Info
In the Forte UI, you can give friendly names to foreign contracts (e.g. “Oracle”, “OFAC List”, “Leaderboard”). These are off-chain only and used to improve readability during configuration.
Best Practices
Do | Don’t |
---|---|
Use view/pure functions | Rely on state-changing methods in expressions |
Keep foreign calls deterministic | Depend on external randomness |
Document foreign return types | Assume type inference works automatically |