This guide focusses on the most common patterns of interactions with the Bounty Manager Module. Please refer to the Technical Reference section to see all public getters and setters.
Managing Bounty Manager Roles
Managing roles for the Bounty Manager involves several steps, including reading role, generating role IDs, assigning roles, and revoking them.
Retrieving the roles
The Bounty Manager utilizes several roles to handle the issuance, verification, and claiming of bounties. The first step is to retrieve the available roles in the Bounty Manager, as demonstrated below:
The following two-step process validates whether a given address has roles assigned to it:
// Step 1. Generate the role ids
const [GEN_VERIFIER_ROLE, GEN_BOUNTY_ISSUER_ROLE, GEN_CLAIMANT_ROLE] =
await Promise.all(
[VERIFIER_ROLE, BOUNTY_ISSUER_ROLE, CLAIMANT_ROLE].map((id) => {
return workflow.authorizer.read.generateRoleId.run([
workflow.optionalModule.LM_PC_Bounties_v1.address,
id,
])
})
)
// Step 2. Check if the user has the role
const [HAS_VERIFIER_ROLE, HAS_BOUNTY_ISSUER_ROLE, HAS_CLAIMANT_ROLE] =
await Promise.all(
[GEN_VERIFIER_ROLE, GEN_BOUNTY_ISSUER_ROLE, GEN_CLAIMANT_ROLE].map(
(genId) => {
return workflow.authorizer.read.hasRole.run([
genId,
<wallet_address>,
])
}
)
)
Grant and Revoke Role
The following section demonstrates how to grant and revoke roles for a wallet address.
const walletAddress = sdk.walletClient.account.address
const args = [
<VERIFIER_ROLE | BOUNTY_ISSUER_ROLE | CLAIMANT_ROLE>,
walletAddress
] as const
// Grant role
const grantRoleTransactionHash = await workflow.optionalModule.LM_PC_Bounties_v1.write.grantModuleRole.run(args)
// Revoke role
const revokeRoleTransactionHash = await workflow.optionalModule.LM_PC_Bounties_v1.write.revokeModuleRole.run(args)
Bounty Creation
Add a Bounty
The following section explains how to add a bounty to the Bounty Manager:
import { decodeEventLog } from 'viem'
import { getModuleData } from '@inverter-network/abis'
let bountyId = string
const bounty = [
// Minimum Payment Amount
'1000',
// Maximum Payment Amount
'10000',
// Details ( type any )
{
timestamp: 1734448333
message: 'hello'
}
] as const
const addBountyTransactionHash =
await workflow.optionalModule.LM_PC_Bounties_v1.write.addBounty.run(bounty, {
confirmations: 1,
// !Optional! You can get the list of bounty id's from a different endpoint
onConfirmation: (receipt) => {
// Define the ABI for the BountyAdded event
const BountyAddedAbi = [
getModuleData('LM_PC_Bounties_v1').abi.find(
(i) => i.name === 'BountyAdded'
),
]
// Decode the logs using the ABI
const decodedLogs = decodeEventLog({
abi: BountyAddedAbi,
data: receipt.logs[0].data,
topics: receipt.logs[0].topics,
})
// Retrieve the bountyId from the decoded logs
bountyId = decodedLogs.args.bountyId.toString()
},
})
Add Bounty in Batches
The following section explains how to add multiple bounties in batches
The guide includes code snippets for Inverter Network's TypeScript SDK. Please refer to the relevant code snippets based on the SDK you are using.
Set up Inverter Network SDK: Refer to the Quick Start guides for detailed instructions. See the React SDK Guide or TypeScript SDK Guide for more information.
Deploy a Workflow: Refer to the Deploy a Workflow guide for detailed instructions. See the React SDK Guide or TypeScript SDK Guide for more information.
Retrieve a deployed Workflow: Refer to the Operate a Workflow guide for detailed instructions. See the React SDK Guide or TypeScript SDK Guide for more information.
Optionally if your setup needs a specific contract: Refer to the Deploy a Contract Guide for detailed instructions. See the React SDK Guide or TypeScript SDK Guide for more information.