Pointer

A "pointer" is a connection between two parameters of different plugin instances. It represents a flow of data from one parameter (usually an output parameter) to another input parameter. A pointer can be used to link the output of one plugin to the input of another, allowing for data to be passed between them.

To understand the concept of a pointer, let's look at how it is used in the code.

In the Param class there's a method named set which takes a value. If the value is a WrappedParam (i.e., an output / an instance of Param), the code creates a pointer between the two parameters by calling fct.addPointer()

The addPointer method defined in the FCTGraph class creates a connection (an edge) in the graph between two plugin instances

Here's an example showing how a pointer is created:

Creating a pointer

  1. First, we create a new FCTGraph instance:

const fct = create();
  1. Next, we add two plugin instances to the FCTGraph:

const getMyKiroBalance = fct.add(ERC20.getters.BalanceOf, {
  to: KIRO,
  methodParams: {
    owner: MY_WALLET,
  },
});

const sendAllKiroToBob = fct.add(ERC20.actions.Transfer, {
  to: KIRO_ADDR,
  methodParams: {
    amount: getMyKiroBalance.outputs.balance,
    to: BOB_WALLET_ADDR,
  },
});
  1. In the sendAllKiroToBob plugin instance, we set the amount parameter to getMyKiroBalance.outputs.balance. This creates a pointer between the balance output parameter of the getMyKiroBalance plugin instance and the amount input parameter of the sendAllKiroToAsaf plugin instance.

Removing a pointer

When the FCTGraph is compiled and executed, the value of the balance parameter from the getMyKiroBalance plugin instance will be passed as the amount parameter for the sendAllKiroToAsaf plugin instance.

Last updated