Summary

The Foreign Call Protocol (FCP) facilitates the ability for SmartWeave contracts to behave inter-operably by invoking functions from other contracts that support FCP.

Background

The lack of interoperability between Arweave-based smart contracts has widely been considered a limiting factor to what developers can build with SmartWeave. It forced smart contract developers to design mechanisms that could not utilize or interface with external, existing mechanisms. The FCP removes this restriction.

Proposed Solution

Logic Flow

  1. User sends a nested contract interaction transaction for contract A to contract B by calling its invoke function.
  2. User sends a contract interaction transaction to contract A invoking its readOutbox function

Requirements

The FCP allows for two-way communication between SmartWeave contracts on Arweave. In order to facilitate this, contracts need two new arrays in their states and two new functions in their sources:

State modifications

Contract source modifications

Example Code

See two example contracts that successfully utilized the Foreign Call Protocol: ABC and DEF.