@suilab/token-creator-sdk
v1.0.0
Published
TypeScript SDK for creating native SUI tokens using SUILab's API
Maintainers
Readme
@suilab/token-creator-sdk
TypeScript SDK for creating native SUI tokens using SUILab's API. Simplifies token creation for developers building on the SUI blockchain.
Installation
npm install @suilab/token-creator-sdkQuick Start
import { SuiLabTokenCreatorSDK } from '@suilab/token-creator-sdk';
// Initialize SDK with your API key
const sdk = new SuiLabTokenCreatorSDK('SUILab_YOUR_API_KEY', {
developerWallet: '0xYOUR_WALLET_ADDRESS',
developerFee: 3, // 3 SUI fee you charge users
network: 'mainnet'
});
// Create a token
const result = await sdk.createNativeToken({
name: 'My Token',
symbol: 'MTK',
decimals: 9,
totalSupply: 1000000,
description: 'My awesome token on SUI',
userAddress: userWalletAddress,
icon: 'https://example.com/icon.png' // optional
});
console.log('Token created:', result.tokenId);
console.log('Transaction:', result.digest);Features
- ✅ Simple token creation in 3 lines of code
- ✅ Automatic fee calculation and handling
- ✅ Built-in parameter validation
- ✅ IPFS icon upload support
- ✅ Full TypeScript support with types
- ✅ Error handling and retry logic
API Reference
SuiLabTokenCreatorSDK
Main SDK class for token creation.
Constructor
constructor(apiKey: string, config: TokenCreatorConfig)Parameters:
apiKey- Your SUILab API key (get from https://docs.suilab.fun/apikey)config- SDK configuration object
Example:
const sdk = new SuiLabTokenCreatorSDK('SUILab_abc123', {
developerWallet: '0x742d...',
developerFee: 5,
network: 'mainnet'
});Methods
createNativeToken(params)
Creates a native SUI token.
Parameters:
interface TokenCreationParams {
name: string; // Token name
symbol: string; // Token symbol (uppercase)
decimals: number; // Decimals (0-18)
totalSupply: number; // Total supply
description: string; // Token description
userAddress: string; // User's wallet address
icon?: string | File; // Optional icon URL or File
metadata?: object; // Optional metadata
}Returns: Promise<TokenCreationResult>
Example:
const token = await sdk.createNativeToken({
name: 'My DAO Token',
symbol: 'DAO',
decimals: 9,
totalSupply: 10_000_000,
description: 'Governance token for My DAO',
userAddress: '0x742d...'
});estimateFees()
Get fee breakdown for token creation.
Returns: FeeEstimate
Example:
const fees = sdk.estimateFees();
console.log(fees);
// {
// platformFee: 2, // SUILab platform fee
// developerFee: 3, // Your custom fee
// networkFee: 0.05, // Estimated network fee
// total: 5.05 // Total
// }validateParams(params)
Validate token parameters before creation.
Returns: ValidationResult
Example:
const validation = sdk.validateParams(myParams);
if (!validation.isValid) {
console.error('Errors:', validation.errors);
}Fee Structure
When users create tokens through your integration:
| Fee Type | Amount | Recipient | |----------|--------|-----------| | Platform Fee | 2 SUI | SUILab (mandatory) | | Developer Fee | Customizable | You (set in config) | | Network Fee | ~0.05 SUI | SUI Validators |
Example: If you set developerFee: 3, users pay 5.05 SUI total (2 + 3 + 0.05)
Configuration
TokenCreatorConfig
interface TokenCreatorConfig {
developerWallet: string; // Your wallet to receive fees
developerFee: number; // Fee you charge (in SUI)
network?: 'mainnet' | 'testnet'; // Default: 'mainnet'
apiEndpoint?: string; // Custom API endpoint (optional)
}Error Handling
try {
const result = await sdk.createNativeToken(params);
console.log('Success!', result);
} catch (error) {
console.error('Failed:', error.message);
}Common errors:
Invalid API key format- Check your API keyValidation failed- Check token parametersAPI Error- Check API status or networkNo response from API- Network issue
Utilities
IPFS Upload
import { uploadToIPFS } from '@suilab/token-creator-sdk';
const iconUrl = await uploadToIPFS(
imageFile,
'YOUR_PINATA_API_KEY',
'YOUR_PINATA_SECRET'
);Unit Conversion
import { suiToMist, mistToSui } from '@suilab/token-creator-sdk';
const mist = suiToMist(5); // 5 SUI → 5000000000 MIST
const sui = mistToSui(BigInt(5000000000)); // → 5 SUIGet API Key
- Visit https://docs.suilab.fun/apikey/requestapikey
- Fill out the request form
- Receive your API key via email (24-48 hours)
Support
- Documentation: https://docs.suilab.fun/apikey
- Email: [email protected]
- GitHub: https://github.com/suilab/token-creator-sdk
License
MIT
Built with ❤️ by SUI Lab Team
