Skip to main content

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

  1. Create or launch your Unity project

  2. Open the Unity Package Manager window

  3. Click on the + button in the status bar (top left corner)

  4. Choose Add package from Git URL from the drowdown and a text field will appear

  5. Enter the following URL and click Add to install Honeycomb's Solana SDK

    https://github.com/Honeycomb-Protocol/Solana.Unity-SDK.git
  6. 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

note

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

note

Making any transactions on the Honeynet (our test RPC) would require having Honeynet SOL in your wallet. So make sure to fund your wallet on Honeynet before proceeding with this guide.

You can do so using the following command if you haven't already.

solana airdrop <amount> <wallet address> -u https://rpc.test.honeycombprotocol.com

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
);