Skip to main content

Godot Development Environment Setup

Godot is a powerful engine designed to support all sorts of projects. You can use it to create games or applications you can then release on desktop or mobile, as well as on the web.

Using our Solana SDK with Godot is a great way to create blockchain games or applications. This guide will show you how to set up your development environment to start building with Godot and our Solana SDK.

Pre-requisites

Before you start, make sure you have the following:

1. Setup your application

  1. Download the latest release of Godot Solana SDK.
  2. Open your project in Godot.
  3. Right click on the res:// folder in the file system dock on the left side of the Godot editor.
  4. Click on Open in File Manager.
  5. Create a new folder called bin in the root of your project folder.
  6. Extract and place the binaries you downloaded in step 1 in your project's res://bin/ folder.
  7. Add your authority keypair to the res:// folder (the root of your project folder).
  8. Reload your project by clicking Project > Reload Current Project in the top-left corner and you will have Solana SDK (along with Honeycomb Protocol) available in your project as additional nodes and resources.

2. Add the Honeycomb node to your scene

  • Click the '+' button in the Scenes dock on the left side of the Godot editor and create a new Honeycomb node.
  • Create/open the linked script for the Honeycomb node.

3. Set up Edge Client:

extends Node
var client: HoneyComb

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
client = HoneyComb.new()
client.set_honeycomb_url("https://edge.main.honeycombprotocol.com")

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

4. Add helper functions to extract and send transactions

func extract_transaction(response: Dictionary):
if response.has("tx"):
return response.tx.transaction
elif response.has("transaction"):
return response.transaction
return ""

func send_transaction_func(encoded_transaction: String, signers: Array[Keypair], skip_preflight: bool = false):
var decoded_tx = SolanaUtils.bs58_decode(encoded_transaction)
var transaction: Transaction= Transaction.new_from_bytes(decoded_tx)
add_child(transaction)

transaction.set_signers(signers)
print("Signing transaction...")
transaction.partially_sign(signers)
transaction.skip_preflight = skip_preflight
transaction.send()
return transaction

func process_transaction(encoded_transaction: String, signers: Array[Keypair], skip_preflight: bool = false):
var tx = await send_transaction_func(encoded_transaction, signers, skip_preflight)
if not tx:
print("Failed to create transaction")
return

print("Transaction sent, awaiting response...")
var response = await tx.transaction_response_received
tx.queue_free()

return response

5. Create and send a transaction

extends Node
var client: HoneyComb

# Import authority keypair for signing the transaction
var authority: Keypair = Keypair.new_from_file("res://authority.json")

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
client = HoneyComb.new()
client.set_honeycomb_url("https://edge.test.honeycombprotocol.com")

# Create a project
client.create_create_project_transaction("Authority Publickey", "Project Name")
var response = await client.query_response_received

# Extract the project address from the response
var project_address = response.createCreateProjectTransaction.projectAddress

# Extract the transaction from the response
var encoded_tx = extract_transaction(response.createCreateProjectTransaction)

# Process and send the transaction
if not encoded_tx.is_empty():
await process_transaction(encoded_tx, [authority])

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass