Send request to user to approve enj use on app
mutation ApproveEnj {
CreateEnjinRequest (
identityId: XX,
type: APPROVE,
approve_enj_data:{ value: XXXXXXX, }
){
id,
}
}
Set value as -1 for max value
Note that this value decreases as it is used, like a literal spending allowance, if you set a value fo 10 ENJ and then make 10 transactions for 1 ENJ each your allowance will then be 0 and need to be set again.
If a user has already confirmed enj spend and wants to change the value or set to max again it first has to be reset by setting value to 0
Set a token to be bound to a wallet or have temporary freedom of movement, or lift the restriction
mutation setBound{
CreateEnjinRequest
(
identityId: XXXX,
type: SET_TRANSFERABLE,
set_transferable_data:
{
token_id: "00000000000000",
token_index: "00000000000000",
transferable: BOUND
}
)
{
id
}
}
transferable: PERMANENT, TEMPORARY, BOUND.
Changes the name of a token
mutation changeNFTname {
CreateEnjinRequest(
identityId: XX,
type: UPDATE_NAME,
update_item_name_data: {
token_id: "xxxxxxxxxxxxxxxx",
name: "NEW NAME HERE",
})
{
id
encodedData
}
}
Shows the users identityId, wallet or linking details
query fetchUserData{
EnjinUser(name: "$userId")
{
identities{
id
linkingCode
linkingCodeQr
wallet{
ethAddress
ethBalance
enjBalance
enjAllowance
}
}
}
}
Creates players as an identity for your app
"CreateEnjinUser(name:\"".$playerid."\"){".
"identities {".
"id,".
"linkingCode,".
"linkingCodeQr,".
"}".
"}".
Creates a token on the Enjin Trusted Platform
mutation createTokenRequest {
CreateEnjinRequest (
identityId: XXX,
type: CREATE,
create_token_data: {
name: "TokenName",
totalSupply: 100,
initialReserve: 100,
supplyModel: INFINITE,
meltValue: "1000000000000000000",
meltFeeRatio: 0,
transferable: PERMANENT,
transferFeeSettings: {
type: PER_CRYPTO_ITEM,
token_id: "0",
value: "1000000000000000000"
}
nonFungible: false
}){
id,
encodedData
}
}
supplyModel Types: FIXED, INFINITE, COLLAPSING.
Transfer Types: PERMANENT, TEMPORARY, BOUND.
Transfer Fee Type: NONE, PER_TRANSFER, PER_CRYPTO_ITEM, RATIO_CUT, RATIO_EXTRA, TYPE_COUNT.
Non-Fungible or Fungible, true or false.
Melt Fee Ratio: Value returned to the developer, range 0-5000, eg 1 = 0.01%, 5000 = 50%.
Shows you your Indentity_Id which is used in most queries and mutations
query viewIdentities {
EnjinIdentities(
pagination: {
page: 1,
limit: 50})
{
id
app {
name
}
linking_code
linking_code_qr
enj_allowance
ethereum_address
}
}
Gets player details from identity_id
query viewIdentities
{
EnjinIdentities(id:XXXXXX)
{
wallet
{
ethBalance,
enjBalance,
enjAllowance,
}
}
}
Find secret key for app for creating auth tokens
query myApp{
EnjinApps(id:XX){
secret
}
}
Get auth tokens for making graph calls
query GetAccessToken{
AuthApp(id:XX, secret: "appSecret"){
accessToken
expiresIn
}
}
Melt NFT's in batches
mutation BatchMelt{
CreateEnjinRequest (
identityId: YOUR_IDENTITY_ID,
type:MELT,
melt_token_data: {
token_id: "xxxxxxxxxxxxxxxx",
token_index_array: [
"xxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxx",
],
#value_array: "",
}
) {
identityId
tokenId
}
}
Force meta data to update
mutation refreshTokenMeta {
InvalidateTokenMetadata(id: "xxxxxxxxxxxxxxxx")
}
Mint items that are not unique
mutation mintFungibleItems {
CreateEnjinRequest(
identityId: YOUR_IDENTITY_ID,
appId: XXX,
type: MINT,
mint_token_data: {
token_id: "xxxxxxxxxxxxxxxx",
recipient_address_array: [
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
],
value_array: [
HOW_MANY,
HOW_MANY
]}) {
id
encoded_data
}
}
Mint items that are unique
mutation mintNonFungibleItems {
CreateEnjinRequest(
identityId: YOUR_IDENTITY_ID,
appId: XXX,
type: MINT,
mint_token_data: {
token_id: "xxxxxxxxxxxxxxxx",
token_index: "0",
recipient_address_array: [
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
]}) {
id
encoded_data
}
}
Returns ENJ that was locked in as Initial Reserve for an item you no longer wish to use
mutation releaseReserve {
CreateEnjinRequest(
identityId: XXX,
type: RELEASE_RESERVE,
release_reserve_data: {
token_id: "xxxxxxxxxxxxxxxx",
value: X,
}
)
{
tokenId
}
}
Send Enj
mutation sendENJ {
CreateEnjinRequest(
identityId: SENDERS_IDENTITY_ID,
type: SEND_ENJ,
send_enj_data:
{
to: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
value: "1000000000000000000"
}
)
{
id
encodedData
}
}
value is in gwei the above example = 1 Enj
please note that at the time of writing this the notifications for confirming the send enj are displaying the amount / 10. Meaning instead of 1 enj shows 0.1, but it does send 1 enj
Send multiple Fungible and nonFungible together, no index on Fungible tokens
mutation advancedSendAll {
CreateEnjinRequest(
identityId: YOUR_IDENTITY_ID,
type: ADVANCED_SEND,
advanced_send_token_data: {transfers: [
{token_id: "xxxxxxxxxxxxxxxx", token_index: "xxxxxxxxxxxxxxxx", to: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", value:"1" },
{token_id: "xxxxxxxxxxxxxxxx", token_index: "xxxxxxxxxxxxxxxx", to: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", value:"1" },
{token_id: "xxxxxxxxxxxxxxxx", token_index: "xxxxxxxxxxxxxxxx", to: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", value:"1" },
{token_id: "xxxxxxxxxxxxxxxx", token_index: "xxxxxxxxxxxxxxxx", to: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", value:"1" },
{token_id: "xxxxxxxxxxxxxxxx", to: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", value:"1" },
{token_id: "xxxxxxxxxxxxxxxx", to: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", value:"1" }
]})
{
id
encodedData
transactionId
}
}
Sets the URI of a token
mutation changeURI {
CreateEnjinRequest (
identityId: XXX,
type: SET_ITEM_URI,
set_item_uri_data: {
token_id: "xxxxxxxxxxxxxxxx",
token_index: "xxxxxxxxxxxxxxxx",
item_uri: "https://xxxxxxxxxxxxxxxx.com/xxxxxxxxxxxxxxxx"
})
{
id
encodedData
state
}
}
To have 1 URI for all tokens -
Dynamic URI Guide
Gives detailed information about a specific token
query viewTokens {
EnjinTokens(
name: "TOKEN_NAME",
pagination: {
page: 1,
limit: 50})
{
appId
id
name
creator
meltValue
meltFeeRatio
meltFeeMaxRatio
supplyModel
totalSupply
circulatingSupply
reserve
transferable
nonFungible
blockHeight
markedForDelete
createdAt
updatedAt
availableToMint
itemURI
}
}
Token details from token ID. Can also be used to find the appID of a token you did not create.
getBalanceByTokenNotAddress {
EnjinBalances(
tokenId: "XXXXXXXXXXXXXXXXX"
appIds: []
value_gte: 1
){
token{
id
name
app{
id
}
}
}
}
App ID Finder if you just want to know the App Id right now.
Returns the addresses that have a specific token
query getBalanceByTokenNotAddress {
EnjinBalances(
tokenId: "XXXXXXXXXXXXXXXXX",
) {
index
value
wallet{
ethAddress
}
}
}
View transaction information
query ViewTransactionData{
EnjinTransactions(
id: xxxxx,
) {
id
transactionId
type
state
recipientAddress
createdAt
token {
id
name
},
events {
param1
},
}
}
3 steps to a full trade
1: create trade request - confirm in 1st persons wallet - use token id:"0" for ENJ
mutation sendTradeRequest {
CreateEnjinRequest (
identityId: XXX,
type: CREATE_TRADE,
create_trade_data:{
asking_tokens: [{ id: "XXXXXXXXXXXXXXXXX", value: 1 }],
offering_tokens: [{ id: "XXXXXXXXXXXXXXXXX", value: 1 }],
second_party_identity_id: XXX
})
{
id
transactionId
encodedData
state
}
}
2: get the trade_id - param1
query idForCompleteTrade{
EnjinTransactions(id:XXXXXX){
type,
transactionId,
events { param1 }
}
}
3: complete the trade request - entering param1 as trade_id, 2nd persons identity_id and confirm in 2nd persons wallet
mutation completeTradeRequest {
CreateEnjinRequest (
identityId: XXX,
type: COMPLETE_TRADE,
complete_trade_data:
{
trade_id: "XX"
})
{
id
transaction|Id
encodedData
}
}
Unlinks a wallet so a user can re-link
mutation UnlinkIdentity {
identity: UnlinkIdentity(id: XXX) {
id
linkingCode
linkingCodeQr
}
}
Displays Token_Name and Token_Id for tokens found in wallet
query balances {
EnjinBalances(
ethAddress: "WALLET_ADDRESS",
value_gte: 1,
appIds: [APP_ID1, APP_ID2],
pagination: {limit: 500, page: 1})
{
items {
index
id
value
identity {
id
}
wallet {
ethAddress
}
app {
id
}
}
cursor {
total
hasPages
perPage
currentPage
lastPage
}
}
}
EnjinBalances
ethAddress: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
value_gte: 0 -> shows melted items as they technically still belong to that wallet
Displays Token_Index for a specific token found in wallet
query getBalance {
EnjinBalances(
ethAddress: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
tokenId: "XXXXXXXXXXXXXXXXX",
value_gte: 1) {
token {
name
id
}
index
value
}
}
EnjinBalances(
ethAddress: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
tokenId: "XXXXXXXXXXXXXXXXX",
value_gte: 0 -> shows melted items as they technically still belong to that wallet
Removes fees for a given wallet address per token
mutation WhiteList{
CreateEnjinRequest (
identityId: XXX,
appId: XXX,
type: SET_WHITELISTED,
set_whitelisted_data: {
token_id: "XXXXXXXXXXXXXXXXX",
account: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
whitelisted: "0x0000000000000000000000000000000000000004",
on: true
}
) {
id,
encodedData
}
}
account = address
0x0000000000000000000000000000000000000001 - Send & Receive
0x0000000000000000000000000000000000000002 - Send
0x0000000000000000000000000000000000000003 - Receive
0x0000000000000000000000000000000000000004 - No Fees
1 URI to rule them all
Set all token URI as
https://yourDomain.com/yourPage?token_details={id}
{id} is auto filled by wallet/enjinx when query token data
yourPage then splits token_details to get 'id' and 'index'
then your page pulls relevant data from database for the 'id' and 'index'
and outputs the relevant json
For NFT's make a database entry for the base (starting version) of the NFT. Meaning it has the NFT's ID, and and Index of 0000000000000000.
When your URI page looks for an entry with the exact id and index, if there is no entry in the database that matches the index, request the base version with id and index of 0000000000000000 from your database. This way you only need to have database entries for each NFT index that has actually had values changed.
php example
Split token_details
The first 16 characters is the id
The last 16 characters is the index
$id = substr($token_index, 0, 16);
$index = substr($token_index, -16);
Check database for id and index match
If a match display data in json
If not a match, fetch the data for the base version with index of 0000000000000000
Then display data in json
php example
$arr = array(
"name" => "".$name." - ".$level."",
"description" => "".$description."",
"image" => "".$img_url."",
"properties" => array(
"Game" => "Kingdom Karnage",
"Website" => "KepithorStudios.com",
)
);
if($quality != ""){
$arr['properties']['Quality'] = $quality;
}
if($level != 0){
$arr['properties']['Level'] = $level;
}
if($race != ""){
$arr['properties']['Race'] = $race;
}
if($abilityname_1 != ""){
$arr['properties'][$abilityname_1] = $ability_list[$abilityname_1];
}
if($abilityname_2 != ""){
$arr['properties'][$abilityname_2] = $ability_list[$abilityname_2];
}
if($abilityname_3 != ""){
$arr['properties'][$abilityname_3] = $ability_list[$abilityname_3];
}
if($note != ""){
$arr['properties']['Note'] = $note;
}
echo json_encode($arr, JSON_UNESCAPED_SLASHES);