Skip to main content

Start using Honeycomb Profiles

Introduction

Honeycomb Profiles let you take your existing users' Web2 profiles and bring them to Web3 with very little effort. This guide will show you how to get started with Honeycomb Profiles in your apps/games.

Prerequisites

Before starting this guide, please make sure to setup your development environment.

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 { client, sendTxns } from "@/utils"; // Import the client and sendTxns functions (covered in the dev environment setup)

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: {
customDataFields: [ // Specify an array of custom data fields that you can set on your users' profiles
"bugsReported"
]
}
});

await sendTxns(wallet, [txResponse]); // Send the transaction 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 { client, sendTxns } from "@/utils"; // Import the client and sendTxns functions (covered in the dev environment setup)

const {
createCreateProfilesTreeTransaction: txResponse // This is the transaction response, you'll need to sign and send this transaction through client.sendBulkTransactions
} = 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
},
advanced: {
maxDepth: 20,
maxBufferSize: 64,
canopyDepth: 14,
}
}
});

await sendTxns(wallet, [txResponse]); // Send the transaction to the blockchain

3. (Optional) Add badges to your project

Badges in Honeycomb Protocol are essentially achievements; these badges get added to users' profiles when they perform certain actions in your app/game. As a developer you'll have complete control over what those actions are and when the badges get added. You can even add limited edition badges that can only be earned during a certain time period.

To add badges to your project, use the following code:

import { client, sendTxns } from "@/utils"; // Import the client and sendTxns functions (covered in the dev environment setup)

const {
createCreateBadgeCriteriaTransaction: txResponse // This is the transaction response, you'll need to sign and send this transaction through client.sendBulkTransactions
} = await client.createCreateBadgeCriteriaTransaction({
args: {
authority: authorityPublicKey, // Project authority public key
projectAddress: projectAddress, // Project public key
payer: payerPublicKey, // Optional transaction payer public key
badgeIndex: 0, // Badge index as an integer, used to identify the badge
condition: BadgesCondition.Public, // Badge condition, only Public is available for now
startTime: 0, // Optional start time, UNIX timestamp
endTime: 0, // Optional end time, UNIX timestamp
},
});

await sendTxns(wallet, [txResponse]); // Send the transaction to the blockchain

4. Create Web3 profiles for your users

Whenenever a new user comes to your app/game, you can create a new Web3 profile for them using the following code:

import { client, sendTxns } from "@/utils"; // Import the client and sendTxns functions (covered in the dev environment setup)

const {
createNewUserWithProfileTransaction: txResponse // This is the transaction response, you'll need to sign and send this transaction through client.sendBulkTransactions
} = await client.createNewUserWithProfileTransaction({
project: projectAddress.toString(),
wallet: userPublicKey.toString(),
payer: adminPublicKey.toString(),
profileIdentity: "main",
userInfo: { // Optional
username: "Honeycomb Developer",
name: "John Doe",
bio: "This user is created for testing purposes",
pfp: "https://lh3.googleusercontent.com/-Jsm7S8BHy4nOzrw2f5AryUgp9Fym2buUOkkxgNplGCddTkiKBXPLRytTMXBXwGcHuRr06EvJStmkHj-9JeTfmHsnT0prHg5Mhg",
},
profileInfo: { // Optional
bio: "John Doe's Bio",
name: "John Doe",
pfp: "link-to-pfp"
}
});

await sendTxns(wallet, [txResponse]); // Send the transaction to the blockchain to create the user

5. (Optional) Add achievements to your users' profiles

If you added badges to your project, you'll now be able to give your users achievements.

Use the following code to do so:

import { client, sendTxns } from "@/utils"; // Import the client and sendTxns functions (covered in the dev environment setup)
import { BadgesCondition } from "@honeycomb-protocol/edge-client";

const { createClaimBadgeCriteriaTransaction: txResponse } =
await client.createClaimBadgeCriteriaTransaction({
args: {
criteriaIndex: 0, // Badge index as an integer, used to identify the badge, make sure to use the same badge index you used when creating the badge
profileAddress: profileAddress, // The user's profile address
projectAddress: projectAddress, // The project address
proof: BadgesCondition.Public, // The proof of the badge, only Public is available for now
payer: userPublicKey.toString(), // The transaction payer public key
},
});

await sendTxns(wallet, [txResponse]); // Send the transaction to the blockchain

6. (Optional) Add custom data to your users' profiles

If you added custom data fields to your project, you can assign values to these fields for your users.

import { client, sendTxns } from "@/utils"; // Import the client and sendTxns functions (covered in the dev environment setup)

const { createUpdateProfileTransaction: txResponse } =
await client.createUpdateProfileTransaction(
{
profile: profileAddress,
customData: {
add: {
bugsReported: ["10"],
},
},
payer: userPublicKey.toString(),
}
);