Inter-contract calls and permissions
Focus: one proxy entry that calls another contract entry after checking call permissions.
contract_caller.slx
entry forward_call(target_hash: Hash, entry_id: u16, args: any[]) {
require(is_contract_callable(target_hash, entry_id), "tx permission blocks call")
let target: Contract = Contract::new(target_hash).expect("target contract not found")
let deposits: map<Hash, u64> = {}
target.call(entry_id, args, deposits)
return 0
}How it works
is_contract_callable(target_hash, entry_id)enforces the transaction’s contract-call permission.Contract::new(target_hash).expect(...)loads the deployed target contract.depositsis empty here so the example stays focused on the call itself.target.call(entry_id, args, deposits)invokes the selected target entry.
Invoke this contract with a wallet RPC permission value such as "all" or a specific allowlist. See Permissions for the JSON shape.
Last updated on