User Management
Methods for registering users and retrieving user information.create
Creates a new instance of the CeloRefer SDK.Parameters
| Name | Type | Description |
|---|---|---|
| chain | Chain | The Celo chain to connect to (e.g., celoAlfajores) |
| walletClient | WalletClient | Viem wallet client with account |
Returns
CeloReferSDK - New SDK instance.
Example
registerUser
Registers a new user in the CeloRefer system with a referral code.Parameters
| Name | Type | Description |
|---|---|---|
| referralCode | string | Referral code of the referring user |
Returns
Hex - Transaction hash of the registration.
Example
registerGenesisUser
Registers a new user as a genesis user (first user with a custom code).Parameters
| Name | Type | Description |
|---|---|---|
| customCode | string | Custom referral code for the genesis user |
Returns
Hex - Transaction hash of the registration.
Example
getUserInfo
Retrieves detailed information about a user.Parameters
| Name | Type | Description |
|---|---|---|
| userAddress | Address | Address of the user |
Returns
UserInfo object containing user details.Example
getUserStats
Gets statistics for a user.Parameters
| Name | Type | Description |
|---|---|---|
| userAddress | Address | Address of the user |
Returns
UserStats object containing user statistics.Example
getBadgeTier
Gets the badge tier for a user.Parameters
| Name | Type | Description |
|---|---|---|
| userAddress | Address | Address of the user |
Returns
number - Badge tier (0-3 for Bronze, Silver, Gold, Platinum).
Example
getReferralCode
Gets the referral code for a user.Parameters
| Name | Type | Description |
|---|---|---|
| userAddress | Address | Address of the user |
Returns
string - Referral code for the user.
Example
generateReferralLink
Generates a referral link for sharing.Parameters
| Name | Type | Description |
|---|---|---|
| referralCode | string | Referral code to include in the link |
Returns
string - Complete referral link.
Example
getBadgeInfo
Gets information about a specific badge tier.Parameters
| Name | Type | Description |
|---|---|---|
| tier | number | Badge tier (0-3) |