Staking Widget

Getting Started with the Staking Widget

Welcome to the Staking Widget Integration Guide!

This guide will walk you through the steps to integrate the Staking Widget into your project, enabling your users to stake tokens directly from your platform.

Follow these steps to set up and customize the widget according to your needs.

Step 1: Prerequisites

Before you begin, make sure you have the following:

  • Access to the project’s codebase where you intend to integrate the staking widget.

  • A wallet with enough funds to deploy the pools if not already deployed.

  • Familiarity with JavaScript/TypeScript and frontend development frameworks (e.g., React, Vue).

Note: This library is written in React.

Step 2: Install the Staking Widget

To get started, you'll need to include the Staking Widget in your project. If there's a package available, you can install it using npm or yarn:

npm install @trustswap/web-widgets

or

yarn add @trustswap/web-widgets

Step 3: Widget Configuration

Import and configure the widget in your project. You need to specify the blockchain network and the addresses of the smart contracts.

import { StakingWidget } from "@trustswap/web-widgets";

const chainId = 97;
const poolAddress = "Ox";
const poolId = 1;

export default function App() {
  return (
    <StakingWidget
      chainId={chainId}
      poolId={poolId}
      stakingPoolAddress={poolAddress}
      themeConfig={{
        primaryColor: "#bf6635",
        container: "#F6F6FA",
      }}
    />
  );
}

if you want to display more than 2 widgets at the same time, you can just render an extra component:

export default function App() {
  return (
    <>
      <StakingWidget
        chainId={chainId}
        poolId={poolId}
        stakingPoolAddress={poolAddress}
        themeConfig={{
          primaryColor: "#bf6635",
          container: "#F6F6FA",
        }}
      />

      <StakingWidget
        chainId={chainId}
        poolId={poolId}
        stakingPoolAddress={poolAddress}
        themeConfig={{
          primaryColor: "#bf6635",
        }}
      />
    </>
  );
}

Step 4

There is no step 4. You can check your implementation in the browser now.

Step 5: Customize the Appearance

We use Mantine with Vanilla Extract as the styling solution. They are TypeScript-based and fully typed:

  • primaryColor: Primary color of the widget, would affect the button and segmented control colors.

  • container : Color of the base element of the widget. In hex format.

  • button : Styling for the button component, which is a CSSProperty.

  • segmentedControl : Styling for the Segmented Control. Same with buttons.

Otherwise, you can use your own CSS file and override the styling with class / id selectors.

Step 6: Deploy and Test

Finally, deploy your application and test the integration thoroughly to ensure that all functionalities, such as staking, unstaking, and claiming rewards, are working as expected. Monitor the interactions and transactions to address any issues promptly.

This guide provides a clear path for developers to integrate the Staking Widget into their projects, empowering users to engage with staking functionalities seamlessly.

Adjust the instructions as necessary to fit the specific needs or technical specifics of your widget or deployment environment.

Last updated