Skip to main content

Transactions Guide

Recommended Sol Minimum for links with non SOL values (SPL tokens, NFTs, SFTs etc.)

// TRANSACTION_FEE_LAMPORTS + 2 * RENT_EXEMPT_MINIMUM_LAMPORTS;
const TIPLINK_MINIMUM_LAMPORTS = 4083560;
Transactions Fees

If there is no extra SOL on your TipLinks users will be unable to withdraw to their personal wallets

Recommended Sol Minimum for links with only SOL

// TRANSACTION_FEE_LAMPORTS + RENT_EXEMPT_MINIMUM_LAMPORTS;
const TIPLINK_SOL_ONLY_LINK_MINIMUM_LAMPORTS = 900000;
Transactions Fees

Account minimums can be derived using getFeeForMessage and getMinimumBalanceRorRentExemption

Transaction logic adapted from: https://docs.solana.com/developing/clients/javascript-api

import { TipLink } from '@tiplink/api';
import {
PublicKey,
Keypair,
Transaction,
SystemProgram,
sendAndConfirmTransaction,
} from '@solana/web3.js';

const fundTipLink = async (sourceKeypair, destinationTipLink) => {
/* TipLink.create() should not be able to generate invalid addresses
* this check is purely for demonstrational purposes
*/
const isValidAddress = await PublicKey.isOnCurve(destinationTipLink.keypair.publicKey);
if(!isValidAddress) {
throw "Invalid TipLink";
}

let transaction = new Transaction();
let connection = new Connection(clusterApiUrl("devnet"), "confirmed");

transaction.add(
SystemProgram.transfer({
fromPubkey: sourceKeypair.publicKey,
toPubkey: destinationTipLink.keypair.publicKey,
lamports: TIPLINK_SOL_ONLY_LINK_MINIMUM_LAMPORTS,
}),
);

const transactionSignature = await sendAndConfirmTransaction(connection, transaction, [sourceKeypair], {commitment: "confirmed"});
if (transactionSignature === null) {
throw "Unable to fund TipLink's public key";
}
return transactionSignature;
};
Note

You should use a fromKeypair you control which has enough funds in a production environment

Full Transaction Example

Transaction logic adapted from: https://docs.solana.com/developing/clients/javascript-api

Connection

Wallets on https://tiplink.io/ will only work with mainnet connections

import {
PublicKey,
Keypair,
Connection,
clusterApiUrl,
sendAndConfirmTransaction,
Transaction,
SystemProgram,
LAMPORTS_PER_SOL,
} from '@solana/web3.js';

import { TipLink } from '@tiplink/api';

const SOLANA_TRANSACTION_FEE_LAMPORTS = 5000; // to derive the real cost use: Connection.getFeeForMessage()
const TIPLINK_SOL_ONLY_LINK_MINIMUM_LAMPORTS = 900000;

const createAndFundKeypair = async () => {
const sourceKeypair = Keypair.generate();
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
const airdropSignature = await connection.requestAirdrop(
sourceKeypair.publicKey,
TIPLINK_SOL_ONLY_LINK_MINIMUM_LAMPORTS + SOLANA_TRANSACTION_FEE_LAMPORTS,
);
const confirmation = await connection.confirmTransaction(airdropSignature, "confirmed");
if (confirmation.value.err !== null) {
throw "Unable to fund new wallet";
}
return sourceKeypair;
}

const fundTipLink = async (sourceKeypair, destinationTipLink) => {
/* TipLink.create() should not be able to generate invalid addresses
* this check is purely for demonstrational purposes
*/
const isValidAddress = await PublicKey.isOnCurve(destinationTipLink.keypair.publicKey);
if(!isValidAddress) {
throw "Invalid TipLink";
}

let transaction = new Transaction();
let connection = new Connection(clusterApiUrl("devnet"), "confirmed");

transaction.add(
SystemProgram.transfer({
fromPubkey: sourceKeypair.publicKey,
toPubkey: destinationTipLink.keypair.publicKey,
lamports: TIPLINK_SOL_ONLY_LINK_MINIMUM_LAMPORTS,
}),
);

const transactionSignature = await sendAndConfirmTransaction(connection, transaction, [sourceKeypair], {commitment: "confirmed"});
if (transactionSignature === null) {
throw "Unable to fund TipLink's public key";
}
return transactionSignature;
};

const createAndFundTipLink = async () => {
const sourceKeypair = await createAndFundKeypair();
const destinationTipLink = await TipLink.create();
await fundTipLink(sourceKeypair, destinationTipLink);
console.log("visit", destinationTipLink.url.toString(), "to view your balance and perform other wallet actions");
console.log("The TipLink should have 90000 lamports worth of sol on it: the minimum recommended amount for a usable TipLink");
};

createAndFundTipLink();
Connection

Wallets on https://tiplink.io/ will only work with mainnet connections