Missions
Pre-requisites
Please make sure that you've followed our getting started guide and set up your development environment.
You'll also need the following:
In order to participate in missions, your users will need to have created a profile for your project. They'll also need eligible characters that can go on the missions you create (more on this below).
Why use missions?
Missions can be used in a variety of ways, including:
- Idle rewards: Your players earn idle rewards while they're not actively playing, or interacting with, your game.
- Give players a reason to come back: Missions can be used to encourage your users to come back to your game. As a developer, you can create a mission that can be completed once a day, for example.
- Encourage players to explore: Developers can also create missions that require players to have certain characters. It's up to you to decide how players can get these characters. For example, you could create a mission that requires a character that can only be obtained by completing a certain quest in your game.
- Guild/clan missions (coming soon): Honeycomb Protocol will soon be implementing guilds. That way, a whole guild will be able to participate in missions and earn rewards together. The reward distribution mechanism will be decided by the guild leader.
Missions instructions
Create a mission pool
You'll begin by creating a mission pool. The purpose of a mission pool is to group missions together based on the criteria you define. For example, you could create a mission pool for all missions that require a certain character model. Users who don't have a character based on that model won't be able to participate in the missions in that pool.
- JavaScript
- GraphQL
- Unity/C#
const {
createCreateMissionPoolTransaction: {
missionPoolAddress, // The address of the mission pool
tx, // The transaction response, you'll need to sign and send this transaction
},
} = await client.createCreateMissionPoolTransaction({
data: {
name: "Test Mission Pool",
project: projectAddress.toString(),
payer: adminPublicKey.toString(),
authority: adminPublicKey.toString(),
delegateAuthority: delegateAuthority.toString(), // Optional
characterModel: characterModelAddress.toString(),
},
});
query CreateCreateMissionPoolTransaction($data: NewMissionPoolData!) {
createCreateMissionPoolTransaction(data: $data) {
tx {
transaction
blockhash
lastValidBlockHeight
}
missionPoolAddress
}
}
Provide the accompanying data:
{
"data": {
"name": "string", // The name of the mission pool
"project": "pubkey", // The project for which you're creating the mission pool
"authority": "pubkey", // Project authority pubkey
"delegateAuthority": "pubkey", // Optional, delegate authority pubkey
"payer": "pubkey", // Payer pubkey
"characterModel": "pubkey", // The character model that will be allowed to participate in missions in this pool
}
}
var createMissionPoolParams = new CreateCreateMissionPoolTransactionParams
{
Data = new NewMissionPoolData
{
Name = "Test Mission Pool", // Name of the mission pool
Project = projectAddress, // Project address
Payer = adminPublicKey, // Public key of the payer
Authority = adminPublicKey, // Public key of the project authority
DelegateAuthority = delegateAuthority, // Optional
CharacterModel = characterModelAddress // Character model address
}
}
// Create a mission pool transaction
var tx = await Client.CreateCreateMissionPoolTransaction(createMissionPoolParams)
// Extract mission pool address and transaction response from the result
var missionPoolAddress = tx.CreateCreateMissionPoolTransaction.MissionPoolAddress; // This is the mission pool address once created
var txResponse = tx.CreateCreateMissionPoolTransaction.Tx; // This is the transaction response, which you'll need to sign and send
Create a mission
In order to create a mission, you should already have a mission pool. Afterwards, here's how you can create a mission:
- JavaScript
- GraphQL
- Unity/C#
import { RewardKind } from "@honeycomb-protocol/edge-client";
const {
createCreateMissionTransaction: {
missionAddress, // The address of the mission
tx, // The transaction response, you'll need to sign and send this transaction
},
} = await client.createCreateMissionTransaction({
data: {
name: "Test mission",
project: projectAddress.toString(),
cost: {
address: resourceAddress.toString(),
amount: "100000",
},
duration: "86400", // 1 day
minXp: "50000", // Minimum XP required to participate in the mission
rewards: [
{
kind: RewardKind.Xp,
max: "100",
min: "100",
},
{
kind: RewardKind.Resource,
max: "25000000",
min: "50000000",
resource: resourceAddress.toString(),
},
],
missionPool: missionPoolAddress.toString(),
authority: adminPublicKey.toString(),
payer: adminPublicKey.toString(),
},
});
query CreateCreateMissionTransaction($data: NewMissionData!) {
createCreateMissionTransaction(data: $data) {
tx {
transaction
blockhash
lastValidBlockHeight
}
missionAddress
}
}
Provide the accompanying data:
{
"data": {
"project": "pubkey", // The project for which you're creating the mission
"missionPool": "pubkey", // The mission pool to which the mission belongs
"authority": "pubkey", // Project authority pubkey
"delegateAuthority": "pubkey", // Optional, delegate authority pubkey
"payer": "pubkey", // Payer pubkey
"name": "string", // The name of the mission
"minXp": "int", // The minimum XP required to participate in the mission, send it as a string
"cost": {
"address": "pubkey", // A valid project resource address, this cost will be deducted from the user's account when they participate in the mission
"amount": "int" // The amount of the resource required to participate in the mission, send it as a string
},
"duration": "int", // The duration of the mission in seconds (for example: 1 hour = 3600), send it as a string
"rewards": [
{
"kind": "string", // The kind of reward, valid values: "Xp" or "Resource"
"min": "int", // The minimum amount of the reward, send it as a string
"max": "int", // The maximum amount of the reward, send it as a string
"resource": "pubkey" // Optional, the resource address for the reward, only specify if the reward kind is "Resource"
}
]
}
}
var createMissionTransaction = await Client.CreateCreateMissionTransaction(new CreateCreateMissionTransactionParams
{
Data = new NewMissionData
{
Name = "Test mission",
Project = projectAddress.ToString(),
Cost = new MissionCost
{
Resource_address = resourceAddress.ToString(),
Amount = "100000"
},
Duration = "86400", // 1 day
MinXp = "50000", // Minimum XP required to participate in the mission
Rewards = new List<MissionReward>
{
new MissionReward
{
Kind = RewardKind.Xp,
Max = "100",
Min = "100"
},
new MissionReward
{
Kind = RewardKind.Resource,
Max = "25000000",
Min = "50000000",
Resource = resourceAddress.ToString()
}
},
MissionPool = missionPoolAddress.ToString(),
Authority = adminPublicKey.ToString(),
Payer = adminPublicKey.ToString()
}
});
var missionAddress = createMissionTransaction.MissionAddress; // Address of the created mission
var tx = createMissionTransaction.Tx; // Transaction response, to be signed and sent
Send characters on mission
This transaction will send a player's character(s) on an eligible mission:
- JavaScript
- GraphQL
- Unity/C#
const {
createSendCharactersOnMissionTransaction: txResponse // This is the transaction response, you'll need to sign and send this transaction
} = await client.createSendCharactersOnMissionTransaction({
data: {
mission: missionAddress.toString(),
characterAddresses: [
characterAddress.toString(),
],
authority: userPublicKey.toString(),
payer: payerPublicKey.toString(), // Optional
},
});
query CreateSendCharactersOnMissionTransaction($data: ParticipateOnMissionData!) {
createSendCharactersOnMissionTransaction(data: $data) {
transactions
blockhash
lastValidBlockHeight
}
}
{
"data": {
"mission": "pubkey", // The mission for which you're sending characters
"characterAddresses": ["pubkey"], // An array of character addresses that you're sending on the mission, these characters must be eligible to participate in the mission
"authority": "pubkey", // User pubkey, the user must own these characters
"payer": "pubkey" // Optional, payer pubkey
}
}
var sendCharactersOnMissionParams = new CreateSendCharactersOnMissionTransactionParams
{
Data = new ParticipateOnMissionData
{
Mission = missionAddress.ToString(), // Mission address
CharacterAddresses = new List<string>
{
characterAddress.ToString(), // Character address
},
Authority = userPublicKey.ToString(), // Public key of the authority
Payer = payerPublicKey.ToString(), // Optional: public key of the payer
}
};
// Create a send characters on mission transaction
var txResponse = await Client.CreateSendCharactersOnMissionTransaction(sendCharactersOnMissionParams); // This is the transaction response, you'll need to sign and send this transaction
Recall characters from a mission
Once a mission's duration has ended, you can recall characters from the mission. Recalling will automatically claim any rewards that the characters have earned. If you recall before the mission's duration has ended, the characters will not receive any rewards.
Here's the transaction for recalling characters:
- JavaScript
- GraphQL
- Unity/C#
const {
createRecallCharactersTransaction: txResponse // This is the transaction response, you'll need to sign and send this transaction
} = await client.createRecallCharactersTransaction({
data: {
mission: missionAddress.toString(),
characterAddresses: [
characterAddress.toString()
],
authority: userPublicKey.toString(),
payer: payerPublicKey.toString(), // Optional
},
lutAddresses: [lookupTableAddress],
});
query CreateRecallCharactersTransaction($data: RecallFromMissionData!) {
createRecallCharactersTransaction(data: $data) {
transactions
blockhash
lastValidBlockHeight
}
}
{
"data": {
"mission": "pubkey", // The mission from which you're recalling characters
"characterAddresses": ["pubkey"], // An array of character addresses that you're recalling from the mission
"authority": "pubkey", // User pubkey, the user must own these characters
"payer": "pubkey" // Optional, payer pubkey
}
}
var recallCharactersParams = new CreateRecallCharactersTransactionParams
{
Data = new RecallFromMissionData
{
Mission = missionAddress.ToString(), // Mission address
CharacterAddresses = new List<string>
{
characterAddress.ToString() // Character address
},
Authority = userPublicKey.ToString(), // Public key of the authority
Payer = payerPublicKey.ToString(), // Optional: public key of the payer
},
LutAddresses = new List<string>
{
lookupTableAddress // Lookup table address
}
};
// Create a recall characters transaction
var txResponse = await Client.CreateRecallCharactersTransaction(recallCharactersParams); // This is the transaction response, you'll need to sign and send this transaction
Fetching a character's history
Please see the character history guide to learn how to fetch a character's history.