finchain-token-creator
v1.2.3
Published
This sdk makes easy connection with Finchain Token Creator services
Maintainers
Readme
Finchain Token Creator SDK
The official Node.js SDK for interacting with the Finchain Token Creator platform.
Installation
npm install finchain-token-creatorQuick Start
const FTC = require('finchain-token-creator');Authentication
Before using the SDK, you need to obtain your API credentials (apiKey and apiSecret) from tokencreator.finchain.com.br. Configure the SDK with these credentials using the config method.
await FTC.config({
apiKey: 'YOUR_API_KEY',
apiSecret: 'YOUR_API_SECRET'
});Launching a new token
Use deploy to create and launch a new token.
// Example: deploy ERC20
await FTC.tokens.deploy(
FTC.types.STANDARD.ERC20,
FTC.types.NETWORK.BSC,
FTC.types.CLASS_IDENTIFIER.UTILITY_TOKEN,
{
name: "MyToken",
symbol: "MTK",
description: "My utility token",
quantity: "1000000",
companyName: "My Company",
// icon: optional (Buffer/Uint8Array/ReadableStream in Node, Blob/File in browser)
}
);
// Example: deploy ERC721 with file
await FTC.tokens.deploy(
FTC.types.STANDARD.ERC721,
FTC.types.NETWORK.POLYGON,
FTC.types.CLASS_IDENTIFIER.FAN_SPORT_TOKEN,
{
name: "MyNFT",
symbol: "MNFT",
description: "My NFT collection",
companyName: "My Company",
icon: myFile // Buffer/stream/Blob/File
}
);
// Example: deploy ERC20 with icon using FTCImageHandler
const response = await FTC.tokens.deploy(
FTC.types.STANDARD.ERC20, // Token Standard
FTC.types.NETWORK.BSC_TESTNET, // Network
FTC.types.CLASS_IDENTIFIER.UTILITY_TOKEN, // Class Identifier
{
name: "Test Token via SDK",
symbol: "TT",
description: "Testing Token via SDK",
quantity: "10000000000000000000",
companyName: "Test Company via SDK",
icon: await FTC.utils.FTCImageHandler("/path/image" /* or Buffer */)
}
);NETWORKS
| Key | Value | |---------------|----------| | XRPL_TESTNET | XRPL | | BSC_TESTNET | BSC_TEST | | AMOY_TESTNET | AMOY | | BSC | BSC | | ETHEREUM | ETHEREUM | | POLYGON | POLYGON |
STANDARD
| Key | Value | |-------|-------| | ERC20 | ERC20 | | ERC721| ERC721|
CLASS_IDENTIFIER
| Key | Value | |-----------------|-------| | UTILITY_TOKEN | UT | | REWARDS_TOKEN | RT | | PAYMENT_TOKEN | PT | | FAN_SPORT_TOKEN | FST | | RWA_TOKEN | TRWA | | REFI_TOKEN | RFI | | DEFI_TOKEN | DFI |
Token Operations
Minting Tokens
Mint new tokens or token items to a specified address.
// Mint fungible tokens (ERC20)
await FTC.tokens.mint(
'TOKEN_ADDRESS', // The address of the token to mint
1000, // Amount to mint
'TO_ADDRESS' // Recipient address
);
// Mint NFT with file (ERC721)
await FTC.tokens.mint(
'TOKEN_ADDRESS', // The address of the token to mint
1, // Amount to mint (usually 1 for NFTs)
'TO_ADDRESS', // Recipient address
'My NFT Item', // Token item name
fileObject // File object to be associated with the NFT
);Transferring Tokens
Transfer tokens from your account to another address.
await FTC.tokens.transfer(
'TOKEN_ADDRESS', // The address of the token to transfer
100, // Amount to transfer
'TO_ADDRESS' // Recipient address
);Burning Tokens
Burn (destroy) tokens from your account.
await FTC.tokens.burn(
'TOKEN_ADDRESS', // The address of the token to burn
50 // Amount to burn
);Get Status of a Transaction
Get the status of a transaction by its hash.
await FTC.actions.status('TRANSACTION_HASH_ID');Get Transactions of a Token
Get the transactions of a token by its address.
await FTC.actions.transactions(
'TOKEN_ADDRESS', // The address of the token to get the transactions
'MINT', // The type of transactions to get (optional) MINT, TRANSFER, BURN
1, // The page of transactions to get (optional)
1000 // The limit of transactions to get (optional)
);List All Tokens
List all tokens from your account.
// List all tokens (default: page 1, limit 1000)
const tokens = await FTC.tokens.list();
// List tokens with pagination
const tokens = await FTC.tokens.list(1, 100); // page 1, limit 100API Reference
FinchainTokenCreator
config(config: { apiKey: string; apiSecret: string }): Promise<void>- Configures the SDK with your API credentials
- Required before making any API calls
getAuthorization(): string- Returns the current authorization token
- Returns empty string if not authenticated
Tokens (Actions)
list(page?: number, limit?: number): Promise<{ data: Token[] } | { error: string }>- Lists all tokens from your account
- Parameters:
page: (Optional) Page number to retrieve (default: 1)limit: (Optional) Maximum number of tokens per page (default: 1000)
- Returns:
Token[]: Array of tokens with the following structure:hashId: Hash ID of the tokenaddress: (Optional) Token addressimgUrl: URL of the token imagename: Name of the tokenticker: Token ticker/symbolsupply: (Optional) Total supply of the tokennetwork: (Optional) Network where the token is deployedtype: Type of the tokenscanUrl: (Optional) URL to view the token on the blockchain explorercreated_at: Creation date of the tokenstatus: (Optional) Status of the tokenactions: Array of available actions for the token
mint(tokenAddress: string, amount: number, to: string, tokenItemName?: string, file?: File): Promise<any>- Mints new tokens or token items
- Parameters:
tokenAddress: Address of the token to mintamount: Amount of tokens to mintto: Recipient addresstokenItemName: (Optional) Name for new token item (required if file is provided)file: (Optional) File to associate with the token item (required if tokenItemName is provided)
transfer(tokenAddress: string, amount: number, to: string): Promise<any>- Transfers tokens to another address
- Parameters:
tokenAddress: Address of the token to transferamount: Amount of tokens to transferto: Recipient address
burn(tokenAddress: string, amount: number): Promise<any>- Burns (destroys) tokens
- Parameters:
tokenAddress: Address of the token to burnamount: Amount of tokens to burn
status(hashId: string): Promise<any>- Gets the status of a transaction by its hash
- Parameters:
hashId: Hash ID of the transaction
transactions(tokenAddress: string, type?: string, page?: number, limit?: number): Promise<Action[]>- Gets the transactions of a token
- Parameters:
tokenAddress: Address of the token to get the transactionstype: (Optional) Type of transactions to get (MINT, TRANSFER, BURN)page: (Optional) Page of transactions to getlimit: (Optional) Limit of transactions to get
- Returns:
Action[]: Array of transactionsaddressTo: Address of the recipientamount: Amount of tokens transferredaction: Type of transaction (MINT, TRANSFER, BURN)hashId: Hash ID of the transactiontxHash: Transaction hashstatus: Status of the transactionstandard: Standard of the token (ERC20, ERC721)createdAt: Date and time of creationupdatedAt: Date and time of updatescanUrl: URL to view the transaction on the blockchain explorer
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please contact our support team or visit tokencreator.finchain.com.br.
