- Inject the Claimr widget dynamically.
- Pass wallet signatures to Claimr without reconnecting.
- Respond to Claimr widget events for blockchain interaction.
src/claimr_wrapper.tsx: Handles Claimr widget injection.src/wagmi.ts: Sets up wallet connections and providers.src/example_app.tsx&src/main_page.tsx: The main app UI.
- Node.js (v18+ recommended)
- npm or Yarn
Run the project
Open a terminal and follow the steps below.1
Navigate to your project directory
2
Install dependencies
Using npm:Using Yarn:
3
Start the development server
Using npm:Using Yarn:
4
Visit your app
Open
http://localhost:3000 in your browser.Build for production (optional)
To create a production-ready build:build/ folder.
Claimr widget integration
TheClaimrWrapper component is responsible for injecting the Claimr widget script into the application. This ensures the widget is loaded dynamically and configured appropriately for your dApp environment.
Script source:
data-container), which organization and campaign to load, what feature add-ons are enabled, and that it’s running in a dApp context.
The widget script is injected only once per session to avoid duplication.
App bootstrapping (example_app.tsx)
The widget is used within a fully Web3-enabled app context, including support for wallet connections, data fetching, and blockchain interaction. The main provider hierarchy looks like this:WagmiProvider: Wallet and blockchain interaction support.QueryClientProvider: Enables data fetching via React Query.RainbowKitProvider: Wallet UI and modal handling.ClaimrWrapper: Injects and initializes the Claimr widget.
MainPage now have access to both the wallet and the Claimr widget.
Wallet integration (wagmi.ts)
The app uses:@rainbow-me/rainbowkitfor wallet modal & connection managementwagmifor Ethereum interaction abstraction
- Ethereum Mainnet
- Sepolia testnet
- Arbitrum Sepolia testnet
projectId comes from WalletConnect (required by RainbowKit).
Connecting external wallets to the Claimr widget
The Claimr widget does not manage the wallet directly. Instead, it relies on the host app to pass signed wallet data for authentication.Two-way integration
- Wallet management (connect/disconnect, sign, etc.) is handled via wagmi + RainbowKit.
- The Claimr widget uses SDK methods and browser events to communicate with the wallet context.
window.claimr.connect_wallet(address, signature, message)
This function is called after the user signs a message with their wallet:address: user’s wallet address (fromwagmi.useAccount())signature: result fromsignMessageAsync()message: custom nonce + timestamp message (fromget_sign_message())
window.claimr.on_request = async (...) => { ... }
Set during widget::ready:
on_request function handles:
- Switching chains if needed (
switchChainAsync) - Calling a contract method with
abi,contract,method,args, andchain_id - Returning the transaction hash back to Claimr
Example flows
When the user opens the app:- React app loads.
ClaimrWrapperinjects the widget.- If
localStorage['demo-signature']exists, it’s reused. - Otherwise, the app shows a “Connect wallet → Sign in” prompt.
signMessageAsync()signs a claimr-auth message.- The signature is saved in
localStorage. window.claimr.connect_wallet(...)is called to complete login.
- The widget emits a
widget::readyevent. - Your app assigns the
on_requesthandler. - Claimr can now ask your app to switch chains or execute contract calls.
Campaign configuration: required settings
To ensure the Claimr widget works correctly with your dApp, configure the campaign settings accordingly.1
Navigate to Sign-in options
Open your Claimr dashboard, go to your specific campaign, click Settings in the left-hand menu, then select Sign-in options.

2
Set the sign-in parameters
- Require login to start a task: Ensures that users must log in (e.g., via wallet) before they can begin any task. This is necessary for Claimr to associate actions with an authenticated wallet address.
- Require token to start campaign (optional): If enabled, this requires a specific token to access the campaign.
- Wallet change is disabled (optional): Prevents users from switching wallets mid-session.
- Disable users merge (optional): Disables automatic merging of user identities across sign-in methods.
3
Configure wallet sign-in
Select Wallet to allow wallet-based login in the Select sign-in services field, select the correct blockchain in the Chains field, and in the Wallet message field, enter a custom message that will be shown to users during wallet signature to identify the purpose of signing.