> For the complete documentation index, see [llms.txt](https://cryptoraggies.gitbook.io/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cryptoraggies.gitbook.io/welcome/services/clients-portfolio/zombie-chains-hoarders-collections.md).

# Zombie Chains - Hoarder's Collections

## <mark style="color:yellow;">Background</mark>

Zombie Chains, part of Hoarder's Collection, planned to build a PvP battle and tournament system on Cardano utilising their existing NFT collections - Zombie Chains, Zombie Hunters, Zombie Fight Club Aliens and Zombie Fight Club Fight Cards.

<figure><img src="/files/vFgnjymiJMiXHaPEs5XX" alt=""><figcaption><p><a href="https://zombiechains.cryptoraggies.io/">https://zombiechains.cryptoraggies.io/</a></p></figcaption></figure>

The requirement was a system that takes in NFT trait attributes in a transparent and fair manner, and simulate fights between players, with the chance of winning determined by the difference in NFT strength score between the players. This needs to be built to support 1v1 battles, and a grand tournament system of up to 32 players. Ideally the fees sent in by players should be held in a smart contract without single ownership.

<div><figure><img src="/files/AJQ3OMzG6SDExwJrVqYr" alt="" width="178"><figcaption><p>Class Weight and Strength Score displayed together with the NFTs.</p></figcaption></figure> <figure><img src="/files/TIqMXwOh03emjQoBdc04" alt="" width="375"><figcaption><p>Detailed ZC' NFTs trait attributes can be found in <a href="https://zombiechains.weirdoznft.io/zombiechains">https://zombiechains.weirdoznft.io/zombiechains</a></p></figcaption></figure></div>

## <mark style="color:yellow;">Solution Proposed</mark>

We agreed on the team's requirement of holding player fees in a smart contract without single ownership, and proposed a solution to build this system. The battle and tournament systems were built separately, each featuring a system comprising of 4 interacting parameterised smart contracts, taking advantage of Cardano's eUTxO model and the composability of transactions to execute each battle and tournament.

<div><figure><img src="/files/sFrPNl9jzTOc387IhMlx" alt="" width="563"><figcaption><p>Battle System (1 vs 1 Battle)</p></figcaption></figure> <figure><img src="/files/fGSEuiKckP8IwGGXnvGC" alt="" width="375"><figcaption></figcaption></figure></div>

<mark style="color:yellow;">**For the battle system (1 vs 1 Battle)**</mark>, we opted to use a single smart contract system initialised by a Battle Admin Wallet which contributes a seed UTxO to mint a thread token to kickstart the system. The whole system comprises of:

* Thread token minting contract
* Oracle token minting contract
* Oracle token holding contract
* Battle wager holding contract

These 4 smart contracts work alongside each other to generate results and publish them onchain for each battle, and to release the correct rewards for each player depending on battle result.

<figure><img src="/files/cue12RINwpnHDStN6A37" alt=""><figcaption><p>Our AI storytelling system transforms battles into whimsical spectacles, seamlessly blending fantasy and reality. After each clash, a personalised touch awaits with an AI-generated image crafted based on player's name, turning victories into unique masterpieces. It's not just a game; it's a journey where technology meets creativity, offering a truly immersive and unforgettable gaming experience. </p></figcaption></figure>

<mark style="color:yellow;">**For the tournament system**</mark>, we chose to use a dynamic set of parameterised smart contracts, resulting in a unique set of 4 smart contracts for each tournament. All the tournament parameters, including buy-in price, buy-in currency, prizes etc, are entered into the smart contract system as parameters and therefore, every tournament will have a unique set of smart contract byte code.

<div><figure><img src="/files/8eIxEdLYdG3io3ysvlpC" alt="" width="375"><figcaption><p>Comprehensive tournament layout</p></figcaption></figure> <figure><img src="/files/aQJOxy3pqna12XRSxVgY" alt="" width="375"><figcaption><p>Only admins have the option to create a tournament</p></figcaption></figure></div>

This system comprises of:

* Tournament main contract
* Tournament slot id token minting contract
* Tournament tag token minting contract
* Tournament oracle token minting contract

The intricate interplay of these smart contracts ensures that each slot within the tournament can only be occupied once, and that every participant's strength score is verified, preventing foulplay. The tag token is particularly designed to work with the oracle minting contract such that the oracle minting contract must consume 2 tag tokens every time it mints a set of fight outcome, resulting in fight outcomes that will only ever be minted once, ensuring fairness and eliminating ambiguity.

This system is powered by a Tournament Gamemaster Wallet which deploys all 4 contracts on-chain using its own ADA upfront, then re-coups the ADA from the tournament participants' entry fee while orchestrating the minting of oracle tokens and advancement of players from round to round. This ensures a perpetually sustainable system powered by fair and transparent fees, producing reliable and definite results for each fight.

<figure><img src="/files/f1c5wzLjUA09ItkEBVTv" alt=""><figcaption><p>The 32 players tournament board. Players will be randomly assigned to their brackets. Once the tournament has been filled up, it will start automatically. Players will not have to claim their win/lost, all pay-outs are automated.</p></figcaption></figure>

<figure><img src="/files/ANdxI2cUm8Dw46QnfwDu" alt=""><figcaption><p>Click on the brackets and players can see the results.</p></figcaption></figure>


---

# 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://cryptoraggies.gitbook.io/welcome/services/clients-portfolio/zombie-chains-hoarders-collections.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.
