After checking the ERC20 Transfer Plugin documentation, we can determine that the transfer plugin requires 3 parameters - to (token address), methodParams.recipient (who receives the tokens), and methodParams.amount (how many tokens to send)
Another way to get the required parameters is by calling:
constparams=transfer.input.get()
Set parameters to ERC20 Transfer plugin
There are 2 ways to set parameters for plugins.
The first way is by calling transfer.input.set function
transfer.input.set({ to:"0xB1191F691A355b43542Bea9B8847bc73e7Abb137",// KIRO Address methodParams: { recipient:"0x...",// Address, which is going to receive the tokens amount:"10"+"0".repeat(18) // Sending 10 tokens. (10 + 18 decimals) }})
The second way is by calling each parameter separately
Once we have BatchMultiSigCall constructed, now we can add the plugin to BatchMultiSigCall class by calling create() function
awaitbatchMultiSigCall.create({ plugin: transfer, from:"0x...",// Here we put the vault address, from whom the transfer will happen nodeId:"ERC20_Transfer"})
Now we have an FCT that is ready to be exported!
constFCT=awaitbatchMultiSigCall.exportFCT()
Congratulations, you built your first FCT!
Full code example
import { BatchMultiSigCall } from"@kirobo/fct-core"import { ERC20 } from"@kirobo/fct-plugins"consttransfer=newERC20.actions.Transfer({ chainId:1,})transfer.input.set({ to:"0xB1191F691A355b43542Bea9B8847bc73e7Abb137",// KIRO Address methodParams: { recipient:"0x...",// Address, which is going to recieve the tokens amount:"10"+"0".repeat(18) // Sending 10 tokens. (10 + 18 decimals) }})constbatchMultiSigCall=newBatchMultiSigCall({ provider:newethers.providers.JsonRpcProvider("..."), chainId:1,})awaitbatchMultiSigCall.create({ plugin: transfer, from:"0x...",// Here we put the vault address, from whom the transfer will happen nodeId:"ERC20_Transfer"})constFCT=awaitbatchMultiSigCall.exportFCT()// Use FCT.typedData to sign on to the FCT. If you are using @metamask/eth-sig-util// to sign on EIP712 transaction, this is an example of how to sign on to the FCTimport { signTypedData, SignTypedDataVersion } from"@metamask/eth-sig-util";constsignature=signTypedData({ data:FCT.typedData, privateKey:Buffer.from(key,"hex"), version:SignTypedDataVersion.V4})