# NFT Marketplace App

In this guide, we will be building a simple NFT Marketplace app from scratch.&#x20;

### Defining our App

Before we begin building the app in the ADO Builder, let's define its features and functionality. For this build, we will assume a team is looking to create a simple marketplace for an NFT collection where each NFT is sold for a fixed price.&#x20;

### Defining our Components

To create the App we described above, we need the following components:

* [CW721](https://docs.andromedaprotocol.io/andromeda/andromeda-digital-objects/marketplace) component to mint the NFT collection
* [Marketplace](https://docs.andromedaprotocol.io/andromeda/andromeda-digital-objects/marketplace) component to sell the NFTs

## Building the App

Open a new empty project in the ADO Builder and give the app an appropriate name:

<figure><img src="https://3919035805-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaNGg2pluC6LG4475Lq89%2Fuploads%2FmnjzcRtoxmyk80IbRBKu%2FScreen%20Shot%202024-03-18%20at%206.38.28%20PM.png?alt=media&#x26;token=2385faea-e7b0-4000-ae16-569e6f43fa37" alt=""><figcaption></figcaption></figure>

Add a CW721 component and fill in the fields:&#x20;

{% hint style="info" %}
Use your connected wallet for the **Minter Address** field.
{% endhint %}

<figure><img src="https://3919035805-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaNGg2pluC6LG4475Lq89%2Fuploads%2FThHjSB4NSkXd89sWZYvw%2FScreen%20Shot%202024-03-18%20at%206.39.11%20PM.png?alt=media&#x26;token=a53a083c-425b-484a-9522-896cd9780a43" alt=""><figcaption></figcaption></figure>

Next, add the marketplace component to the build. Other than the optional modules, the Marketplace ADO has two fields:

* **Authorized Sale Type:** Allows us to define a CW20 ADO  whose tokens can be set as the purchasing token for the NFT sales. This would restrict the CW20 ADOs allowed to be set to the one defined here. In case we just select native, then we can set any CW20 as the purchasing token. Using a native token is always accepted. This will be defined later on when we configure auction parameters. So for now we select the **Native** option.
* **Modules:** Allows users to add modules to the auction. For now, you do not need any modules, so you can keep it empty.

{% hint style="info" %}
Modules are currently disabled, but will be available in our next release.
{% endhint %}

The app is now ready to be published to chain. Go ahead and publish:

<figure><img src="https://3919035805-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaNGg2pluC6LG4475Lq89%2Fuploads%2FZvmFQ277lcZT251AjV88%2FScreen%20Shot%202024-03-18%20at%206.42.50%20PM.png?alt=media&#x26;token=46ba2355-b4da-4564-b21e-b35769af56a9" alt=""><figcaption></figcaption></figure>

## Setting up the NFT Sales

The app has been published to chain and is ready to be interacted with. The steps we will perform in this section are the following:

1. Mint the NFT collection using our CW721
2. Start sales on each NFT minted in the collection by sending it to the marketplace

### Minting the NFT Collection

The easiest way to mint the NFTs is by using our **Batch Mint** message that can mint several NFTs at a time. Choose the **Batch Mint** message from the list of execute messages for a CW721 and mint some NFTs:

{% hint style="warning" %}
Make sure that the owner of the NFTs is your address.
{% endhint %}

<figure><img src="https://3919035805-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaNGg2pluC6LG4475Lq89%2Fuploads%2FoXsoMyJVic8Ab9aI9edJ%2FScreen%20Shot%202024-03-18%20at%206.48.00%20PM.png?alt=media&#x26;token=b54985b9-a82a-4513-afdc-787164a86c9a" alt=""><figcaption></figcaption></figure>

Once done with the first token, add another token and repeat the process until you have 3 NFTs and then publish.

### &#x20;Starting Sales on Each NFT

In order to start a sale on an NFT, you need to send that NFT to the Marketplace component with the sale parameters attached. This is very similar to what we did to start an auction on an NFT. &#x20;

Select **Send NFT** from the list of executes of the **CW721** component. The “**Recipient Address**” is the Marketplace component address which can be fetched from the assets page. For the “Token/NFT Name” field, put the token Id of the NFT you want to start a sale on:

<figure><img src="https://3919035805-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaNGg2pluC6LG4475Lq89%2Fuploads%2FNNt52m2hrI5ciyTNW6QX%2FScreen%20Shot%202024-03-18%20at%206.50.54%20PM.png?alt=media&#x26;token=b443f23b-e315-41e9-abc7-499f92557b02" alt=""><figcaption></figcaption></figure>

Next you have the “**Custom Message**” field. Since you are sending to a marketplace component, select **Marketplace** and then select “**CW721 start sale**” under “**Select Message**”.&#x20;

Here you will have to specify the following:

* If we want to use a CW20 token as the purchasing token. I will not check the box as I intend to use native.
* Specify the coin denom accepted for purchasing the NFT. Since I am building on the Stargaze chain, and I want to use a native tokens as the bidding token, I will specify **ustars**.
* The starting time of the sale. This is specified through an [epoch time](https://www.google.com/url?q=https://www.epochconverter.com\&sa=D\&source=editors\&ust=1684253771700484\&usg=AOvVaw1ibK4NOXubSN0uNcYHSI6F) in milliseconds. Selecting none means the sale will start immediately after the message is published. I will use that option.
* The duration of the sale in milliseconds. I want the auction to run for 2 hours. .
* The price of the NFT. I will choose 100000.&#x20;
* Recipient which is the address to receive the funds from a succesfull NFT sale. I will select none as it will default to my address (The sender of the NFT)

{% hint style="info" %}
Not including a start time means the sale is started immediately.
{% endhint %}

<figure><img src="https://3919035805-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaNGg2pluC6LG4475Lq89%2Fuploads%2F1WeerZZXRa9SgWtRl8Ka%2FScreen%20Shot%202024-04-18%20at%207.35.33%20PM.png?alt=media&#x26;token=1b1c180f-c759-46f8-9c35-e96b92b94f51" alt=""><figcaption></figcaption></figure>

Once you publish, the first NFT is sent to the marketplace ADO where it is listed for sale for the specified price. Users are able to buy the NFTs from the marketplace which will send the funds to your address and send them the NFT.

We have succesfully set up one NFT sale. You can do the same for each minted NFT. You can also use the **Multi Execute** option, to set up multiple messages at a time. This would allow you to send multiple NFTs to the marketplace at a time.

{% hint style="info" %}
If you want to try buying some of the NFTs from the sale and then checking the results, check our "[Using CLI to Interact with Apps](../using-cli-to-interact-with-apps)" section.

If you are interested in using queries on your App components, check out our [Using Queries ](../../learning-the-basics/using-queries)section to learn about that process.
{% endhint %}
