Earn Page
Ready-made component for earning rewards
Earn Page is a ready-made component that allows users to earn rewards by connecting their wallets and interacting with DeFi partners.
Showcase
Live showcase of an Earn Page implementation
Wizard
Customize your Earn Page with our interactive wizard
Overview
The EarnPage
component uses provided APIs to fetch partners and display them.
You need to provide user
so that the component can fetch the user’s join status.
If the user has not joined, it prompts them to sign up for Turtle.
If no user is provided, it will prompt a login modal.
Installation
If you haven’t already, install the dependencies using the following guide:
Get Started
Get Started with the Typescript SDK
Usage Example
Adapter
We provide an adapter for Wagmi, since it’s the most popular React-based library for interacting with the blockchain. We use Wagmi at Turtle.club, so we can also recommend it as the best choice for your project.
If you want to use a different library, you can implement your own adapter. You will still have to plumb in your own wallet connection modal, as is shown in the example above.
Props
User’s wallet address (undefined if not connected)
Referral code
Optional campaign identifier for tracking specific campaigns
Network to use (extends number)
Header configuration object
Function to open the wallet connection modal
Function to change the network: (network: Network) => Promise<void>
Function to sign the message for wallet authentication: (message: string) => Promise<string>
Function to send a transaction: (transaction: Transaction<Network>) => Promise<string>
Optional callback triggered when signing process starts
Optional error handler: (error: Error) => void
Optional success callback
Types
Transaction Interface
EarnPageProps Interface
Theming
Using the TurtleProvider
The EarnPage component must be wrapped in a TurtleProvider
to apply theming.
We recommend wrapping somewhere in your app, like in App.tsx
, but you can wrap it in any component.
Theme Configuration
The themeConfig
prop accepts a TurtleThemeConfig
object with the following structure:
Default Theme
The default theme configuration is as follows:
How it Works
- The EarnPage component fetches available partners and deals
- It checks if the user has joined Turtle using the provided wallet address
- If not joined, it prompts the user to sign a message to join
- Once joined, users can access partner deals with boosted rewards
- The component handles all states: loading, empty results, and listing deals
By providing the necessary authentication functions, the EarnPage component handles the entire flow from wallet connection to deal redemption.