Skip to main content

Add characters to your game

Introduction

Characters are the heart of any game. They are the entities that interact with the world and the players. Honeycomb Protocol lets you create characters in a variety of ways. Developers have the option to create characters out of NFTs, or they can create Honeycomb native characters that don't require their players to have any NFTs to begin with.

What are characters in Honeycomb Protocol?

Characters in Honeycomb Protocol are basically compressed assets that are stored in a merkle tree. These characters can have a variety of attributes, stats, and even resources equipped to them. They can be used to represent a variety of in-game elements, like individual players in your game, cards in your players' inventories, pets that your players have collected, and so much more; the possibilities are endless.

Step by step guide

1. Create a project

A project in Honeycomb represents an app/game you want to use with Honeycomb Protocol. To create a project, use the following code:

import { useWallet } from "@solana/wallet-adapter-react";
import { sendClientTransactions } from "@honeycomb-protocol/edge-client/client/walletHelpers";
import { client } from "@/utils"; // Import the client (covered in the dev environment setup)

const wallet = useWallet();

const {
createCreateProjectTransaction: {
project: projectAddress, // Save this project address in your database, you'll need it to interact with the Web3 side of your app
tx: txResponse, // This is the transaction response you'll need to send to the blockchain after signing
},
} = await client.createCreateProjectTransaction({
name: "My First Project",
authority: authorityPublicKey, // The wallet public key of the authority, the authority has complete control over the project
payer: payerPublicKey, // The wallet public key of the payer, the payer pays for the transaction fees
profileDataConfig: {
achievements: [ // Specify an array of achievements that you can give to your users
"Pioneer"
],
customDataFields: [ // Specify an array of custom data fields that you can set on your users' profiles
"bugsReported"
]
}
});

await sendClientTransactions(client, wallet, txResponse); // Get the transaction signed by the user and send it to the blockchain

2. Create a profiles tree

On Solana, when you use compression to store data, you need to use merkle trees. Honeycomb Protocol uses a merkle tree to store user profiles. To create a profiles tree, use the following code:

import { useWallet } from "@solana/wallet-adapter-react";
import { sendClientTransactions } from "@honeycomb-protocol/edge-client/client/walletHelpers";
import { client } from "@/utils"; // Import the client (covered in the dev environment setup)

const wallet = useWallet();

const {
createCreateProfilesTreeTransaction: txResponse // This is the transaction response, you'll need to sign and send this transaction
} = await client.createCreateProfilesTreeTransaction({
payer: adminPublicKey.toString(),
project: projectAddress.toString(),
treeConfig: {
// Provide either the basic or advanced configuration, we recommend using the basic configuration if you don't know the exact values of maxDepth, maxBufferSize, and canopyDepth (the basic configuration will automatically configure these values for you)
basic: {
numAssets: 100000, // The desired number of profiles this tree will be able to store
},
// Uncomment the following config if you want to configure your own profile tree (also comment out the above config)
// advanced: {
// maxDepth: 20,
// maxBufferSize: 64,
// canopyDepth: 14,
// }
}
});

await sendClientTransactions(client, wallet, txResponse); // Get the transaction signed by the user and send it to the blockchain

3. Pick a character creation method

Honeycomb Protocol offers three methods to create characters:

  1. Wrapping: Wrapping freezes the NFT and creates a new Honeycomb character from it. Your players will need to have an eligible NFT in their wallet to create a character. It's important to note that the characters' metadata (traits) cannot be updated once they are created using this method. To use this method, please visit the the wrapping characters page.
  2. Assembling with an NFT: This method lets you take over the update authority for that NFT and creates a new Honeycomb character. Your players will need to have an eligible NFT in their wallet to create a character. This method allows you to update the characters' traits and appearance in the future. To use this method, please visit the assembling characters page.
  3. Assembling a Honeycomb native character: This method creates a Honeycomb character without an NFT. This method doesn't require your players to have any NFTs in their wallet. This method also allows you to update the characters' traits and appearance in the future. To use this method, please visit the assembling characters page.