What is a Permissioned Foreign Call?
A Permissioned Foreign Call is a security mechanism that controls who can use specific functions from external contracts in their Rules Engine policies.How it Works
- Contract Owner Sets Up: The owner of an external contract marks specific functions as “permissioned”
- Rules Engine Creates Allowlist: The Rules Engine maintains a list of addresses that are allowed to use this function
- Policy Creation Check: When someone tries to create a policy that uses this function, the Rules Engine checks if their address is on the allowlist
- Access Control: If they’re not on the list, the transaction fails
Why Use This?
This prevents malicious users from manipulating external contract data through Rules Engine policies. It’s especially important for contracts that store state data that gets updated by the Rules Engine.Setting Up a Permissioned Foreign Call
Step 1: Inherit the Admin Contract
Your contract must inherit fromRulesEngineForeignCallAdmin
(available in the forte-rules-engine npm package):
Step 2: Mark Functions as Permissioned
After deployment, callsetForeignCallAdmin()
on your contract:
Step 3: Manage the Allowlist
The Foreign Call Admin can manage who can use this function:- Add users:
addAdminToPermissionList()
- Update list:
updatePermissionList()
- Remove all:
removeAllFromPermissionList()
Understanding the Foreign Call Admin Role
The Foreign Call Admin is the gatekeeper for a permissioned foreign call.Key Responsibilities
- Single Admin: Each permissioned foreign call has no more than one Foreign Call Admin
- Multiple Contracts: One address can be Foreign Call Admin for multiple different contracts
- Transferable Role: The admin role can be transferred to another address (requires acceptance)
- Policy Control: Only the Foreign Call Admin can decide which Policy Admins can use this foreign call
Role Transfer Process
- Current admin initiates transfer
- New admin must accept the role
- Transfer completes only after acceptance