Badges
This API documentation provides details of the Badges smart contract that has been deployed on the Polygon network.
The Badges contract allows KUTHULU to manage a set of badges which can be issued to users based on their participation and achievements. Badges can be added, removed and verified based on certain conditions set by the application admins.
Badges can be awarded via calls from KUTHULU or self-verification if the badge has an allowedAddress
set to a smart contract of any ERC-20 or ERC-721 token. When a user verifies their address, the smart contract will call out to the connected token smart contract to get the balance of the users ERC-20 or ERC-721 tokens and verify that they own at least the minimum required that is setup when creating the badge. The token smart contract can also deploy the optional kuthuluVerifyBadgeType()
function should multiple badges be awarded from a single smart contract. See Amulets smart contract for code examples.
Table of Contents
External Contract Functions
These functions are designed to interact with the Badges smart contract from external sources.
addBadgeToUser
This function allows admins or allowed addresses to add a badge to a user.
userAddress
address
Wallet address of the user to add the badge to.
badgeID
uint256
The badge ID.
Returns: This function does not return a value.
Example usage with ethers.js:
removeBadgeFromUser
This function allows admins or allowed addresses to remove a badge from a user.
userAddress
address
Wallet address of the user to remove the badge from.
badgeID
uint256
The badge ID.
Returns: This function does not return a value.
Example usage with ethers.js:
Public Functions
These functions can be called by any user and are designed to interact with the Badges smart contract internally.
verifyBadge
This function allows a user to verify if they qualify for a badge.
badgeID
uint256
The badge ID to check to see if they qualify to be added.
Returns: This function does not return a value.
Example usage with ethers.js:
getUserBadges
This function returns a list of user's badge IDs.
userAddress
address
The address of the user to get badges for.
Returns: Array of badge IDs (uint256[]).
Example usage with ethers.js:
getBadgeDetails
This function retrieves the details of a badge.
badgeID
uint256
The ID of the badge to get the details for.
Returns: Array of badge details (string[]).
Example usage with ethers.js:
getBadges
This function retrieves a list of all the available badge IDs.
None
Returns: Array of badge IDs (uint256[]).
Example usage with ethers.js:
kuthuluVerifyBadgeType Example
This code example is pulled from the Amulets contract. This will verify that an address owns a specific badge type that is associated with their tokens.
Last updated