Managing Your Assets
Learn more about how to manage your NFTs within your integration
The Enjin API has been built to provide all the functionality you need to manage a robust blockchain-based gaming economy.
You will likely use the following queries and mutations quite often when it comes to managing your tokenized assets in your project or in your game.
Some of these requests involves managing your assets in different ways to customise the experience how you want your NFTs to work in your integration.

Change Asset Name

Assets have their names specified on the blockchain and within their metadata. This means assets can, technically, be given a different name on the blockchain and in its metadata.
The following mutation can be used to update a token's name on the blockchain:
1
mutation UpdateTokenName($identityId: Int!, $itemNameData: UpdateItemNameInput!) {
2
CreateEnjinRequest(identityId: $identityId, type: UPDATE_NAME, update_item_name_data: $itemNameData)
3
{
4
id
5
encodedData
6
}
7
}
Copied!

Melt Batch Items

There may be times that you make a mistake during the asset minting process and you wish to melt all of the assets you have created.
To melt any asset, the asset must be in your wallet. It's important to quadruple-check your token settings prior to sending them to your users.
Once your assets have been distributed to your users, there is no going back and the only way to fix any errors is to generate replacement tokens.
1
mutation BatchMelt($identityId: Int!, $meltTokenData: MeltTokenInput!) {
2
CreateEnjinRequest(identityId: $identityId, type: MELT, melt_token_data: $meltTokenData) {
3
identityId
4
tokenId
5
}
6
}
Copied!

Release Reserve

When you first create an asset, you will be asked to lock an initial reserve on the Enjin Coin (ENJ) into it.
This is to ensure you can mint your tokens fluidly, using the Enjin Coin you have set aside.
If you no longer wish to use the asset and decide not to go ahead with minting the respective tokens, you can destroy the asset and return the Enjin Coin that you have set aside. You can do that by using the following mutation:
1
mutation ReleaseReserve($identityId: Int!, $tokenId: String!, $value: Int!) {
2
CreateEnjinRequest(identityId: $identityId, type: RELEASE_RESERVE, release_reserve_data: {token_id: $tokenId, value: $value}) {
3
tokenId
4
}
5
}
Copied!
There is a cool-down period for releasing reserve and the more Enjin Coin you have locked into the template, the longer you have to wait until you can release it. This waiting period can take days or even weeks.

Send All Item Types: Advanced Send

The Platform API allows you to send an unlimited amount of Fungible tokens and up to 100 Non-Fungible tokens to up to 1000 users, in a single transaction. The Advanced Send mutation is one of the most common mutations to send vast amounts of assets from one address to another in a single transaction and with ease.
This is the most robust and popular sending mutation used by developers:
1
mutation AdvancedSend($identityId: Int!, $tokenData: AdvancedSendTokenInput!) {
2
CreateEnjinRequest(identityId: $identityId, type: ADVANCED_SEND, advanced_send_token_data: $tokenData) {
3
id
4
encodedData
5
}
6
}
Copied!

Transfer Whitelisting

If you've created a bound token or a token with transfer fees, and you don't wish for these settings to apply in every circumstance, you can use transfer whitelisting to allow specific users to send tokens to specific addresses.
1
mutation WhitelistToken($identityId: Int!, $appId: Int!, $whitelistData: SetWhitelistedInput!) {
2
CreateEnjinRequest(identityId: $identityId, appId: $appId, type: SET_WHITELISTED, set_whitelisted_data: $whitelistData) {
3
id
4
encodedData
5
}
6
}
Copied!

Whitelist Settings

Full Rights: The address has full rights to send and receive the token. 0x0000000000000000000000000000000000000001
Can Send: The address can send but not receive the token. Which means that the only way they can get the token, is if you mint it directly to their address. 0x0000000000000000000000000000000000000002
Can Receive: The address can receive but can't send the token. 0x0000000000000000000000000000000000000003
No Fees: The address can send tokens without paying transfer fees. 0x0000000000000000000000000000000000000004

Asset Details, Holders & Transaction Data

If you wish to provide your users with detailed information about a specific asset, you can use this query to look up the data:
1
query GetTokenDetails($name: String!) {
2
EnjinTokens(name: $name, pagination: {page: 1, limit: 50}) {
3
id
4
name
5
creator
6
meltValue
7
meltFeeRatio
8
meltFeeMaxRatio
9
supplyModel
10
totalSupply
11
circulatingSupply
12
reserve
13
transferable
14
nonFungible
15
blockHeight
16
markedForDelete
17
createdAt
18
updatedAt
19
availableToMint
20
itemURI
21
}
22
}
Copied!

Token Holders

This query returns a list of addresses who own a specific token:
1
query GetBalance($tokenId: String!) {
2
EnjinBalances(tokenId: $tokenId) {
3
token {
4
id
5
index
6
}
7
wallet {
8
ethAddress
9
}
10
value
11
}
12
}
Copied!
It can be useful for rewarding all holders of a specific token in one go, through a coordinated airdrop.

Transaction Data

Whenever you issue a send mutation, a transaction id will be returned to you. This id is very important and it is highly advisable to log this data so you can access it again, at a later date.
Should you want to view the state of any transaction that you have performed on the blockchain, you will need to use this query:
1
query GetTransaction($id: Int!) {
2
EnjinTransactions(id: $id) {
3
id
4
transactionId
5
type
6
state
7
error
8
token {
9
id
10
name
11
}
12
}
13
}
Copied!
The Enjin Transactions query will return various pieces of information, depending on the state of the transaction that you have run.
You will notice that we added the error argument within the query. The error argument is useful to have, in case your transaction has failed/dropped for a certain reason. This will display why the transaction did not process on the network.
This query will return the following values:
  • PENDING: Transaction is created on the Enjiin Cloud, but has not yet been signed by the user/dev.
  • TP_PROCESSING: Transaction has been signed and is waiting for the Enjin Cloud/Platform) to process the transaction for broadcast.
  • BROADCAST: Transaction has been signed and has been broadcast but has not yet been confirmed on the blockchain.
  • EXECUTED: The transaction has received confirmation on the blockchain and the Enjin Cloud.
  • CANCELED_USER: The user has cancelled the PENDING transaction/not signed.
  • CANCELED_PLATFORM: The Platform has cancelled the PENDING transaction.
  • FAILED: Transaction has failed on the Enjiin Platform.
  • DROPPED: Transaction was not mined on the blockchain and has since been dropped.

Set Spending Allowance

If you want to increase the security of your project and set a spending limit for yourself, or allow your players to choose their own spending limits, you can use this mutation to set a spending allowance:
1
mutation ApproveEnj($id: String!, $limit: Int!) {
2
CreateEnjinRequest(
3
identityId: $id
4
type: APPROVE
5
approve_enj_data: { value: $limit }
6
) {
7
id
8
}
9
}
Copied!
Set value as -1 for max value.
This value decreases as it is used, like a literal spending allowance. If you set the value to 10 Enjin Coin (ENJ) and then make 10 transactions for 1 ENJ each, your allowance will go down to 0 and it will need to be set again.

Changing Asset Transfer Status

At times, you may want to change the transfer status of an asset that you've created to give it a certain value, whether you want the asset to be permanently transferable, temporarily transferable, or bound to an address.
The following mutation will allow you to change the asset transferable type:
GraphQL V1
GraphQL V2
1
mutation ChangeAssetTransferableType(
2
$appId: Int!
3
$identityId: Int!
4
$tokenId: String!
5
$transferable: TokenTransferable!
6
) {
7
CreateEnjinRequest(
8
appId: $appId
9
identityId: $identityId
10
type: SET_TRANSFERABLE
11
set_transferable_data: { token_id: $tokenId, transferable: $transferable }
12
) {
13
id
14
encodedData
15
}
16
}
Copied!
1
​
2
​
Copied!
If you set the token to be permanently transferable, you will not be able to alter that setting.
Last modified 2mo ago