Set up Inverter Network SDK: Refer to the guide for detailed instructions.
Retrieve workflow simulation (optional): If you are going to batch the workflow deployment itself you can retrieve the preliminary data from .
Inverter has a module multicall provider called trustedForwarder which enables developers to batch write calls for inverter managed contracts.
Executing Module Multicall
In this section we will use a already deployed workflow to showcase the execution.
Parameters
trustedForwarderAddress | orchestratorAddress (required):
This parameter is used to locate the batcher.
calls(required):
These parameters are the metadata of the bathed write functions.
import { sdk } from '<your_sdk_export>'
import type { MixedRequestedModules } from '@inverter-network/sdk'
const { getWorkflow, moduleMulticall } = sdk
const deployer = sdk.walletClient.account.address
const TOTAL_DEPOSIT_AMOUNT = '1000'
// Should either be `as const` or be passed dirrectly in the `requestedModules`
const requestedModules = {
fundingManager: 'FM_DepositVault_v1',
paymentProcessor: 'PP_Simple_v1',
authorizer: 'AUT_Roles_v1'
} as const satisfies MixedRequestedModules
const workflow = await getWorkflow({
orchestratorAddress: '0x8a1897E6Fa0236F68f86240C391D2a7bED3Cf85c',
requestedModules,
fundingTokenType: 'ERC20Issuance_v1'
})
// We will first mint the TOTAL_DEPOSIT_AMOUNT
await workflow.fundingToken.module.write.mint.run([deployer, TOTAL_DEPOSIT_AMOUNT])
// Now we will call deposit twice in one transaction
// NOTE: The bytecode run will handle the needed 2 approves, if you want to handle it yourself, pass in the skipApprove method option at the second index of the params `{skipApprove: true}`
const { returnDatas, statuses, transactionHash } =
await sdk.moduleMulticall.write(
{
orchestratorAddress: workflow.orchestrator.address,
calls: [
{
address: workflow.fundingManager.address,
allowFailure: false,
callData: await workflow.fundingManager.bytecode.deposit.run('500')
},
{
address: workflow.fundingManager.address,
allowFailure: false,
callData: await workflow.fundingManager.bytecode.deposit.run('500')
}
],
}
)