# Brawler Bears (PVP)

Brawler Bears is a strategic NFT fighting game where players use unique bears, equipped with various weapons and abilities, to engage in wagered battles, earn ARKD tokens, and compete for dominance.

### I. Getting Started

1. **Acquire a Brawler Bear:** You need to own a Brawler Bear to start playing. This can be obtained in three ways:
   * **Airdrop:** If you held a qualifying NFT during the airdrop period, you might have been airdropped a Brawler Bear.
   * **Minting:** Participate in the minting event to acquire a newly minted Brawler Bear.
   * **Marketplace:** Purchase a Brawler Bear from the marketplace from another player.
2. **Acquire Weapons:** Weapons can significantly boost your bear's combat capabilities. They can be obtained through:
   * **Airdrop:** For each Brawler Bear you owned prior to the launch of the game, you were airdropped one weapon.
   * **Minting:** Participate in the minting event to acquire a newly minted weapon.
   * **Marketplace:** Purchase weapons from the marketplace from another player.

### II. Gameplay Mechanics

* **Equip Attacks:** Each bear can equip up to three attacks. Carefully plan your bear's attacks for optimal performance in battle.
* **Create/Join Battles:** Engage in battles by wagering ARKD. Challenge other players to assert your bear's dominance. *(1 KDA Battle Fee)*
* **Perform Attacks:** Execute powerful attacks against your opponent to deplete their health and claim victory.
* **Earn Rewards:** The winner of each battle receives the ARKD as a reward. These rewards can be used to level up your bear and unlock new abilities.
* **Heal Your Bear:** Use ARKD to restore your bear's health, ensuring it's ready for the next battle.
* **Level Up (Coming Soon):** Enhance your bear's abilities and strength by winning battles and inflicting damage on opponents. Your victories and the damage you deal contribute to your progression.
* **Timed Out Wins (Coming Soon):** If a player doesn't make a move for 24 hours, the last player to move wins the battle. Strategize your moves with this in mind.

### III. Fighter and Weapon Stats

#### Fighter Stats

* **Level:** Tracks your progress as a Brawler Bear.
* **Health Power (HP):** Indicates your bear's resilience and endurance against enemy attacks.
* **W/L Ratio:** Shows your win-loss record as a competitor.
* **Total Battles:** Counts the number of battles your bear has engaged in, showcasing your experience.
* **Damage Given:** Records the total amount of damage your bear has inflicted on opponents.
* **Damage Taken:** Shows the total damage your bear has sustained during battles.

#### Weapon Stats

* **Damage:** Measures the strength of your attacks, showing how much damage they can inflict on opponents.
* **Power:** Shows how many times a specific attack can be used before it needs to be recharged.

### IV. Healing Items

* **Lavender Honey:** Fully restores HP and replenishes all equipped attacks once every 24 hours.
* **Sapphire Honey:** Restores half of the maximum HP.
* **Golden Honey:** Fully restores HP and replenishes all equipped attacks.
* **Attack Power Replenisher:** Recharges your weapons when their power runs out.

### V. Progression and Leveling

* **Battle Achievements (Coming Soon):** Each battle you win and each attack you make contributes to your bear's leveling up, which increases its maximum HP.
* **Leaderboard (Coming Soon):** Compete with others on the leaderboard to secure the top spot and showcase your skills.
* **Free Play Mode (Coming Soon):** Test strategies and improve your skills in this mode where battles don't require any wagering.


# NFTs


# What is an “NFT”?

NFT, or non-fungible token, is a unique digital asset that can come in various forms and sizes. They offer a fun way to support your favorite teams, artists, creators, and events, as well as provide an opportunity to expand your portfolio or make a quick profit.

&#x20;When you buy and sell NFTs on the Kadena blockchain, you're often supporting artists, as they have the ability to collect creator royalties on their collections. This is known as "Creator Royalties" and will be tagged on the NFTs for transparency.

&#x20;NFTs also have a practical use as a form of digital ownership for online goods and services. This is especially useful for situations where scalpers may sell fake tickets, or where establishing trust for a digital good is important.&#x20;

It is important to note that NFTs come with risk and volatility, especially in the digital art use case. It is essential to conduct thorough research before making any purchases.


# Why Kadena?

The Kadena blockchain is known for its scalability and security features.One of its key features is its use of parallel-chain architecture, which allows for faster and more efficient transactions. This is achieved by having multiple chains running in parallel, allowing for increased throughput and reduced congestion on the network.Another important feature is its use of formal verification, which is a mathematical approach to proving the correctness of smart contracts. This helps to ensure that the contracts are free from errors and reduces the risk of unintended consequences.Kadena also has a built-in governance mechanism that allows for community participation in protocol upgrades and decision making. The Kadena blockchain also has a built-in privacy feature, which is an important aspect for many use cases.Additionally, Kadena blockchain is the first blockchain to implement Pact, a smart contract programming language that has formal verification built in, which helps to make smart contract more secure.All these features together make Kadena blockchain a great choice for enterprise and business use cases that require scalability, security and privacy.


# What is Proof of Ownership?

The power of blockchain technology lies in its ability to provide verifiable digital ownership. On the Kadena blockchain, as well as other blockchain networks, individuals can prove ownership of digital assets through their wallet address.

&#x20;This eliminates the possibility of disputes and fraud, as ownership can be easily verified. An example of this is the value of a Banksy artwork.&#x20;

Anyone can view a digital image of it, but only the person who owns the NFT, the non-fungible token, has the true and verifiable ownership of the artwork. This is the strength of blockchain technology in verifying the authenticity and ownership of digital assets.


# What occurs when I mint or purchase from the Arkade marketplace?

Arkade is both a primary and secondary marketplace for NFTs.&#x20;

When you mint an NFT on Arkade's official website, you are buying directly from the creators of the NFT collection and storing it on the blockchain. You don't have the option to choose which NFT you get, it's like a lucky draw where you have equal chances of getting a legendary or common tier NFT for the same price.

&#x20;However, you may be able to purchase the NFT at a lower price compared to buying on a secondary market. On the other hand, buying NFTs on Arkade's secondary market allows you to choose which NFT you want and the current holders set the price for each NFT.


# Wallets


# What's a wallet?

A wallet on the Kadena blockchain is a digital storage for your digital assets, much like a bank. However, as the owner of the wallet, you are responsible for the security of your funds.

In the Web3 space, a wallet serves as a form of identification and is necessary for all interactions. It is the key to accessing NFTs and other digital assets, as it is used to exchange tokens, purchase NFTs, and store these assets.

It is important to take steps to ensure the safety of your assets in your wallet. This includes using a strong password, regularly backing up your wallet, and keeping your software up to date. A wallet serves as a digital passport in the Web3 space, and you will always need it for any digital interactions.


# What are the different types of wallets available?

The Kadena blockchain offers a variety of wallet options for managing and storing digital assets. On the Arkade platform, we primarily focus on digital wallets that can be easily accessed through a browser extension or phone app.&#x20;

These wallets allow for seamless connection to the Arkade marketplace, where you can buy and sell NFTs using $KDA. With a digital wallet, you'll be able to easily manage and transact with NFTs on the Arkade platform.

Some of the wallets currently on the Kadena Blockchain are below.

1. X-Wallet by Kaddex: <https://xwallet.kaddex.com/#download>
2. Zelcore Wallet: <https://zelcore.io/>
3. Koala Wallet: <https://koalawallet.io/>
4. Chainweaver: <https://chainweaver.kadena.network/>
5. WalletConnect: <https://walletconnect.com/>

*Please note that this list is not in any particular order and does not represent any endorsement or recommendation from us.*


# How do I set up a digital wallet?

With so many wallet options available, setting up a digital NFT wallet can seem overwhelming. To make the process easier, we've put together a universal guide on how to set up your digital NFT wallet:

1. Choose a reputable wallet provider: There are several NFT wallet providers that you can choose from. Look for a provider that has a good reputation, is user-friendly, and has a good track record of security.
2. Create an account: Sign up for an account with your chosen wallet provider. You will need to provide your email address and create a password.
3. Download the wallet: Once your account is set up, download the wallet to your device. The wallet is typically available as a mobile app or as a browser extension.
4. Secure your wallet: Enable any security features that the wallet provider offers, such as two-factor authentication (2FA). This will help protect your NFTs from being stolen.
5. Add funds to your wallet: You will need to add funds to your wallet in order to purchase NFTs. This can typically be done by connecting your wallet to a cryptocurrency exchange, such as Coinbase, and then transferring funds from the exchange to your wallet.
6. Store your private key safely: The private key is a unique code that is used to access your wallet. Keep it safe and do not share it with anyone.

Note that different wallet providers may have slightly different setup processes, but the basic steps should be similar. Always make sure to do your own research before choosing a wallet provider and follow best practices for keeping your digital assets safe.\
\
Here is a list of resources compiled from direct sources within the Kadena ecosystem:

{% embed url="<https://www.youtube.com/watch?v=3bjmIxeQ4mk>" %}

Koala Wallet:&#x20;

{% embed url="<https://www.youtube.com/watch?v=sqyj3nnn8RA>" %}

**Safety Note:**

When signing up for a new wallet, you’ll be given 12 words known as your “Secret Recovery Phrase”. This is your private key and you can think of it as your password. These words are what you will use to recover your wallet if you need to log into a new device.


# How do I get $KDA?

There are several ways to buy $KDA, the native token of the Kadena blockchain, such as:

1. Cryptocurrency Exchanges: You can buy $KDA on several major cryptocurrency exchanges such as Binance, Huobi, OKEx, and KuCoin.
2. OTC (Over-The-Counter) trading: you can buy $KDA directly from someone who already owns it through OTC trading, which is a way to buy and sell large amounts of cryptocurrency without going through a centralized exchange.
3. Staking: you can earn $KDA by participating in staking, which is a process of holding and validating transactions on the Kadena blockchain.
4. Mining: you can mine $KDA by participating in the consensus process of the Kadena blockchain.
5. Koala Wallet: You can purchase directly from the app using a credit or debit card.&#x20;

It is important to note that the availability and accessibility of these options may vary depending on your location and regulations. It is also important to conduct your own research and due diligence before buying $KDA or any other cryptocurrency.


# What are healthy wallet safety practices?

When using the Kadena blockchain, it is important to **keep your seed phrase/private key safe and never share it with anyone.** This will ensure that only you have access to your wallet and funds.

It's also important to note that NFTs can be a lot of fun, but they are a highly volatile asset class and their value can fluctuate. It's important to do your own research (DYOR) before investing in NFTs.

To further protect your funds, it's **best practice to use a "burner wallet" when minting NFTs on any launchpad or marketplace.** A burner wallet is a temporary wallet that is used only for minting and can help limit your risk of exposure to shady websites.

**Make sure to always check the URL of any website you visit** to ensure it is the official link and bookmark sites you regularly visit. Be aware of phishing websites, which are identical fake sites that attempt to steal your private information.

Finally, consider getting a hardware wallet for added security. Hardware wallets protect your private keys and allow you to sign and confirm transactions on the Kadena blockchain. Even if the computer you're using isn't secure, your cryptocurrency funds will be safe in a hardware wallet.


# Buying


# How do I mint an NFT?

One of the safest ways to buy NFTs is through a reputable launchpad/marketplace like Arkade or Hypercent.

To ensure the integrity of our platform at Arkade, we have implemented several safety measures, such as thoroughly evaluating the authenticity of collections before they are launched, making KYC a mandatory requirement, and having a thorough launch process.

**Here’s how you can use Arkade's marketplace:**

1. Head over to our website [here](https://www.arkade.fun/market).
2. Make sure you connect your wallet to [www.Arkade.fun](http://www.Arkade.fun) - it will be located in the top right:\
   ![](broken://files/6YPjzHCJ4rxhQYSUuHDy)
3. Locate the correct project you are buying or planning to mint from.
4. Wait for the public mint or whitelist (presale) mint to start.
5. Mint away!

Launchpad mints can be high-traffic events, which means you may face competition when trying to mint. Don't be discouraged if you're unsuccessful, there will always be other opportunities. \
\
Another option is to buy or mint through the NFT collection's official website or within our marketplace. We will discuss this further later on.

<br>


# How do I choose which NFT is for me?

When it comes to buying NFTs, it's always a good idea to do your own research (DYOR) to assess the project's long-term strength. This includes evaluating the core idea, the strength of its offering, and the ability of the team to deliver on their promises. \
\
But, if you're feeling adventurous, you can always take a risk and buy an NFT without any research - just remember, it's not the most responsible way to invest. \
\
**For those who want to do some research, here are some questions to get you started:**<br>

* What is the minting process like? Are there any restrictions on buying or selling the NFTs?
* What is the maximum supply of the NFTs and how is it controlled?
* What is the liquidity of the NFTs? Can you easily buy and sell them on the market?
* What is the use case for the NFTs? Are they purely for collecting or do they have utility within the project's ecosystem?
* What is the project's roadmap and what are their future plans?
* Are there any partnerships or collaborations in place? Are they reputable and well-known in the industry?
* What is the financial situation of the project? Do they have adequate funding to support their plans and goals?
* What is the reputation of the project and the team in the NFT community? Are there any red flags or concerns about their past activities?
* How does the project compare to similar NFT projects in the market? Is it a leader or a follower in the space?
* What is the overall market sentiment and hype around the project?

*Answering these questions will help you evaluate the long-term strength of the project, and help you make a more informed decision when buying NFTs. Remember, it's always a good idea to conduct your own research before investing in any new projects.*


# How do I buy an NFT on Arkade?

Minting an NFT on the Arkade marketplace is a pretty-straightforward process.

Making sure you have funds on Chain 1 for purchasing


# How do I stay safe while minting and buying NFTs?

When considering an NFT project or individual, it's important to be aware of potential red flags that may indicate a scam or cash grab. Some things to look out for include:

* Accounts that have gained a large number of followers in a short period of time
* A lack of transparency or doxxing from the team
* Questionable origins of the art used in the project
* A lack of clear purpose or innovation in the project
* Use of bots for social media engagement
* Unrealistic promises and non-ethical marketing tactics&#x20;
* Restrictions on asking questions or seeking more information
* Heavy reliance on paid marketing
* High mint prices without corresponding quality or uniqueness in the NFT collection. It's important to keep these potential red flags in mind while evaluating NFT projects and individuals, but also to remember that not all projects with some of these characteristics are necessarily bad actors. It's always a good idea to do your own research and exercise caution when investing in NFTs.


# Selling


# How do I sell NFTs on Arkade?

When listing your NFTs on Arkade, it's possible that other users may send you offers to purchase your NFTs. If you decide to accept an offer and sell your NFT, it's important to follow these steps to ensure a smooth transaction:

1. Check the URL to make sure you are on the official Arkade website (arkade.fun) before connecting your wallet.
2. Review the offer and make sure you are satisfied with the terms before accepting.
3. Click "cancel listing" to remove your NFT from the marketplace.
4. Approve the transaction in your wallet to complete the sale.

It's important to note that it's always a good idea to double check the URL before connecting your wallet to any website, as there may be phishing websites that attempt to steal your private key or other sensitive information. By only connecting your wallet on the official Arkade website, you can ensure the safety and security of your NFTs and transactions.

<br>


# Will I be able to sell an NFT immediately?

When buying NFTs on Arkade, it's important to keep in mind that they are illiquid assets, meaning that you need to sell them in order to see returns. One way to assess the demand for an NFT collection is by checking the transaction activity of the collection. The more activity, the higher the likelihood of being able to sell your NFT. Additionally, it's also important to keep an eye on the prices at which the NFTs are being purchased. If the prices are low, it may be difficult to sell your NFT for a significantly higher price, as it may not be perceived as a good value by buyers. Therefore, it's important to be aware of the current market prices and conditions before listing your NFTs for sale.

Additionally, it's also important to consider the uniqueness and rarity of the NFTs you are buying. The less common the NFTs are, the more valuable they tend to be. Furthermore, it's also important to consider the project's long-term plans and what's the utility of the token you are buying, NFTs that have a real-world use case and are part of an ecosystem tend to have a better appreciation potential than just collectibles.

Overall, it's important to do your own research and keep an eye on the transaction activity, market prices, and the uniqueness of the NFTs you are considering buying or selling on Arkade.


# What is a floor price?

On Arkade, you can find the floor price for any collection on the collection page. The floor price is the lowest price at which NFTs in that collection are being sold and it reflects how holders value their NFTs.&#x20;

Typically, a higher floor price indicates a higher valuation of the NFTs in that collection. It's important to keep an eye on the floor price when buying or selling NFTs, as it gives you an idea of the current market value of the collection.


# What are attributes and why are they important?

Welcome to Arkade, where you can explore the world of NFT collecting! Here, every NFT is unique and has its own set of attributes, such as the design of the mouth, body, or background, making each one valuable in its own way.

One important factor to consider when buying NFTs is the rarity of the NFT. The rarity of an NFT is determined by the likelihood of its unique combination of attributes. For example, an NFT with rare attributes, such as purple sunglasses, found in only 0.01% of the collection, can potentially increase its value. On Arkade, you can easily check the rarity rank of an NFT on its collection page through our partner Kadefi.

This allows you to make informed decisions when buying NFTs, giving you a better idea of the potential value of the NFT based on its rarity. Additionally, you can also check the transaction activity of the collection, the prices at which the NFTs are being purchased, and the uniqueness of the NFTs.

Experience the excitement of owning one-of-a-kind NFTs on Arkade, where you can find rare and unique collections that you won't find anywhere else. Happy collecting!

![](broken://files/5Am84hCCZIlAUM7mgCWQ) (Placeholder, lol)


# Now that I’ve bought and sold an NFT, what do I do?

Trading NFTs on Arkade is not just about owning valuable digital assets, but also about being a part of a vibrant and active community. To fully immerse yourself in the NFT community, it's important to connect with others on social media platforms such as Twitter, Telegram, and Discord. Twitter is a great place to connect with the larger NFT community and stay up-to-date with the latest developments and trends, while Discord and Telegram offer more specific groups where you can interact with like-minded individuals and other NFT holders.

To get the most out of your NFT trading experience, spend time on Discord, join the general chat channel, and engage with other holders. Make new friends and have fun while you're at it! Ask questions and as you gain more experience in the NFT space, help guide newbies by providing valuable insights and answering their questions.

When you're ready to contribute to the NFT project, think about what unique skills or talents you can offer. Whether it's designing, marketing, or coding, there are many ways to contribute to an NFT project and make a difference.

Being a part of a vibrant community of NFT enthusiasts can add to the enjoyment of buying, selling and collecting NFTs.


# Overview

**Base URL**

```
http://api.arkade.fun
```

**Request API Key**

If you are a *verified creator* or *partner,* you can [**request an API Key**](https://www.arkade.fun/create).


# Collections


# Latest

**GET /latest**

Gets the latest collections.

Headers:

* `x-api-key` (string): The API key for authentication.

Success response:

* Status code: 200
* Body:
  * `result` (array): An array of collection objects.
  * `success` (object): A success message.

Error response:

* Status code: 400
* Body:
  * `error` (object): The error object.


# Upcoming

**GET /upcoming**

Gets the upcoming collections.

Headers:

* `x-api-key` (string): The API key for authentication.

Success response:

* Status code: 200
* Body:
  * `result` (array): An array of collection objects.
  * `success` (object): A success message.

Error response:

* Status code: 400
* Body:
  * `error` (object): The error object.


# Live

**GET /live**

Gets the live collections.

Headers:

* `x-api-key` (string): The API key for authentication.

Success response:

* Status code: 200
* Body:
  * `result` (array): An array of collection objects.
  * `success` (object): A success message.

Error response:

* Status code: 400
* Body:
  * `error` (object): The error object.


# Overview

In progress...


# Smart Contract

Here is an example Pact smart contract for Arkade's NFT Standard

```
(namespace "free")

(define-keyset "free.my-admin-keyset" (read-keyset 'my-admin-keyset))

(module butter GOV
    "Butter NFT"
  
    (defconst NFTS_TO_MINT_COUNT 10000.0)  
    (defconst WL_MINT_PRICE 100.0)
    (defconst PUBLIC_MINT_PRICE 200.0)
    (defconst WL_MINT_START_TIME "2023-01-01T19:00:00Z")
    (defconst PUBLIC_MINT_START_TIME "2023-01-02T19:00:00Z")
    (defconst MINT_END_TIME "2023-01-07T19:00:00Z")
    (defconst MAX_WL_MINT 10)
    (defconst TOTAL_VOLUME_KEY "total-volume-count-key")
    (defconst NFTS_MINTED_COUNT_KEY "nfts-minted-count-key")
    (defconst MINT_CHAIN_ID_KEY "mint-chain-id-key")
    (defconst CURR_WL_ROLE_KEY "curr-wl-role-key")
    (defconst WL_PREMIUM_ROLE "whitelist")
    (defconst PRICE_KEY "price-key")
    (defconst ADMIN_KEYSET "free.my-admin-keyset")
    (defconst ADMIN_ADDRESS "")
    (defconst CREATOR_ADDRESS "")
    (defconst ROYALTY_FEE 0.1)
  
      (defcap GOV () 
          (enforce-keyset ADMIN_KEYSET)
      ) 
  
      (defcap PRIVATE () 
          @doc "Can only be called from a private context"
          true
      ) 
  
      (defcap ACCOUNT_GUARD(account:string) 
          @doc "Verifies account meets format and belongs to caller"
          (enforce (= "k:" (take 2 account)) "For security, only support k: accounts")
          (enforce-guard   
              (at "guard" (coin.details account))
          )
      )
  
      (defcap OWNER (id:string)
          @doc "Enforces that an account owns an NFT"
          (let 
              (
                  (nft-owner (at "owner" (read nfts id ["owner"])))
              )
              (compose-capability (ACCOUNT_GUARD nft-owner))
          )
      )
  
      (defcap ADMIN() 
          @doc "Only allows admin to call these"
          (enforce-keyset  ADMIN_KEYSET)
          (compose-capability (PRIVATE))
          (compose-capability (ACCOUNT_GUARD ADMIN_ADDRESS))
      )
  
      (defcap PUT_ON_SALE (id:string owner:string price:decimal)
        @doc "Emitted event when an NFT is put on sale"
        @event true
      )
  
      (defcap REMOVED_FROM_SALE (id:string owner:string)
        @doc "Emitted event when an NFT is removed from sale"
        @event true
      )
  
      (defcap BOUGHT (id:string new-owner:string original-owner:string price:decimal)
          @doc "Emitted event when an NFT is removed from sale"
          @event true
      )
  
      (defun initialize ()
          @doc "Initializes the contract the first time its loaded"
          (insert counts NFTS_MINTED_COUNT_KEY {"count": 0.0})
          (insert counts TOTAL_VOLUME_KEY {"count": 0.0})
          (insert values MINT_CHAIN_ID_KEY {"value": (at "chain-id" (chain-data))})
          (insert price PRICE_KEY {"price": WL_MINT_PRICE})
          (insert values CURR_WL_ROLE_KEY {"value": "whitelist"})
      )
  
      ;;;;; SCHEMAS AND TABLES ;;;;;
  
      (defschema nft-main-schema
          @doc "Stores core information about each NFT"
          id:string
          date-minted:time
          owner:string
          item:object
      )
  
      (defschema marketplace-schema
          @doc "Schema for marketplace information"
          id:string
          for-sale:bool
          price:decimal
          updated-at:time
          owner:string
      )
  
      (defschema counts-schema
          @doc "Basic schema used for counting things"
          count:decimal
      )
  
      (defschema values-schema
          @doc "Basic schema used for storing basic values"
          value:string
      )
  
      (defschema wl-schema
          @doc "Basic schema used for WL members, keys are account ids"
          role:string
      )
  
      (defschema price-schema
          @doc "Prices schema"
          price:decimal
      )
  
      (deftable nfts:{nft-main-schema})
      (deftable marketplace:{marketplace-schema})
      (deftable counts:{counts-schema})
      (deftable values:{values-schema})
      (deftable wl:{wl-schema})
      (deftable price:{price-schema})
  
      ;;;;;; MINT FUNCTIONS ;;;;;;
      
     (defun mint-nfts-bulk (owner:string amount:integer)
         @doc "Mints NFTs bulk"
          (enforce-mint-live)
          (coin.transfer owner CREATOR_ADDRESS (* 0.90 (* (get-mint-price) amount)))
          (coin.transfer owner ADMIN_ADDRESS (* 0.10 (* (get-mint-price) amount)))
          (with-capability (ACCOUNT_GUARD owner)
             (with-capability (PRIVATE)
                 (map
                     (mint-nft owner) 
                     (make-list amount 1)
                 )
             )
         )
      )
  
      (defun mint-nft (owner:string amount:integer)
          @doc "Mints an NFT"
          (require-capability (PRIVATE))
          (require-capability (ACCOUNT_GUARD owner))

          (let (
                  (id (get-latest-nft-to-mint-data) )
              )
              (insert nfts id {
                  "id": id,
                  "item": { "edition": id },
                  "date-minted": (at "block-time" (chain-data)),
                  "owner": owner
              })
          )
          (with-capability (PRIVATE)
              (increase-count TOTAL_VOLUME_KEY (* (get-mint-price) amount))
          )   
          (increase-count NFTS_MINTED_COUNT_KEY 1.0)
      )
  
      (defun mint-nfts-free (owner:string amount:integer)
          @doc "Mints nfts as admin for free"
          (with-capability (ADMIN)
             (with-capability (ACCOUNT_GUARD owner)
              (with-capability (PRIVATE)
                  (map
                      (mint-nft owner) 
                      (make-list amount 1)
                  )
              )
             )
          )
      )
  
      (defun add-to-wl-bulk (role:string accounts:list)
          @doc "Adds wl users with a role"
          (with-capability (ADMIN)
              (map (add-to-wl role) accounts)
          )
      )
  
      (defun add-to-wl (role:string account:string)
          @doc "Adds a user to a wl"
          (require-capability (ADMIN))
          (insert wl account {"role": role})
      )
  
      (defun update-user-wl-role (role:string account:string)
          @doc "Updates a user's wl role"
          (with-capability (ADMIN)
              (update wl account {"role": role})
          )
      )
  
      (defun set-price(price-value:decimal)
          @doc "Set the price"
          (with-capability (ADMIN)
              (update price PRICE_KEY {"price": price-value})
          )
      )
      
      (defun get-latest-nft-to-mint-data ()
          (let 
              (
                  (minted-count (get-count NFTS_MINTED_COUNT_KEY))
                  (created-to-mint-count NFTS_TO_MINT_COUNT)
              )
              (enforce (< 0.0 created-to-mint-count) "No NFTs are available for mint.")
              (enforce 
                  (< minted-count created-to-mint-count)
                   "All NFTs put up for mint have already been minted."
              )
              (let 
                  (
                    (id (int-to-str 10 (+ (floor minted-count) 1)))
                  )
                  id
              )
          )
      )
  
      ;;;;;; MARKETPLACE FUNCTIONS ;;;;;;
  
      (defun transfer-bulk:string
          (ids:list
            receiver:string
          )
          @doc "(Admin only) Transfer multiple NFTs to an account."
          (with-capability (ADMIN)
              (map 
                  (transfer receiver)
                  ids
              )
          )
      )
  
      (defun transfer:string (receiver:string id:string)
          @doc "Transfer an NFT to an account."
          (enforce-marketplace-live)
          (enforce-account-exists receiver)
          (with-capability (OWNER id)
              (write marketplace id {
                          "id": id,
                          "for-sale": false, 
                          "price": -1.0, 
                          "updated-at": (at "block-time" (chain-data)),
                          "owner": receiver
              })
              (update nfts id {"owner": receiver})
          )
      )
  
      (defun put-id-for-sale(id:string price:decimal)
          @doc "Puts an NFT up for sale"
          (enforce-marketplace-live)
          (with-capability (OWNER id)
              (enforce (> price 0.0) "Price must be positive")
              (let* 
                  (
                      (owner (at "owner" (get-nft-fields-for-id ["owner"] id )))
                  )
                  (write marketplace id {
                      "id": id,
                      "for-sale": true, 
                      "price": price, 
                      "updated-at": (at "block-time" (chain-data)),
                      "owner": owner
                  })
                  (emit-event (PUT_ON_SALE id owner price))
              )
          )
      )
  
      (defun remove-id-from-sale (id:string)
          @doc "Removes an NFT from sale"
          (with-capability (OWNER id)
              (let* 
                  (
                      (owner (at "owner" (get-nft-fields-for-id ["owner"] id )))
                  )
                  (write marketplace id {
                      "id": id,
                      "for-sale": false, 
                      "price": -1.0, 
                      "updated-at": (at "block-time" (chain-data)),
                      "owner": owner
                  })
                  (emit-event (REMOVED_FROM_SALE id owner))
              )
          )
      )
  
    (defun buy-id-on-sale (id:string curr-user:string)
        @doc "Buys an NFT that was put up for sale"
        (with-capability (ACCOUNT_GUARD curr-user)
            (enforce-id-on-sale id)
            (let* 
                (
                    (nft-data (get-nft-fields-for-id [] id ))
                    (original-owner (at "owner" nft-data))
                    (price (at "price" (read marketplace id ["price"])))
                    (fee (get-market-fee-from-price price))
                    (to-seller-amount (get-to-seller-amount-from-price price))

                )
                (coin.transfer curr-user original-owner to-seller-amount)
                (coin.transfer curr-user CREATOR_ADDRESS fee)
                (write marketplace id {
                    "id": id,
                    "for-sale": false, 
                    "price": -1.0,  ; Invalid price so NFT can't be sold
                    "updated-at": (at "block-time" (chain-data)),
                    "owner": curr-user
                })
                (update nfts id (+ {"owner": curr-user} nft-data ))
                (with-capability (PRIVATE)
                    (increase-count TOTAL_VOLUME_KEY price)
                )
                (emit-event (BOUGHT id curr-user original-owner price))
            )
        )
    )
  
      (defun all-ids ()
          @doc "Returns all the IDs"
          (keys nfts)
      )
  
      (defun get-market-fee-from-price (price:decimal)
          @doc "Market fee cost for ID sold at a given price"
          (* price ROYALTY_FEE)
      )
  
      (defun get-to-seller-amount-from-price (price:decimal)
          @doc "Amount that goes to a seller when NFT sold at a given price"
        (* price (- 1 ROYALTY_FEE))
      )
  
      (defun get-marketplace-fields-for-ids (fields:list ids:list) 
          @doc "Return fields for a list of IDs"
          (map 
              (get-marketplace-fields-for-id fields)
              ids
          )
      )
  
      (defun get-marketplace-fields-for-id (fields:list id:string )
          @doc "Return the fields for a given ID"
          (if 
              (> (length fields) 0)
              (+ {"id": id} (read marketplace id fields))
              (read marketplace id)
          )
      )
  
      (defun get-all-on-sale ()
          @doc "Returns all items on sale"
          (select marketplace ["id", "price", "updated-at"] (where "for-sale" (= true)))
      )
      
      (defun get-nft-fields-for-ids (fields:list ids:list) 
          @doc "Return fields for a list of IDs"
          (map 
              (get-nft-fields-for-id fields)
              ids
          )
      )
  
      (defun get-nft-fields-for-id (fields:list id:string )
          @doc "Return the fields for a given ID"
          (+ {"id": id} (read nfts id fields))
      )
  
      ;;;;; ENFORCEMENTS ;;;;;
  
      (defun enforce-mint-wl-role (account:string)
          @doc "Enforce the account has a role that allows them to mint NFTs"
          (if (< (at "block-time" (chain-data)) (time PUBLIC_MINT_START_TIME))
              (let 
                  (
                      (curr_wl_role (get-value CURR_WL_ROLE_KEY))
                      (user_wl_role (get-wl-role account))
                  )
                  (if 
                      (= curr_wl_role WL_PREMIUM_ROLE)
                      (enforce (= user_wl_role WL_PREMIUM_ROLE) "Only whitelist members allowed")
                      true
                  )
              )    
              true
          )
      )
  
      (defun enforce-account-exists (account:string)
          @doc "Enforces that an account exists in the coin table"
          (let ((coin-account (at "account" (coin.details account))))
              (enforce (= coin-account account) "account was not found")
          )
      )
  
      (defun enforce-max-wl-mint (account:string amount:integer)
          @doc "Enforces WL member only mints max amount"
          (if (< (at "block-time" (chain-data)) (time PUBLIC_MINT_START_TIME))
              (let 
                  (
                      (owned-count (length (ids-owned-by account)))
                  )
                  (enforce (<= amount MAX_WL_MINT) "You have minted the max")
                  (enforce (< owned-count MAX_WL_MINT) "You have minted the max")
              )
              true
         )
      )
  
      (defun enforce-mint-live ()
          @doc "Enforces mint is live"
          (enforce (>= (at "block-time" (chain-data)) (time WL_MINT_START_TIME)) "Mint is not live.")
          (enforce (<= (at "block-time" (chain-data)) (time MINT_END_TIME)) "Mint has ended.")
      )
  
      (defun enforce-marketplace-live ()
          @doc "Enforces mint has ended and marketplace is live"
          (enforce (>= (at "block-time" (chain-data)) (time MINT_END_TIME)) "Mint is not live.")
      )
  
      (defun enforce-id-on-sale (id:string)
          @doc "Enforces the NFT for the ID is on sale"
          (let* 
              (
                  ; Get the owner for the id
                  (current-owner (at "owner" (get-nft-fields-for-id ["owner"] id)))
                  (marketplace-data (read marketplace id ["owner", "for-sale"]))
              )
              (enforce (= current-owner (at "owner" marketplace-data))
                  "The person who is the current NFT owner isn't the one that put it on sale")
              (enforce (= true (at "for-sale" marketplace-data))
                  "The nft is not listed for sale")
          )
      )
      
  
      ;;;;;; HELPER FUNCTIONS ;;;;;;;;;
      
      (defun increase-count(key:string amount:decimal)
          @doc "Increases count of a key in a table by amount"
          (require-capability (PRIVATE))
          (update counts key 
              {"count": (+ amount (get-count key))} 
          )
      )
  
      (defun set-value(key:string value:string)
          @doc "Sets the value for a key to store in a table"
          (with-capability (ADMIN)
              (update values key 
                  {"value": value} 
              )
          )
      )
  
      (defun get-count (key:string)
          @doc "Gets count for key"
          (at "count" (read counts key ['count]))
      )
  
      (defun get-value (key:string)
          @doc "Gets value for a key"
          (at "value" (read values key ['value]))
      )      

      (defun get-mint-price()
          (if (< (at "block-time" (chain-data)) (time PUBLIC_MINT_START_TIME)) WL_MINT_PRICE PUBLIC_MINT_PRICE)
      )
  
      (defun get-wl-role (account:string)
          @doc "Gets current wl role for the user"
          (try
              ""
              (at "role" (read wl account ["role"]))
          )
      )
  
      (defun ids-owned-by (owner:string)
          @doc "All IDs owned by someone"
          (select nfts ["id"] (where "owner" (= owner)))
      )
  
  )
  
 (create-table nfts)
 (create-table marketplace)
 (create-table counts)
 (create-table values)
 (create-table wl)
 (create-table price)
 (initialize)
```


# Overview

In progress...


