Api Reference
The main class to interface with TipLink Pro functionality including campaigns and dispensers.
Functionality includes creating campaigns, adding tiplink entries to those campaigns, and creating, pausing, refeshing and deleting dispensers.
Import
import { TipLinkClient } from '@tiplink/api';
Class Definition
TipLinkClient
export class TipLinkClient {
campaigns: CampaignActions;
public static async init(apiKey: string, version: number = 1): Promise<TipLinkClient> {}
}
Campaign
class CampaignActions {
public constructor(params: CampaignActionsConstructor) {}
public async create(params: CampaignCreateParams): Promise<Campaign> {}
}
interface CampaignCreateParams {
name: string;
description: string;
imageUrl: string;
active: boolean; // default true
themeId?: number; // Optional: premium feature
}
export class Campaign extends TipLinkApi {
id: number;
name: string;
description: string;
imageUrl: string;
active: boolean;
dispensers: DispenserActions;
public async addEntries(tiplinks: TipLink[]): Promise<boolean> {}
}
Dispenser
class DispenserActions extends TipLinkApi {
campaign: Campaign;
public async create(params: CreateDispenserParams): Promise<Dispenser> {}
public async find (params: DispenserFindParams): Promise<Dispenser> {}
public async all(params: DispenserAllParams): Promise<Dispenser[]> {}
}
interface CreateDispenserParams {
useCaptcha: boolean; // default true
useFingerprint: boolean; // default true
unlimitedClaims: boolean; // default false // WARNING: this is a global setting affecting all dispensers for a given campaign
active?: boolean; // default true
}
export class Dispenser extends TipLinkApi {
campaign: Campaign;
urlSlug: string;
useCaptcha: boolean;
useFingerprint: boolean;
unlimitedClaims: boolean;
active: boolean;
url: URL;
public async pause(): Promise<boolean> {}
public async resume(): Promise<boolean> {}
public async refresh(): Promise<URL> {}
public async delete(): Promise<boolean> {}
}
Mint
class MintActions extends TipLinkApi {
public constructor(params: MintActionsConstructor) {}
public async getFees(params: MintCreateParams): Promise<FeeResponse> {}
public async create(params: MintCreateParams): Promise<Mint> {}
}
enum DataHost {
Arweave = "arweave", // irys arweave
Shadow = "shadow" // genesysgo shadow drive
}
interface MintCreateParams {
campaignName: string;
campaignDescription?: string;
mintName: string;
mintDescription?: string;
symbol: string;
mintLimit: number;
mintImageUrl: string;
externalUrl?: string;
existingCollectionId?: string;
creatorPublicKey: PublicKey;
royalties?: number;
royaltiesDestination?: PublicKey;
attributes?: Record<string, string>;
dataHost?: DataHost;
feeTransactionHash?: string;
themeId?: number;
}
interface FeeResponse {
publicKey: PublicKey;
feeLamports: number;
}
export class Mint extends TipLinkApi {
id: number;
campaign_id: number;
campaignName: string;
imageUrl: string;
externalUrl: string;
dataHost: DataHost;
mintName: string;
symbol: string;
mintDescription: string;
mintLimit: number;
attributes: Record<string, string>[];
creatorPublicKey: PublicKey;
collectionId: string;
treeAddress: string;
jsonUri: string;
collectionUri: string;
royalties: number;
primaryUrlSlug: string;
rotatingUrlSlug: string;
useRotating: boolean;
rotatingTimeInterval: number;
totpWindow: number;
userClaimLimit: number;
royaltiesDestination?: PublicKey | null;
public constructor(params: MintConstructorParams) {}
public getMintUrl(): URL {}
public async getAnalytics(): Promise<AnalyticsSummary> {}
}
Example Usage
Create Campaign And Dispenser
import { TipLink, TipLinkClient } from '@tiplink/api';
const API_KEY = "O1.cdase3234_EXAMPLE";
const createCampaignAndDispenserExample = async () => {
const client = await TipLinkClient.init(API_KEY, 1);
const campaign = await client.campaigns.create({
name: "Campaign test",
description: "longer string description", // optional
// themeId: 1, // optional Preimum feature to attach a theme to campaign
});
const tp = await TipLink.create();
const tp2 = await TipLink.create();
// TODO: Fund your tiplinks here using: tp.keypair
const tiplinks = [tp, tp2];
await campaign.addEntries(tiplinks);
const dispenser = await campaign.dispensers.create({
useCaptcha: false, // optional: default true
useFingerprint: true, // optional: default true
unlimitedClaims: false // optional: default false // WARNING: this is global per campaign and affects all dispensers for that campaign
});
return dispenser.url;
}
createCampaignAndDispenserExample().then(url => {
console.log(url.toString());
});