@tradeport/launchpad
v0.1.3
Published
TypeScript client library for Tradeport Launchpad API
Readme
Tradeport Launchpad SDK
A TypeScript SDK for interacting with the Tradeport Launchpad API, which enables developers to create, manage, and mint NFT collections on the SUI blockchain.
Installation
npm install @tradeport/launchpad
# Or if you prefer pnpm
pnpm add @tradeport/launchpadFeatures
- Create and manage NFT collections
- Upload media files for collections and tokens
- Create and manage mint stages
- Control allowed wallets for mint stages
- Mint tokens
- Manage royalties and withdrawals
- Public API for accessing published collections, mint stages and tokens
Getting Started
import { Launchpad } from '@tradeport/launchpad';
// Initialize
const launchpad = new Launchpad({
authentication: {
getWalletData: () => ({
walletAddress: '0x11111', // used wallet address,
publicKey: '0x22222', // used wallet public key,
}),
signMessage: async (walletAddress, message) =>
// wallet interaction code to sign the message and return the signature as hex string like 0xaaaaa,
},
});
// Or if you have already JWT
const launchpad = new Launchpad({
jwt: 'your-jwt-token',
});
// Or if you going to use only public API
const launchpad = new Launchpad();
Example with Mysten Dapp Kit
import {
ConnectButton,
useCurrentAccount,
useCurrentWallet,
useSignPersonalMessage,
} from "@mysten/dapp-kit";
import { Launchpad } from "@tradeport/launchpad";
import { useMemo } from "react";
import { toHex } from "@mysten/sui/utils";
export default function App() {
const currentAccount = useCurrentAccount();
const { currentWallet } = useCurrentWallet();
const { mutateAsync: signPersonalMessage } = useSignPersonalMessage();
const launchpad = useMemo(() => {
if (!currentAccount) return null;
return new Launchpad({
authentication: {
getWalletData: () => ({
walletAddress: currentAccount.address,
publicKey: toHex(new Uint8Array(currentAccount.publicKey)),
walletName: currentWallet?.name,
}),
signMessage: async (walletAddress, message) => {
const result = await signPersonalMessage({
account: currentAccount,
message: new TextEncoder().encode(message),
});
return result;
},
},
});
}, [currentAccount]);
return (
<div>
<ConnectButton />
</div>
);
}
Usage
Create collection
// Create collection record
const {id: collectionId} = await launchpad.createCollection({
name: `Super collection`,
description: `My super collection`,
type: 'Edition',
royalty: 1,
beneficiaryAddress: '0x12345678',
});
// Upload collection media file
await launchpad.uploadCollectionMediaFile(collectionId, {
file: collectionMediaFile, // File object
});
// Add 1 or several tokens
const tokens = await launchpad.createTokens(collectionId, [
{
name: 'NFT #1',
type: 'Edition',
description: 'This is NFT 1',
attributes: [{name: 'Color', value: 'Red'}],
supplyType: 'Fixed',
supplyCount: 2,
},
{
name: 'NFT #2',
type: 'Edition',
description: 'This is NFT 2',
attributes: [{name: 'Color', value: 'Blue'}],
supplyType: 'Fixed',
supplyCount: 3,
},
]);
// Upload token media files
await launchpad.uploadTokenMediaFile(collectionId, tokens[0].id, {
file: tokenMediaFile1, // File object
});
await launchpad.uploadTokenMediaFile(collectionId, tokens[1].id, {
file: tokenMediaFile2, // File object
});
// Create Mint Stage(s)
await launchpad.createMintStage(collectionId, {
name: "Public Mint",
price: "1000000000",
tokenId: "86f73f1f-897a-4461-899c-4435c0c92647", // if Edition collection, include which edition token ID
startTime: new Date().toIsoString() // minting immediately starts
endTime: null, // mint open forever
limit: 5 // limit of 5 mints per wallet
})
// Do some other changes
// Validate collection
await launchpad.validateCollection(collectionId);
// Create collection on blockchain
const {createCollectionTransaction} =
await launchpad.publishCollection(collectionId); // for new collection the first call of publishCollection() returns createCollectionTransaction, i.e. transaction that creates collection on blockchain
// execute createCollectionTransaction using your favorite blockchain client or wallet
await launchpad.finishTransaction({
transactionHash: '<transaction hash of createCollectionTransaction>',
}); // to make the backend to know that the transaction was executed
// Publish collection on blockchain
const {fundCollectionTransaction} =
await launchpad.publishCollection(collectionId);
// execute fundCollectionTransaction using your favorite blockchain client or wallet
await launchpad.finishTransaction({
transactionHash: '<transaction hash of fundCollectionTransaction>',
}); // to make the backend to know that the transaction was executed
// In some seconds/minutes collection will be published: all media files will be uploaded to IPFS, for Drops all tokens will be uploaded to the blockchain
// You can check publishing status using launchpad.getTasks(collectionId). Look at publish-collection.ts in smaples for more detailsMint tokens
// Get available token count to mint
const {count} = await launchpad.getAvailableCountToMint(
collectionId,
mintStageId,
{tokenId}, // for Drops omit this argument
);
if (count > 0) {
// Mint token
const {transaction} = await launchpad.mintTokens(collectionId, {
mintStageId,
tokenId, // for Drops omit this argument
count: 1,
});
// execute transaction using your favorite blockchain client or wallet
const mintedTokens = await launchpad.finishTransaction({
transactionHash: '<hash of transaction>',
});
console.log('Minted token:');
console.log(mintedTokens);
}
Update collection
// Update collection
// If you try to change the name already published collection you will get an error
const result = await launchpad.updateCollection(collectionId, {
description: 'Updated collection description'
});
// If collection was already published and your changes affect the collection blockchain data, you need to execute the transaction
if (result?.transaction) {
// execute transaction using your favorite blockchain client or wallet
await launchpad.finishTransaction({
transactionHash: '<hash of transaction>',
});
}
Use public API
// Get published collection data
// collectionId is id that returns from launchpad.createCollection() or blockchain Id of published collection
const collection = await launchpad.public.getCollection(collectionId);
console.log(collection);
// Get published token data (for Editions only)
// tokenId is id that returns from launchpad.createTokens()
const token = await launchpad.public.getEditionToken(collectionId, tokenId);
console.log(token);
// Get published tokens list (for Editions only)
const tokens = await launchpad.public.getEditionTokens(collectionId);
console.log(tokens);
// Get collection mint stage data
// mintStageId is id that returns from launchpad.createMintStage()
const mintStage = await launchpad.public.getMintStage(collectionId, mintStageId);
console.log(mintStage);
// Get collection mint stages
const mintStages = await launchpad.public.getMintStages(collectionId);
console.log(mintStages);
Check balances and make withdrawals
// Only collection creator can make the next calls
// Check balances
const {balance} = await launchpad.getCollectionBalance(collectionId);
const {royalty} = await launchpad.getCollectionRoyalty(collectionId);
console.log(balance, royalty);
// Withdraw
const {transaction} = await launchpad.withdrawCollectionBalance(collectionId, {
amount: 100, // omit this argument to withdraw all available balance
recepient: '0x12345678', // omit this argument to withdraw to the sender address
});
// execute transaction using your favorite blockchain client or wallet
const {transaction} = await launchpad.withdrawCollectionRoyalty(collectionId, {
amount: 100, // omit this argument to withdraw all available royalty
recepient: '0x12345678', // omit this argument to withdraw to the sender address
});
// execute transaction using your favorite blockchain client or wallet
Sample Applications
Check out the samples directory for complete examples:
publish-collection.mts: Demonstrates the complete process of creating and publishing an NFT collection on the SUI blockchain.update-collection.mts: Shows how to update an existing NFT collection.add-more-tokens.mts: Illustrates how to add additional tokens to an existing published collection.mint-token.mts: Demonstrates how to mint tokens from an existing collection.
Contributing
Requirements
- Node.js 22+
- pnpm
Setup
# Clone the repository
git clone https://github.com/byzantion-xyz/byz-move-launchpad-sdk-ts.git
# Install dependencies
cd byz-move-launchpad-sdk-ts
pnpm install
# Build the SDK
pnpm build
# Run tests
pnpm test