Unity Development Environment Setup
Setting up your Unity development environment for Honeycomb Protocol requires installing our package alongside the Unity engine. This guide will walk you through the steps to set up your Unity application and start using the Honeycomb Protocol SDK.
1. Setup your application
-
Create or launch your Unity project
-
Open the Unity Package Manager window
-
Click on the + button in the status bar (top left corner)
-
Choose Add package from Git URL from the drowdown and a text field will appear
-
Enter the following URL and click Add to install Honeycomb's Solana SDK
https://github.com/Honeycomb-Protocol/Solana.Unity-SDK.git
-
Once the installation is done, repeat steps 2 through 4 and then enter the following URL to install our Unity SDK
https://github.com/Honeycomb-Protocol/Unity-SDK.git
2. Install and configure your Solana wallet
- For wallet installation and configuration, please refer to the Solana Unity SDK installation documentation here.
You can also import the Sample Scene that comes with this SDK, which has a configured wallet for quick testing and demonstration.
3. Use the Honeycomb client
To use the Honeycomb client in your application, simply create a new instance of HplClient
and use it to interact with the blockchain. Below are the steps to set up the client and send a transaction.
1. Set up the Edge Client
Create a new instance of the client in any class you want to use it. For example, you can create a static class to hold the client instance like this:
using HplEdgeClient.Client;
public static class Honeycomb
{
private const string API_URL = "https://edge.test.honeycombprotocol.com/";
public static HplClient Client { get; } = new HplClient(API_URL);
}
2. Sign and send the transaction
In most cases when you interact with the Edge Client to perform actions like creating a user, mining resources, or sending characters on missions, you will receive a JSON object containing the last valid block height, the block hash, and the serialized transaction.
The serialized transaction is sent in response so developers can get it signed by the proper authority before sending it to the blockchain.
Here's how you can use the client to create a project:
First, import the required namespaces at the top of your script.
using HplEdgeClient.Params;
using HplEdgeClient.Helpers;
Afterwards, you can use the following utility function to sign and execute the transaction on the blockchain.
var tx = await Client.CreateCreateProjectTransaction(
new CreateCreateProjectTransactionParams
{
Name = "My Project", // Set the name of the project
Authority = "My Authority" // Set the authority for the project
}
);
// Initialize a TransactionHelper with the created transaction
var txHelper = new TransactionHelper(
tx.CreateCreateProjectTransaction.Tx // Extract the transaction object
);
// Sign the transaction
await txHelper.Sign();
// Send the signed transaction
var res = await Client.SendBulkTransactions(
txHelper.ToSendParams() // Populates the transaction parameters for sending
);