Page cover

SDK

Use SDK to integrate ⚡️claimr into your web application, customize its behavior, and create a more engaging and rewarding user experience.

SDK (Software Development Kit) is a powerful tool that integrates claimr's functionalities into your web application. It provides a set of methods and events that enable you to interact with the claimr widget, customize its behavior, and enhance the user experience.

Methods

complete_task(task_id)

This method allows you to mark a task as complete directly from your web application's front-end. This is useful for tasks that are completed outside of the claimr widget, such as watching a video or visiting a specific page on your website.

  • The task_id parameter should be the unique identifier of the task you want to complete, which can be found in your claimr admin panel.

This method should only be used for tasks that are configured as "Front End" type in your claimr campaign settings.

connect_wallet(address, signature, message)

This method enables users to sign in to your claimr campaign using their web3 wallet credentials.

  • The address parameter should be the user's wallet address.

  • The signature parameter should be the cryptographic signature generated by the user's wallet.

  • The message parameter should be the message that was signed by the user's wallet.

destroy()

This method removes the claimr widget instance from your web page.

get_user_info(campaign_id, public_key, account, platform)

This method retrieves information about a specific user from your claimr campaign using the public API.

  • The campaign_id parameter should be the unique identifier of your campaign.

  • The public_key parameter should be the public key generated in your campaign's general settings.

  • The account parameter should be the user's account identifier. For web3 wallet addresses, use the address in lowercase.

  • The platform parameter should be the platform identifier. For web3 wallets, use "web3".

login()

This method triggers the login dialog within the claimr widget, allowing users to sign in to their claimr account.

logout()

This method logs the user out of their claimr account within the widget.

open_quest(quest_id)

This method opens a specific quest within the claimr widget.

  • The quest_id parameter should be the unique identifier of the quest you want to open, which can be found in your claimr admin panel.

set_theme(theme)

This method allows you to set the theme of the claimr widget if supported by your CSS.

  • The theme parameter should be a string representing the desired theme.

set_user_token(token)

This method sets the user token generated by the claimr API. This token is used to associate a user's actions within the claimr widget with their account on your platform.

  • The token parameter should be the user token generated by the API. Refer to the claimr API documentation for details on generating user tokens.

Events

on_contest_open

This event is fired when a user opens any quest within the claimr widget.

on_custom_login

This event is fired when a user logs in using the "custom" sign-in option.

on_logout

This event is fired when a user logs out of their claimr account within the widget.

Parameters

user

This parameter contains information about the currently logged-in user, such as their user ID, name, and email address.

Last updated

Was this helpful?