Skip to main content

Token Groups

GraphQL Endpoint

https://platform.beta.enjin.io/graphql

A token group is an on-chain bucket of tokens within a single collection — see Token Groups Queries for the read side. All token-group actions are submitted through CreateTransaction, with the action selected by the field set on the transaction input. The response shape is always a Transaction — the examples below all return the standard { uuid, action, state } selection.

createTokenGroup

Creates an empty token group inside a collection. Once the transaction finalizes, a MultiTokens.TokenGroupCreated event is emitted containing the new group's id (assigned by the chain) — see Working with Events for how to read it. You can also list the collection's groups after the fact via GetCollection.tokenGroups.

mutation CreateTokenGroup {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
createTokenGroup: { collectionId: 2967 }
}
) {
uuid
action
state
}
}

destroyTokenGroup

Destroys an existing token group. The group must be empty (no tokens) — remove tokens first with removeTokenFromGroup or setTokenGroups.

mutation DestroyTokenGroup {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
destroyTokenGroup: { id: 694 }
}
) {
uuid
action
state
}
}

addTokenToGroup

Adds a single token to a group.

mutation AddTokenToGroup {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
addTokenToGroup: {
collectionId: 2967
tokenId: 107002853660685728525072975374659356720
groupId: 694
}
}
) {
uuid
action
state
}
}

removeTokenFromGroup

Removes a single token from a group.

mutation RemoveTokenFromGroup {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
removeTokenFromGroup: {
collectionId: 2967
tokenId: 107002853660685728525072975374659356720
groupId: 694
}
}
) {
uuid
action
state
}
}

setTokenGroups

Replaces the full set of groups a token belongs to. Pass groupIds: [] to remove the token from every group at once.

mutation SetTokenGroups {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
setTokenGroups: {
collectionId: 2967
tokenId: 107002853660685728525072975374659356720
groupIds: [694, 692]
}
}
) {
uuid
action
state
}
}

setTokenGroupAttribute

Set or update a single key/value attribute on a token group. The collection-and-group identification uses just id (the token-group id), not a (collectionId, groupId) pair.

mutation SetTokenGroupAttribute {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
setTokenGroupAttribute: {
id: 694
key: "uri"
value: "https://example.com/metadata/token-groups/epochrome-sword.json"
}
}
) {
uuid
action
state
}
}

removeTokenGroupAttribute

Remove a single attribute from a token group.

mutation RemoveTokenGroupAttribute {
CreateTransaction(
network: ENJIN
chain: MATRIX
transaction: {
removeTokenGroupAttribute: {
id: 694
key: "uri"
}
}
) {
uuid
action
state
}
}

Adding a token to a group at creation time

When you create a new token via createToken, you can include groups: [...] in the input to add it to one or more existing groups immediately — no follow-up addTokenToGroup call needed.

transaction: {
createToken: {
recipient: "efRecipientAddress"
collectionId: 2967
tokenId: 12345
initialSupply: 1
listingForbidden: false
infusion: 0
anyoneCanInfuse: false
groups: [694]
}
}