LogoLogo
$THX tokenDiscord Community
  • THX Network
  • 🏗️Campaign Managers
    • Getting Started
    • Analytics
    • Quests
      • Daily Quests
      • Invite Quests
      • Twitter Quests
      • Discord Quests
      • Custom Quests
      • Web3 Quests
      • Webhook Quests
      • Steam Quests
      • Quest Locks
    • Rewards
      • Coin Rewards
      • NFT Rewards
      • Custom Rewards
      • Coupon Rewards
      • Discord Role Rewards
    • Participants
    • Integrations
      • Discord
      • Twitter, now X
      • Gitcoin Passport
    • Coins
    • NFT
  • 🧑‍🤝‍🧑USERS
    • Memberships (Free)
    • Lottery (Free)
  • 💡FAQ
    • Pricing
    • Multi Wallet Account
    • Points
    • Other
  • 💻Developers
    • HTML Widget
    • JS SDK
      • Identity
      • Events
    • API
      • API Specification
      • Example
    • Webhooks
    • QR codes
    • Audits
  • 🪙Tokenomics
    • $THX
    • Locking $THX to $veTHX
    • Increasing Locked $veTHX
    • Protocol
    • Token Distribution
  • 🤝ABOUT
    • Team
    • One Pager
    • Community
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. API

Example

Using the new and improved authentication method one can build their own campaign UI.

Example SDK usage to demonstrate required effort:

  • registering a user

  • authenticating that user

  • listing quests

  • completing a quest

Backend:

const thx = new THXAPIClient({
  clientId: '<CREATE_IN_DASHBOARD>',
  clientSecret: '<CREATE_IN_DASHBOARD>',
});

const identity = await thx.identity.create();
// Identity: e7f32a71-33ea-418e-9d80-32b6bf6405f0

Front-end:

const thx = new THXIdentityClient({
  clientId: '<CREATE_IN_DASHBOARD>',
  clientSecret: '<CREATE_IN_DASHBOARD>',
});

// Authenticate a specific user using his identity code
thx.setIdentity('e7f32a71-33ea-418e-9d80-32b6bf6405f0');

// List available daily quests for your campaign 
// and get the ID of the first quest
const { daily } = await thx.quests.list();
const questId = daily[0].id;
await thx.quests.daily.entry.create(questId);

// Get campaign participation info for authenticated user 
// and show point balance
const { balance } = await thx.request.get('/v1/participants');
// Balance: 10 points

Last updated 9 months ago

Was this helpful?

💻