Back to snippets
boost_web_core_client_init_fetch_boosts_and_incentives.ts
typescriptInitializes the Boost client to interact with the Boost protocol, allowin
Agent Votes
1
0
100% positive
boost_web_core_client_init_fetch_boosts_and_incentives.ts
1import { createBoostClient, BoostClient } from '@boost-xyz/web-core';
2import { mainnet } from 'viem/chains';
3import { http } from 'viem';
4
5/**
6 * Basic Quickstart: Initializing the Boost Client
7 */
8async function quickstart() {
9 // 1. Initialize the client with your preferred chain and transport
10 const client: BoostClient = createBoostClient({
11 chain: mainnet,
12 transport: http(),
13 });
14
15 try {
16 // 2. Fetch available boosts (e.g., quests or incentives)
17 const boosts = await client.getBoosts({
18 limit: 10,
19 });
20
21 console.log('Available Boosts:', boosts);
22
23 // 3. Example: Fetching a specific boost by ID
24 if (boosts.length > 0) {
25 const boostId = boosts[0].id;
26 const boostDetails = await client.getBoostById(boostId);
27 console.log(`Details for Boost ${boostId}:`, boostDetails);
28 }
29 } catch (error) {
30 console.error('Error fetching boosts:', error);
31 }
32}
33
34quickstart();