Skip to main content

JavaScript SDK

This sdk provides methods for interaction with lollipop api and it’s solana contracts

The SDK allows interacting with lollipop, specifically:

  1. getting user's fungible tokens.
  2. getting user's nfts
  3. preparing link/unlink transactions to a lollipop contracts

NPM LINK

TYPESCRIPT DOCS LINK

Installation

Yarn

$ yarn add @lollipop-protocol/sdk

NPM

npm install @lollipop-protocol/sdk

Usage

Lollipop API

// Create an instance of LollipopAPI class for interaction with API
import { LollipopAPI } from '@lollipop-protocol/sdk'

const userPublicKey = new PublicKey('YOUR PUBLIC KEY')
const lollipopAPI = new LollipopAPI()

const fetchedUserData = await lollipopApi.getUserData(
userPublicKey.toString()
)

const userNFTs = await lollipopApi.getUserNFTs(
userPublicKey.toString()
)

const userTokens = await lollipopApi.getUserFungibleTokens(
userPublicKey.toString()
)

Lollipop Program

// Create an instance of LollipopProgram class for interaction with contracts
import { LollipopProgram } from '@lollipop-protocol/sdk'
import { useConnection, useWallet } from '@solana/wallet-adapter-react'

const { connection } = useConnection()
const { wallet } = useWallet()

const lollipopProgram = new LollipopProgram({
connection,
wallet
})

const linkTransaction = await lollipopProgram.getLinkTransaction(
{
coldWallet,
hotWallet,
txPayer
}
)

const unlinkTransaction = await lollipopProgram.getUnlinkTransaction(
{
coldWallet,
hotWallet,
txPayer
}
)