getModule
The getModule
method is the most basic way to get the interact-able contract instance for a given module.
Parameters: an object with the following properties
{
// the name of the module smart contract
name: ModuleName
// the address of the deployed module
address: `0x${string}`
// the public client or provider to make RPC calls
publicClient: PublicClient
// the wallet client to sign and submit transactions
walletClient: WalletClient
extras?: {
// the number of decimals of the issuance token of the funding manager
decimals?: number
// the default token of the fundingManager
defaultToken?: `0x${string}`
}
}
Returns: a Module
object with the following properties
{
// the name of the module smart contract
name: ModuleName
// the address of the deployed module
address: `0x${string}`
// the type of the module (e.g. authorizer)
moduleType: ModuleType
// short description of the module taken from the contract NatSpec documentation
description: string
read: {
[functionName: string]: {
// name of the function
name: string
// description of what the function does taken from NatSpec
description: string
inputs: FormattedAbiParameter[]
outputs: FormattedAbiParameter[]
// an asynchronous function that whose parameters are of type `inputs` and return values are of type `outputs`
run: (args: GetMethodArgs) => Promise<GetMethodResponse>
}
}
simulate: // same as read ...
write: // same as read ...
}
Example:
import { getModule } from '@inverter-network/sdk'
const {
name,
address,
moduleType,
description,
read,
simulate,
write
} = getModule({
name: 'LM_PC_Bounties_v1',
address: '0xa23D85d8FE256a8a1eE92a6d5Ec156a8a21DCdaE',
publicClient,
walletClient,
extras: {
decimals: 18,
},
})
// write function changes the state of the smart contract
const txHash = await module.write.addBounty.run([
'100',
'1000',
['this is an inverter project'],
])
// read function gets some value(s) from the smart contract
const bountyIds = await module.read.listBountyIds.run()
Last updated