Fungible Tokens
Deploying a Fungible Token Smart Contract
Section titled “Deploying a Fungible Token Smart Contract”Deploying a fungible token smart contract follows the same process as any smart contract. Please review this documentation.
Adding a feature type with the token details to the payload. FeatureName 13 is the Token feature.
{ ... "Features": [ { "FeatureName": 13, "FeatureFeatures": { "TokenName": "My Token Name", "TokenTicker": "My Token Ticker", "TokenDecimalPlaces": 16, "TokenSupply": 1000, //0 for infinite supply "TokenBurnable": true, "TokenMintable": true, "TokenVoting": true, "TokenImageURL": "https://...", // optional "TokenImageBase": "base64ImageData..." }, } ]}After compiling, the token smart contract still needs to be minted, following the same approach as any smart contract.
GET http://localhost:7292/scapi/scv1/MintSmartContract/{SMART_CONTRACT_UID}Minting Tokens
Section titled “Minting Tokens”Note: The base token’s smart contract must be of infinite supply in order to mint tokens.
API Endpoint
Section titled “API Endpoint”GET http://localhost:7292/tkapi/TKV2/TokenMint/{scUID}/{fromAddress}/{amount}URL Params:
Section titled “URL Params:”scUID: The token’s smart contract identifier.
fromAddress: The smart contract owner’s address.
amount: The amount of tokens to mint (decimals supported)
Success Response
Section titled “Success Response”{ "Success": true, "Message": "Result: TX Success. SCUID: ..."}Note: all token action methods will return a similar response structure. If
SuccessisfalsetheMessageparam will include details. Every action is sent from an account held by the node’s wallet, and an encrypted wallet must be unlocked first.
Transferring Tokens
Section titled “Transferring Tokens”API Endpoint
Section titled “API Endpoint”GET http://localhost:7292/tkapi/TKV2/TransferToken/{scUID}/{fromAddress}/{toAddress}/{amount}URL Params:
Section titled “URL Params:”scUID: The token’s smart contract identifier.
fromAddress: The sender’s address
toAddress: The recipient’s address
amount: The amount of tokens to transfer (decimals supported)
Burning Tokens
Section titled “Burning Tokens”API Endpoint
Section titled “API Endpoint”GET http://localhost:7292/tkapi/TKV2/BurnToken/{scUID}/{fromAddress}/{amount}URL Params:
Section titled “URL Params:”scUID: The token’s smart contract identifier.
fromAddress: The address of the token owner to burn from.
amount: The amount of tokens to burn (decimals supported)
Pausing (and Unpausing) Token Transactions
Section titled “Pausing (and Unpausing) Token Transactions”API Endpoint
Section titled “API Endpoint”GET http://localhost:7292/tkapi/TKV2/PauseTokenContract/{scUID}/{fromAddress}URL Params:
Section titled “URL Params:”scUID: The token’s smart contract identifier.
fromAddress: The address of the token owner.
The same call toggles: on a paused contract it unpauses.
Banning an Address
Section titled “Banning an Address”API Endpoint
Section titled “API Endpoint”GET http://localhost:7292/tkapi/TKV2/BanAddress/{scUID}/{fromAddress}/{banAddress}URL Params:
Section titled “URL Params:”scUID: The token’s smart contract identifier.
fromAddress: The address of the token owner.
banAddress: The address to ban from the token.
Change Ownership
Section titled “Change Ownership”API Endpoint
Section titled “API Endpoint”GET http://localhost:7292/tkapi/TKV2/ChangeTokenContractOwnership/{scUID}/{fromAddress}/{toAddress}URL Params:
Section titled “URL Params:”scUID: The token’s smart contract identifier.
fromAddress: The sender’s address
toAddress: The recipient’s address
Create Voting Topic
Section titled “Create Voting Topic”API Endpoint
Section titled “API Endpoint”POST http://localhost:7292/tkapi/TKV2/CreateTokenTopicPOST Data Params:
Section titled “POST Data Params:”{ "TopicName": "Raise the supply", "TopicDescription": "Mint 1,000 more tokens for the community fund.", "SmartContractUID": "<token smart contract UID>", "MinimumVoteRequirement": 10, "FromAddress": "<token owner address>", "VotingEndDays": 30}TopicName is at most 128 characters and TopicDescription at most 1,600. MinimumVoteRequirement is a whole number. VotingEndDays is one of 30, 60, 90 or 180. FromAddress must be the token contract’s owner.
Cast Vote
Section titled “Cast Vote”API Endpoint
Section titled “API Endpoint”GET http://localhost:7292/tkapi/TKV2/CastTokenTopicVote/{scUID}/{fromAddress}/{topicUID}/{voteType}URL Params:
Section titled “URL Params:”scUID: The token’s smart contract identifier.
fromAddress: The voter’s address
topicUID: The topic’s unique identifier
voteType: 1 == YES; 0 == NO
Reading Tokens and Votes
Section titled “Reading Tokens and Votes”GET /tkapi/TKV2/GetTokens/{scUID}/{getAll}: the tokens held by the wallet’s accounts (getAll=true), or one token’s details.GET /tkapi/TKV2/GetTokensUpdate: rebuilds the wallet’s in-memory token list.GET /tkapi/TKV2/GetVoteBySmartContractUID/{scUID}: the wallet’s votes on a token’s topics.GET /tkapi/TKV2/GetVoteByTopic/{topicUID}: the votes recorded for one topic.GET /tkapi/TKV2/GetVotesByAddress/{fromAddress}: every token vote cast by an address.GET /tkapi/TKV2/GetTokenOwnerVoteList/{tUID}: the vote list the token owner sees for a topic.