# Solidity

### Diamond Pattern <a href="#diamond-pattern" id="diamond-pattern"></a>

Diamond standard is similar to upgradeable smart contracts, such as the proxy pattern, but with the benefit that you can control many implementation contracts (i.e., logic contracts) from your single Diamond contract (i.e., proxy contract).

Some key features of the Diamond standard include:

* A single gateway to make proxy calls to n number of implementation contracts
* Upgrade a single or multiple smart contract atomically
* No storage limit to how many implementation contracts you can add to your Diamond

Verified on etherscan diamond contract will show interface for only main top facet.

## Smart contracts <a href="#smart-contracts" id="smart-contracts"></a>

[Sources](https://github.com/hack0xield/gutdem)

&#x20;**\*\*\*** Diamond pattern used

#### &#x20;<a href="#dembacon" id="dembacon"></a>

#### \*\*\* DemRebel Contract <a href="#demrebel" id="demrebel"></a>

Main playable character access ERC721 NFT

#### \*\*\* DemNft Contract  <a href="#demnft" id="demnft"></a>

The NFT contract is designed for demGrower and demToddler mintable ERC721s for price in $GD

#### \*\*\* Game Contract <a href="#game" id="game"></a>

Core game logic contract. Contains logic for Farms, Raids, Cash-Out, etc.\
**Chainlink VRF** oracle is used for random results generation.

#### **$GD Token Contract** <a href="#dembacon" id="dembacon"></a>

Main game token, openzeppelin ERC1363

#### Safe Contract <a href="#safe" id="safe"></a>

Utility contract for Farm points storage

&#x20;

For deployment and testing, we are using a Hardhat environment.

Contracts are deployed to Blast Sepolia Net:

<table data-header-hidden><thead><tr><th width="365"></th><th></th></tr></thead><tbody><tr><td>$GD token</td><td>0xE0247bDdf59634b14d9DD4BA5A63F6bFa5184500</td></tr><tr><td>DemRebel Diamond</td><td>0x09F9105D0b5517c3413dD9a4Eca9CE0c6cf5dC6B</td></tr><tr><td>Game Diamond</td><td>0x47eB5b58A09D0E8cABffEdfC2A685d2DC8D60c5E</td></tr><tr><td>Toddler Diamond</td><td>0xb9A85D8047624Fc0CC4C973beD40382D01B96B23</td></tr><tr><td>Grower Diamond</td><td>0x64b0Fb9c2dFaeEEc93C995D82a14ded9c02090fe</td></tr><tr><td>Safe</td><td>0xe822ddCf0B25264a4743f4786697f167dDe3Df7e</td></tr></tbody></table>

## The Farm <a href="#smart-contracts" id="smart-contracts"></a>

<figure><img src="https://2230049731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FChF2cC8UbWLrQaf6EUJt%2Fuploads%2Fhihc68O4bfHye8fX9M6T%2Fimage.png?alt=media&#x26;token=ce63d6a4-0336-40d7-8e6b-24823491b78d" alt=""><figcaption></figcaption></figure>

## Raid logic

### Raid mechanics <a href="#raid-mechanics" id="raid-mechanics"></a>

Raid is a Game mechanic for Farms that allows the transition of Harvest points from one player to another.

1. &#x20;The player launches a ‘scout' mission to find the farm for 'raid'
2. Then the player should make a decision: Raid the scouted Farm or not
3. Toddler NFTs are used for Raiding
4. If the Raid was successful, part of the harvest points will be transferred to the attacker's Safe
5. There is a timed cooldown until the next Raid
6. In the final stage, the player should return his toddlers from the Raid

<figure><img src="https://2230049731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FChF2cC8UbWLrQaf6EUJt%2Fuploads%2F74wrw0adTeUuEoIHOrat%2Fimage.png?alt=media&#x26;token=dc382ded-6107-459c-91ee-b5db8536ce14" alt=""><figcaption></figcaption></figure>

### Blast Net related <a href="#blast-net-related" id="blast-net-related"></a>

Blast users and smart contracts can earn \~4% from beacon chain staking yield.

The game contract is configured to automatically receive ETH yield via rebasing.

Upon starting, the Farm user should supply some ETH, which would be used to grow yield. If there is a need to withdraw staked ETH, the Farm contract for this user will be reset.

### L1 to L2 bridge <a href="#l1-to-l2-bridge" id="l1-to-l2-bridge"></a>

We've developed a Bridge code for NFT transfers from L1 <--> L2. Currently not in scope for GUTDEM project.
