Quick Start

Installation

To install the SDK, use your preferred package manager from the command line. For example, if you use npm, execute the following command:

bun add @inverter-network/sdk

~ or ~

npm install @inverter-network/sdk

Initializing the SDK

Import the class and pass the parameters and initialize the class instance

import { Inverter } from '@inverter-network/sdk'

const sdk = new Inverter({publicClient, walletClient})

Deploying Your First Workflow

Retrieve the Deployment Functions

To deploy your initial workflow, you will need to retrieve the deployment functions like so:

import { RequestedModules } from '@inverter-network/sdk'

const { getDeploy } = sdk

// Should either be `as const` or be passed dirrectly in the `estimateGas`, `run` or `simulate` function args
const requestedModules = {
    fundingManager: 'FM_DepositVault_v1',
    paymentProcessor: 'PP_Simple_v1',
    authorizer: 'AUT_Roles_v1',
    optionalModules: [
        'LM_PC_Bounties_v1', 'LM_PC_RecurringPayments_v1'
    ]
} as const satisfies RequestedModules

const { inputs, estimateGas, run, simulate } = await getDeploy({
    requestedModules
})

Deploying the Workflow

After setting up your deployment with the getDeploy function, you can proceed to deploy the workflow with the specified modules through calling the run function, passing the configuration arguments like so:

// Should either be `as const` or be passed dirrectly in the `estimateGas`, `run` or `simulate` function args
const args = {
    orchestrator: {
        independentUpdates: true,
        independentUpdatesAdmin: "0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF",
    },
    fundingManager: {
        orchestratorTokenAddress: "0x5eb14c2e7D0cD925327d74ae4ce3fC692ff8ABEF",
    },
    authorizer: {
        initialAdmin: "0x7AcaF5360474b8E40f619770c7e8803cf3ED1053",
    },
    optionalModules: {
        LM_PC_RecurringPayments_v1: {
            epochLength: "70000000",
        },
    },
} as const satisfies GetUserArgs<typeof requestedModules>

const { orchestratorAddress, transactionHash } = await run(args);

Interacting with a Deployed Workflow

Retrieving a Workflow

Parameters of required orchestratorAddress and an optional worklfowOrientations the orientation is suggested to be passed for e2e typescript coverage:

const { getWorkflow } = sdk

const { 
    orchestrator, 
    authorizer,
    fundingManager,
    optionalModule,
    fundingToken
} = await getWorkflow({
    orchestratorAddress: '0x8a1897E6Fa0236F68f86240C391D2a7bED3Cf85c',
    requestedModules
});

Reading Data

You can read data from any of the modules like so ( in this example we are reading the totalSupply of the fundingToken ):

const totalSupply = await fundingToken.module.read.totalSupply.run();

Writing Data

You can write data to any of the modules like so ( in this example we are depositing to the funding manager ):

const txHash = await fundingManager.write.deposit.run('100', {
    confirmations: 1,
    onHash: (hash) => {console.log(hash)},
    onConfirmation: (receipt) => {console.log(receipt)},
    onApprove: (receipts) => {console.log(receipts)}
});

Last updated