Skip to main content

Mint Guide

Code Snippet

Constants

Make sure to fill in constants & mintParams below

import { TipLink, TipLinkClient } from '@tiplink/api';
import {
PublicKey,
Keypair,
Connection,
SystemProgram,
TransactionMessage,
VersionedTransaction,
} from "@solana/web3.js";

const API_KEY = "<get from tiplink>"; // reach out on discord
const RPC_ENDPOINT = "<rpc endpoint for making fee transaction>";
const payer = Keypair.generate(); // use keypair you wish to pay fees

const createMint = async (payer) => {

// Initialize Client
const client = await TipLinkClient.init(API_KEY);

const mintParams = {
mintName: "Test Tiplink Client Mint", // Max length 32 characters
symbol: "TESTTMM", // Max length 10 characters
mintDescription: "OPTIONAL: This is purely for testing purposes and should not be treated as a store of value.", // Optional

mintLimit: 100,
mintImageUrl: "https://arweave.net/",
externalUrl: "https://tiplink.io", // Optional
attributes: {"TestAttr": "20", "TestAttr2": "TestString"}, // Optional

existingCollectionId: "<OPTIONAL: Existing Mint Collection>", // Optional

creatorPublicKey: payer.publicKey,

campaignName: "Test Client Created Campaign",
campaignDescription: "Test Description for dashboard", // Optional
// themeId: 1, // Optional: premium feature

royalties: 20, // Optional: Max 50 as percentage
royaltiesDestination: payer.publicKey, // Optional
};

// Get Mint Fee Informatino
const mintFees = await client.mints.getFees(mintParams);

// Setup Fee Payment
const connection = new Connection(RPC_ENDPOINT, "confirmed");
const latestBlockhash = await connection.getLatestBlockhash();
const instructions = [];

// Create Fee Payment Instruction
instructions.push(
SystemProgram.transfer({
fromPubkey: payer.publicKey,
lamports: Math.ceil(mintFees.feeLamports),
toPubkey: mintFees.publicKey,
})
);

// Make Fee Payment
const messageLegacy = new TransactionMessage({
instructions,
payerKey: payer.publicKey,
recentBlockhash: latestBlockhash.blockhash,
}).compileToLegacyMessage();
const transaction = new VersionedTransaction(messageLegacy);
transaction.sign([payer]);
const signedTransaction = await connection.sendTransaction(transaction);

// Add fees transaction has to mintParams
mintParams["feeTransactionHash"] = signedTransaction;

// create mint
const mint = await client.mints.create(mintParams);

return mint;
};

createMint(payer).then(mint => {
// Log dashboard page for this mint campaign
console.log(`https://tiplink.io/pro/campaigns/${mint.campaign_id}`);

// Log mint url
console.log(mint.getMintUrl().toString());
});