buddy.drops
v0.1.1
Published
[![npm version](https://badge.fury.io/js/buddy.drops.svg)](https://badge.fury.io/js/buddy.drops) ![NPM License](https://img.shields.io/npm/l/buddy.drops) [![Static Badge](https://img.shields.io/badge/twitter-BuddyLinkApp-blue?logo=x&logoColor=white)](http
Downloads
2
Readme
Buddy.Drops SDK
The official typescript SDK for Buddy.Drops by Buddy.Link!
This package contains infrastructure and helpers for using Buddy Drops for raffle launches.
How to use
1) Install Package
Use the command npm i buddy.drops
to install the package as a dependency.
2) Setup the initial state
In your layout.tsx or highest app layer file, import the initBuddyDrops()
function with:
import { initBuddyDrops } from 'buddy.drops'
Within global scope (outside of the component) simply run
initBuddyDrops();
You will then be able to access to hook within any component.
3) useBuddyDrops hook
You can use the main hook within any subcomponent to get the data you need with:
import { useBuddyDrops } from 'buddy.drops'
And then proceed to use it within your component like this:
const MyComponent = () => {
const {
step, prevStep, nextStep,
phase, prevPhase, nextPhase,
timer, pause, value, rewards,
tickets, reduceValue, addValue,
buyTickets, errors, mock, sold,
inputProps, onChange, onBlur,
} = useBuddyDrops();
return (
<div>
{`Your Code Goes Here`}
</div>
)
};
Example implementations
Please visit the open-source example on Github.
Initial State
Here is an outline of what each function and state does from the useBuddyDrops hook.
step
The current step in the onboarding flow for the user. This is different from the phase
of the mint, which is where
the mint timer is at between whitelist, public sale, waiting, and claim phase.
prevStep
Use this function to go to the previous onboarding step on the front-end.
nextStep
Use this function to go to the next onboarding step on the front-end.
phase
The current phase of the public mint. The possible states are
PHASE_WHITELIST
, PHASE_PUBLIC_SALE
, PHASE_WAIT
, and PHASE_CLAIM
.
prevPhase
Use this function to decrement the front-end to the previous mint phase.
nextPhase
Use this function to increment the front-end to the next mint phase.
timer
When the mock
state is enabled, sends the remaining hour, minute, and second of the public phase.
Not currently recommended for production.
pause
When the mock
state is enabled, sends the remaining hour, minute, and seconds of the waiting phase.
Not currently recommended for production.
value
The number of tickets a person wishes to purchase.
reduceValue
Reduce the number of tickets a person would like to purchase by 1.
addValue
Increment the number of tickets a person would like to purchase by 1.
rewards
An array of rewards that the user has received during the claim phase.
tickets
The number of tickets a user has already purchased and owns.
buyTickets
Buy tickets (number in value
) which increases the number of tickets
immediately while in mock
state.
errors
An array of error objects which have a type, and a message. Things like maximum exceeded tickets, or other errors will be added here.
mock
Enabled by default for now, to disable add an object to the initBuddyDrops
function with
{[MOCK_DEBUG]: false}
which you can import from buddy.drops
.
sold
This will return the total number of tickets sold for the mint.
inputProps
Use this object in your input to simply set the value, like this:
<input {...inputProps}/>
.
onChange
Use this to manage the onChange events for your input like this:
<input onChange={e => onChange(e, min_tickets, max_tickets)}
.
onBlur
Use this to manage the onBlur events for your input like this:
<input onBlur={e => onBlur(e, min_ticketes)}
.
Additional Resources
Looking for the main SDK?
Other Resources: