Equipping Resources on Characters
Pre-requisites
Before you can fetch history for a character, you'll need the following:
- A project
- At least one created/imported Honeycomb Resource
- At least one character
Intro
Honeycomb Protocol has a rich inventory and resource system that allows your players to equip resources on characters to boost a character's stats or abilities. This guide will show you how to incorporate these elements in your game.
Equipping Resources
Before equipping the resources, please make sure that your players have both the character and the resource that's being equipped in their inventory. Otherwise, this transaction will fail.
Once you make perform the pre-requisite checks, here's how you can equip the resource:
- JavaScript
- GraphQL
- Unity/C#
const {
createEquipResourceOnCharacterTransaction: txResponse // The transaction response that you have to get signed and send the transaction
} =
await client.createEquipResourceOnCharacterTransaction({
characterModel: characterModelAddress.toString(), // The address of the character model
characterAddress: characterAddress.toString(), // The character the resource is being equipped to
resource: resourceAddress.toString(), // The address of the resource being equipped
owner: userPublicKey.toString(), // The public key of the owner
amount: "1000", // The amount of the resource being equipped
});
query createEquipResourceOnCharacterTransaction($characterModel: Bytes!, $characterAddress: Bytes!, $resource: Bytes!, $owner: Bytes!, $amount: String!) {
createEquipResourceOnCharacterTransaction(
characterModel: $characterModel,
characterAddress: $characterAddress,
resource: $resource,
owner: $owner,
amount: $amount
) {
blockhash
lastValidBlockHeight
transaction
}
}
Provide the following parameters to the query:
{
"characterModel": "pubkey", // Character model address in string format
"characterAddress": "pubkey", // Character address in string format
"resource": "pubkey", // Resource address in string format
"owner": "pubkey", // Owner's public key
"amount": "1000" // Amount of resource to equip
}
var equipResourceOnCharacterTransactionParams = new CreateEquipResourceOnCharacterTransactionParams
{
CharacterModel = characterModelAddress, // The address of the character model
CharacterAddress = characterAddress, // The character the resource is being equipped to
Resource = resourceAddress, // The address of the resource being equipped
Owner = ownerPublicKey, // The address of the resource being equipped
Amount = "1000" // The amount of the resource being equipped
};
var tx = await Client.CreateEquipResourceOnCharacterTransaction(equipResourceOnCharacterTransactionParams); // The transaction response that you have to get signed and send the transaction
Unequipping/Dismounting Resources
To unequip or dismount a resource from a character, you can use the following query:
- JavaScript
- GraphQL
- Unity/C#
const {
createDismountResourceOnCharacterTransaction: txResponse // The transaction response that you have to get signed and send the transaction
} =
await client.createDismountResourceOnCharacterTransaction({
characterModel: characterModelAddress.toString(), // The address of the character model
characterAddress: characterAddress.toString(), // The character the resource is being unequipped from
resource: resourceAddress.toString(), // The address of the resource being unequipped
owner: userPublicKey.toString(), // The public key of the owner
amount: "1000", // The amount of the resource being unequipped
});
query createDismountResourceOnCharacterTransaction($characterModel: Bytes!, $characterAddress: Bytes!, $resource: Bytes!, $owner: Bytes!, $amount: String!) {
createDismountResourceOnCharacterTransaction(
characterModel: $characterModel,
characterAddress: $characterAddress,
resource: $resource,
owner: $owner,
amount: $amount
) {
blockhash
lastValidBlockHeight
transaction
}
}
var dismountResourceOnCharacterTransactionParams = new CreateDismountResourceOnCharacterTransactionParams
{
CharacterModel = characterModelAddress, // The address of the character model
CharacterAddress = characterAddress, // The character the resource is being uequipped to
Resource = resourceAddress, // The address of the resource being unequipped
Owner = ownerPublicKey, // The address of the resource being unequipped
Amount = "1000" // The amount of the resource being unequipped
};
var tx = await Client.CreateDismountResourceOnCharacterTransaction(dismountResourceOnCharacterTransactionParams); // The transaction response that you have to get signed and send the transaction