0.2.32 • Published 1 month ago

tide-sdk v0.2.32

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

Tide Button SDK

Version

The Tide Button SDK is an embeddable button that can be added to any website to check eligibility for a specific Tide campaign, perform some tasks, and mint a Participation Badge. This SDK is designed to be integrated into React projects and provides a convenient way to engage with Tide campaigns.

Features

  • Check eligibility for a specific Tide campaign.
  • Perform one or more tasks and mint an NFT badge with just one click. Only Web3 and Gitcoin tasks are currently supported.
  • One simple React component for easy integration.

Getting Started

1. Install the tide-sdk npm package

First, you need to install the tide-sdk npm package as a dependency in your project. You can do this using npm or yarn, depending on your preference. Open your project directory in the terminal and run one of the following commands:

Using npm:

$ npm install tide-sdk

Using yarn:

$ yarn add tide-sdk

2. Import and use the TideButton component:

Once the package is installed, you can import and use the TideButton component in your React application. Here's an example of how to do it:

import React from 'react';
import { TideButton, SdkError } from 'tide-sdk';

function App() {
  // You need to provide a JSON RPC signer and a campaign ID to the `TideButton` component.
  // The `signer` should be an instance of `JsonRpcSigner` from the `ethers` package.
  // The `campaignId` is a string representing the campaign you want to claim. You can find the `campaignId` at the end of the campaign URL.
  // example: https://www.tideprotocol.xyz/users/campaign/d3b784db-4c10-4cca-b4f6-fca203f11b3c => `campaignId` = 'd3b784db-4c10-4cca-b4f6-fca203f11b3c'

  const signer = /* Your `JsonRpcSigner` instance */;
  const campaignId = /* Your `campaignId` as a string */;
  const onError = (error: SdkError) => {
    // Handle possible errors such as 'Campaign not deployed yet.' here"
    console.error('SDK Error:', error);
  };

  return (
    <div className="App">
      {/* Render the `TideButton` component */}
      <TideButton signer={signer} campaignId={campaignId} onError={onError} />
    </div>
  );
}

export default App;

3. Handling Errors:

The onError callback function is provided to handle errors that may occur during the interaction with the Tide SDK. You should implement error-handling logic within a separate function to provide feedback to users when errors occur. The function parameter type is described in SdkError:

(error: { code: string; message: string }) => void

Errors are mapped to the following:

Error CodeMessage
C01Campaign not deployed yet.
C02Campaign not found.
G01Enviroment variable not set.
G02Chain not found.
G03Address not found.
G04Verifier private key not found.
R01Not part of any eligible audiences.
R02Reward has already claimed.
R03Signature generation failed
R04Generic error: could not claim reward
T01Task not found.
T02Task platform not found.
GT01Gitcoin task not found.
GT02Passport score too low.
NET01Wrong network error.
WT01NFT holding task not found.
WT02Token ID not found.
WT03Invalid NFT type.
WT04Your wallet is not holding the correct NFT.
WT05No interaction found, if you have done the task, please wait a minute and try again.
WT06The parameter bound to this event was not found.
WT07The operator bound to this advanced setting not found.
WT08None of your interactions satisfy the required parameters.
WT09Fetch to https://coins.llama.fi didn't return any data
WT10An interaction was found, but the USD value of the transaction was too low
WT11Invalid configuration for cumulative track event task. Good web3 task not found.
WT12Invalid configuration for cumulative track event task. Good cumulative advanced setting value is not a number
WT13An interaction was found, but the threshold has not been reached .
WT14Invalid configuration for cumulative track event task. Bad cumulative advanced setting not found
WT15Invalid configuration for cumulative track event task. Bad cumulative advanced setting value is not a number.
WT16Your interaction was invalidated by an action you took, please complete the task again
WT17The Web3 task bound to this task was not found.
WT18Your wallet does not hold the required token
WT19Your wallet does not hold enough tokens to complete this task.
WT20ProtocolTransactionTask not found
WT21Your wallet has not made enough transactions to complete this task.
WT22Expected parameters.
WT23An interaction was found, but not enough time has passed.
WT24Your interaction was invalidated by an action you took

Conclusions

That's it! With these steps, you can integrate the TideButton component into your React application and enable users to claim campaigns on the Tide Protocol with just one click.

0.2.32

1 month ago

0.2.31

1 month ago

0.2.29

2 months ago

0.2.27

6 months ago

0.2.25

6 months ago

0.2.24

6 months ago

0.2.23

6 months ago

0.2.22

6 months ago

0.2.21

6 months ago

0.2.20

6 months ago

0.2.19

6 months ago

0.2.17

6 months ago

0.2.16

6 months ago

0.2.15

6 months ago

0.2.14

6 months ago

0.2.13

6 months ago

0.2.28

5 months ago

0.2.10

6 months ago

0.2.1

6 months ago

0.2.0

6 months ago

0.2.7

6 months ago

0.2.6

6 months ago

0.2.9

6 months ago

0.2.8

6 months ago

0.2.3

6 months ago

0.2.2

6 months ago

0.2.5

6 months ago

0.2.4

6 months ago

0.1.1

11 months ago

0.1.0

12 months ago