# Define the NFT model · Decentralized marketplace with FT4 · Learn Chromia

> In this project, you define a complete NFT model on-chain and implement it in Rell.

Source: https://chromia.com/learn/marketplace-course/module-nft/nft/

Decentralized marketplace with FT4Lesson 7 of 15

1. [01Decentralized marketplace with FT4](https://chromia.com/learn/marketplace-course/introduction/)
2. [02Set up your project](https://chromia.com/learn/marketplace-course/setup/)

Module 1: Registering accounts and assets

1. [03Overview](https://chromia.com/learn/marketplace-course/module-ft4/)
2. [04Register payment token](https://chromia.com/learn/marketplace-course/module-ft4/register-token/)
3. [05Create user accounts](https://chromia.com/learn/marketplace-course/module-ft4/register-account/)

Module 2: Model NFTs in Rell

1. [06Overview](https://chromia.com/learn/marketplace-course/module-nft/)
2. [07Define the NFT model](https://chromia.com/learn/marketplace-course/module-nft/nft/)
3. [08Mint NFTs](https://chromia.com/learn/marketplace-course/module-nft/mint-nfts/)
4. [09Make card attributes random](https://chromia.com/learn/marketplace-course/module-nft/randomness/)

Module 3: Create the marketplace

1. [10Overview](https://chromia.com/learn/marketplace-course/module-assets/)
2. [11Charge a fee for mystery card purchases](https://chromia.com/learn/marketplace-course/module-assets/buy-mystery-card/)
3. [12Put a card up for sale on the marketplace](https://chromia.com/learn/marketplace-course/module-assets/list-card/)
4. [13Buy a card on the marketplace](https://chromia.com/learn/marketplace-course/module-assets/buy-listed-card/)
5. [14Test our marketplace](https://chromia.com/learn/marketplace-course/module-assets/test-marketplace/)
6. [15Test using Chromia CLI](https://chromia.com/learn/marketplace-course/module-assets/test-cli/)

[Learn](https://chromia.com/learn/)[Decentralized marketplace with FT4](https://chromia.com/learn/marketplace-course/)

07 / 15Module 2: Model NFTs in RellAdvanced

# Define the NFT model

In this project, you define a complete NFT model on-chain and implement it in Rell.

Begin with a base entity called `nft`. It represents an NFT through a unique ID and a mutable attribute that holds the NFT's owner. Create the file `src/rell_marketplace/nft.rell` and add this code:

src/rell\_marketplace/nft.rell

```
entity nft {
    key id: byte_array = op_context.transaction.tx_rid;
    mutable owner: account;
    index owner;
}
```

The `id` property holds the Transaction RID of the minted NFT. The `owner` property is mutable and has the type `account`. Because you can update the owning account, you can transfer the NFT to another account.

The `account` entity comes from the FT4 library and represents an account registered in FT4. For details, see the [FT4 accounts documentation](https://docs.chromia.com/build/ft4/intro/).

An index on `owner` speeds up queries that look up who owns an NFT. The trade-off is that changing the owner becomes a more expensive operation. With the base entity defined, you can now build the Gaming Trade Card NFT and give it its own attributes.

src/rell\_marketplace/nft.rell

```
entity nft_card {
    key nft;
    strength: integer;
    health: integer;
}
```

Here is what each part does:

* `key nft` links the card to the NFT entity and enforces uniqueness on that link.
* `strength` and `health` are the attributes that make each card distinct.

With these few steps, you have a simple NFT model in place.



Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Module 2: Model NFTs in Rell**](https://chromia.com/learn/marketplace-course/module-nft/)[Next →**Mint NFTs**](https://chromia.com/learn/marketplace-course/module-nft/mint-nfts/)
