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

expression:
  method: getPrice
  contract: 0xOracle...
  args:
    - tokenId
  returns: uint256

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

effect:
  type: foreignCall
  contract: 0xListContract
  method: flagAddress
  args:
    - transaction.sender

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

DoDon’t
Use view/pure functionsRely on state-changing methods in expressions
Keep foreign calls deterministicDepend on external randomness
Document foreign return typesAssume type inference works automatically