> For the complete documentation index, see [llms.txt](https://developer.opzeknd.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.opzeknd.xyz/unity-sdk/unity-+-truffle-+-zeknd-template.md).

# Unity + Truffle + zeknd Template

## Overview <a href="#overview" id="overview"></a>

A template for a zeknd DAppChain with a Unity client. Contains:

* Template `Blueprint` Solidity contract implementing a basic string-to-string map. Perfect as a starting point.
* Pre-configured Truffle project that automatically extracts ABIs and binaries of compiled contracts into corresponding folders.
* Pre-configured optimally setup Unity project with `Blueprint` contract test scene, and an already included zeknd SDK.

## #Template Structure <a href="#template-structure" id="template-structure"></a>

```
├── DAppChain/
│   ├── build/ # zeknd binary and app/blockchain state data will be stored here
│   │   ├── contracts/ # Compiled contracts .bin will go here
│   │   └── ...
│   ├── start-chain.sh # Starts the zeknd DAppChain
│   ├── reset-and-start-chain.sh ## Resets app/blockchain state and starts the zeknd DAppChain
│   ├── genesis.json # Change this file when changing/adding contracts
│   └── ...
├── TruffleProject/
│   └── ...
└── UnityClient/ # Unity client project
    ├── Assets/
    │   ├── Contracts/ # Contract ABIs will go here
    │   └── ...
    └── ...
```

***

### #Getting the Template <a href="#getting-the-template" id="getting-the-template"></a>

First, you need to install Truffle, if it isn't installed already:

```
npm install -g truffle
```

After that, you can download the template itself:

```
git clone https://github.com/zekndnetwork/zeknd-unity-project-template.git
```

Feel free to rename the zeknd`-unity-project-template` folder right away according to the name of your project.

### #Building the Truffle Project <a href="#building-the-truffle-project" id="building-the-truffle-project"></a>

```
# Build the Truffle project. This will extract the ABI files to the Unity client,
# and compiled contracts to the DAppChain/build/ directory

cd Truffle
truffle build
```

### #Running the DAppChain <a href="#running-the-dappchain" id="running-the-dappchain"></a>

```
# Start the zeknd DAppChain. zeknd binary will be downloaded automatically

cd DAppChain
./start-chain.sh
```

### #Running the Unity client <a href="#running-the-unity-client" id="running-the-unity-client"></a>

Open the Unity project located in `UnityClient`. Open the `Blueprint/BlueprintTest` scene and run/build it.

## #Workflow <a href="#workflow" id="workflow"></a>

1. Make changes to the contracts.
2. Build the Truffle project using `truffle build`.
3. Start the zeknd DAppChain using `DAppChain/start-chain.sh`.
4. Make changes to the Unity client project.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.opzeknd.xyz/unity-sdk/unity-+-truffle-+-zeknd-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
