Creating a Currency Token
Similarly to Tokens, "Currency Tokens" are also digital assets that can be traded, sold, or used on the Enjin Blockchain. However, unlike standard tokens, currency tokens support fractional values, allowing them to be divided into smaller units, just like traditional currencies.
- Some Enjin Coin on Enjin Matrixchain to process transactions and at least 0.01 ENJ for the Token Account Deposit. You can obtain cENJ (Canary ENJ) for testing from the built-in Canary faucet in the Platform UI.
- An Enjin Platform Account.
- A Collection to place the tokens in.
Enjin Blockchain allows you to create customized Token ID
structures. This flexibility enables you to organize your tokens in various ways that suit your needs.A token becomes a currency by setting its behavior field to { type: IS_CURRENCY, name, symbol, decimalCount }:
- Name: The token name (e.g. Gold Coins).
- Symbol: A short symbol that represents the token (e.g. GOLD).
- Decimals: Max amount of decimals supported for this token (e.g. 2 would mean the token can support up to 2 decimals, like 5.75 Gold Coins).
The decimalCount property specifies how token balances should be displayed in applications, but it does not allow for actual fractional values on the Enjin Blockchain.
This means that for a token with "Decimals: 2", the balance should be divided by 100 (10^2) when displayed in applications.
For example, for the Gold Coins token example mentioned above, a balance of 1,575 Gold Coins should be shown as 15.75 (1,575/100) in apps.
Similarly, when minting tokens, to mint 4.80 Gold Coins, the minted supply parameter should be set to 480 (4.8 * 10^2).
Before minting the Mainnet versions of your Tokens, that will be used in your live economy. Make sure to take a look at the best practices for Token ID structure.
There are two ways to use the Create Asset functionalities:
Option A. Using the Enjin Dashboard
In the Platform menu, navigate to "Collections" and click the collection you want to mint the token into. From the collection page, click the "Create Token" button.
Fill in the standard token fields — Collection ID, Token ID, Initial Supply, and Recipient. See Creating Tokens for the full breakdown of those fields.
To mark the token as a currency, expand the Advanced Settings section. Under Other Options, tick the Is Currency checkbox. Two additional fields appear:
- Symbol - A short symbol that represents the token (e.g.
GOLD). - Decimal Count - The number of decimal places this token should support when displayed in applications (e.g.
2for a token like Gold Coins where balances should render with two decimals).
For a comprehensive view and detail of all available arguments please refer to our API Reference.
Once you're satisfied with the options, click the "Create" button to submit the request. A Transaction Submitted modal appears with the new transaction's UUID and a View Transaction button that opens its row on the Transactions page.
Since this request requires a Transaction
, it must be signed before it broadcasts.- By default, transactions are signed automatically by the Wallet Daemon.
- To sign with a different account, expand Transaction Options → Signing Account on the form and provide a Managed Wallet address.
Once your token is created, lets give it a new look by Adding Metadata.
Option B. Using the Enjin API & SDKs
To create a currency token, use the standard createToken action with the behavior field set to { type: IS_CURRENCY, name, symbol, decimalCount }. The rest of the input (recipient, collectionId, tokenId, initialSupply, etc.) follows the same shape as a regular token create.
The C# and C++ SDK examples below are out of date and will not work against the current Enjin Platform API. This section will be updated once new SDKs are published. Until then, use the GraphQL, cURL, Javascript, Node.js, or Python examples.
- GraphQL
- cURL
- c# SDK
- C++ SDK
- Javascript
- Node.js
- Python
mutation CreateCurrencyToken {
CreateTransaction(
network: ENJIN # or CANARY for testnet
chain: MATRIX
transaction: {
createToken: {
recipient: "cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f" # recipient of the initial supply
collectionId: 2406 # collection to mint into
tokenId: 1 # the new token ID
initialSupply: 1 # initial supply to mint
listingForbidden: false
infusion: 0
anyoneCanInfuse: false
behavior: { # makes this token a currency
type: IS_CURRENCY
name: "Gold Coins"
symbol: "GOLD"
decimalCount: 2
}
}
}
) {
uuid
action
state
}
}
curl --location 'https://platform.beta.enjin.io/graphql' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-d '{"query":"mutation CreateCurrencyToken($recipient: String!, $collectionId: BigInt!, $tokenId: BigInt!, $initialSupply: BigInt!, $behavior: TokenBehaviorInput!) {\r\n CreateTransaction(\r\n network: ENJIN\r\n chain: MATRIX\r\n transaction: {\r\n createToken: {\r\n recipient: $recipient\r\n collectionId: $collectionId\r\n tokenId: $tokenId\r\n initialSupply: $initialSupply\r\n listingForbidden: false\r\n infusion: 0\r\n anyoneCanInfuse: false\r\n behavior: $behavior\r\n }\r\n }\r\n ) {\r\n uuid\r\n action\r\n state\r\n }\r\n}","variables":{"recipient":"cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f","collectionId":2406,"tokenId":1,"initialSupply":1,"behavior":{"type":"IS_CURRENCY","name":"Gold Coins","symbol":"GOLD","decimalCount":2}}}'
using System.Text.Json;
using Enjin.Platform.Sdk;
// Define the token metadata input
var tokenMetadata = new TokenMetadataInput()
.SetName("Token Name") // Set the token name
.SetSymbol("TKN") // Set the token symbol
.SetDecimalCount(18); // Set the decimal count
// Define the token parameters
var tokenParams = new CreateTokenParams()
.SetTokenId(new EncodableTokenIdInput().SetInteger(1)) //Set the token ID
.SetInitialSupply(1) //Mint initial supply
.SetCap(new TokenMintCap().SetType(TokenMintCapType.Infinite)) //Define supply type
.SetMetadata(tokenMetadata); //Set the token metadata
// Set up the mutation
var createToken = new CreateToken()
.SetRecipient("cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f") //The recipient of the initial supply
.SetCollectionId(2406) //Set the collection ID
.SetParams(tokenParams); //Set the previously defined token params
// Define and assign the return data fragment to the mutation
var createTokenFragment = new TransactionFragment()
.WithId()
.WithMethod()
.WithState();
createToken.Fragment(createTokenFragment);
// Create and auth a client to send the request to the platform
var client = PlatformClient.Builder()
.SetBaseAddress("https://platform.beta.enjin.io")
.Build();
client.Auth("Your_Platform_Token_Here");
// Send the request and write the output to the console.
// Only the fields that were requested in the fragment will be filled in,
// other fields which weren't requested in the fragment will be set to null.
var response = await client.SendCreateToken(createToken);
Console.WriteLine(JsonSerializer.Serialize(response.Result.Data));
Work in Progress!
fetch('https://platform.beta.enjin.io/graphql', {
method: 'POST',
headers: {'Content-Type': 'application/json','Authorization': 'Bearer YOUR_API_TOKEN'},
body: JSON.stringify({
query: `
mutation CreateCurrencyToken(
$recipient: String!
$collectionId: BigInt!
$tokenId: BigInt!
$initialSupply: BigInt!
$behavior: TokenBehaviorInput!
) {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
createToken: {
recipient: $recipient
collectionId: $collectionId
tokenId: $tokenId
initialSupply: $initialSupply
listingForbidden: false
infusion: 0
anyoneCanInfuse: false
behavior: $behavior
}
}
) {
uuid
action
state
}
}
`,
variables: {
recipient: "cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f",
collectionId: 2406,
tokenId: 1,
initialSupply: 1,
behavior: { type: "IS_CURRENCY", name: "Gold Coins", symbol: "GOLD", decimalCount: 2 }
}
}),
})
.then(response => response.json())
.then(data => console.log(data));
const axios = require('axios');
axios.post('https://platform.beta.enjin.io/graphql', {
query: `
mutation CreateCurrencyToken(
$recipient: String!
$collectionId: BigInt!
$tokenId: BigInt!
$initialSupply: BigInt!
$behavior: TokenBehaviorInput!
) {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
createToken: {
recipient: $recipient
collectionId: $collectionId
tokenId: $tokenId
initialSupply: $initialSupply
listingForbidden: false
infusion: 0
anyoneCanInfuse: false
behavior: $behavior
}
}
) {
uuid
action
state
}
}
`,
variables: {
recipient: "cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f",
collectionId: 2406,
tokenId: 1,
initialSupply: 1,
behavior: { type: "IS_CURRENCY", name: "Gold Coins", symbol: "GOLD", decimalCount: 2 }
}
}, {
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_TOKEN' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
import requests
query = '''
mutation CreateCurrencyToken(
$recipient: String!
$collectionId: BigInt!
$tokenId: BigInt!
$initialSupply: BigInt!
$behavior: TokenBehaviorInput!
) {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
createToken: {
recipient: $recipient
collectionId: $collectionId
tokenId: $tokenId
initialSupply: $initialSupply
listingForbidden: false
infusion: 0
anyoneCanInfuse: false
behavior: $behavior
}
}
) {
uuid
action
state
}
}
'''
variables = {
'recipient': 'cxLU94nRz1en6gHnXnYPyTdtcZZ9dqBasexvexjArj4V1Qr8f',
'collectionId': 2406,
'tokenId': 1,
'initialSupply': 1,
'behavior': {'type': 'IS_CURRENCY', 'name': 'Gold Coins', 'symbol': 'GOLD', 'decimalCount': 2},
}
response = requests.post('https://platform.beta.enjin.io/graphql',
json={'query': query, 'variables': variables},
headers={'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_TOKEN'}
)
print(response.json())
The response includes the transaction's uuid, action (e.g. MultiTokens.create_token), and state (PENDING → BROADCAST → FINALIZED). Use GetTransaction(network, chain, uuid: "<returned-uuid>") to poll the current state.
Once it reaches FINALIZED, an event is emitted confirming the new currency token was created. See Working with Events for how to read it.
For Token ID management, head to Best Practices > TokenID Structure
For a comprehensive view of all available arguments for queries and mutations, please refer to our API Reference. This resource will guide you on how to use the GraphiQL Playground to explore the full structure and functionality of our API.
createToken also accepts cap, attributes, and groups (token-group membership). To sign with a managed wallet instead of the Wallet Daemon, set signerAccount on CreateTransaction.
To add metadata to your token, go to the Adding Metadata tutorial.