finchain-token-creator v1.1.2
Finchain Token Creator SDK
The official Node.js SDK for interacting with the Finchain Token Creator platform.
Installation
npm install finchain-token-creator
Quick 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'
});
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)
);
API 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)
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.