---
title: "Salahdine Parnasse"
subtitle: "An NFT collection for a top-level international athlete"
description: "How the NFT collection of MMA fighter Salahdine Parnasse was built: ERC721A mint contract, reveal, metadata resolver, Next.js website and automated deployment."
author: "Roman Gascoin"
date: 2022-05-18
lang: en
tags: ["Freelance","Web3","Docker","Solidity"]
canonical: https://rgascoin.fr/blog/salahdine-parnasse/
---

# Salahdine Parnasse

> An NFT collection for a top-level international athlete
## Links

| Label | Link |
| --- | --- |
| Mint | [Salahdine NFT (salahdineparnasse.art)](https://salahdineparnasse.art/) |
| OpenSea | [Salahdine Parnasse collection on OpenSea](https://opensea.io/collection/salahdine-parnasse) |
| Etherscan | [Contract address 0xa0103f2764cc81425ff7fb3273903dd2efebb423 on Etherscan](https://etherscan.io/address/0xa0103f2764cc81425ff7fb3273903dd2efebb423) |
| Twitter | [@SalahdineP on Twitter](https://twitter.com/SalahdineP) |
| LinkedIn post | [Post on LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6926639851815514112/) |

## Project summary

> In March, following the successful launch of an MMA athlete's NFT collection, Salahdine Parnasse's agent wanted to launch a collection for his champion.

> Several proposals were made to determine the best approach for the specifics of the smart contract. A streamlined solution was chosen: no whitelist and no transaction limit. A reveal system was put in place, along with a few free mints offered to the community.

> Three distinct types of NFTs can be obtained randomly:
>
> - **600 classic cards**, with a chance to win a private training session with the champion
> - **200 rare cards**, to win training sessions depending on the "finish"
> - **5 legendary cards**, to win the fighter's equipment or an all-expenses-paid day to watch a fight from backstage

> At launch, the project recorded **28 sales in a few hours**. This may not have been the expected result, but Salahdine's manager saw it as an opportunity to **continue the project in the long term**.

---

## Key points of the project

### The mint contract

This is the foundation of any NFT project: a smart contract capable of issuing `non-fungible tokens`. Several standards exist, each with its advantages and disadvantages. The most well-known are ERC721, ERC721A, and ERC1155. For this project, we chose the Azuki ERC721A standard.

This implementation has the advantage of offering **low-cost multiple** mints, like ERC1155, while keeping the basic ERC721 implementation.

The implementation of the ERC721A contract for the Salahdine project differs in **two ways**:

#### URL management

An **override** of the functions used to retrieve the URLs pointing to the **metadata** of the NFTs.

```javascript
function tokenURI(uint256 tokenId) public view override returns (string memory)
function _baseURI() internal view override returns (string memory)
```

The goal of this change is to display a `placeholder` image before revealing the real designs to users.

#### Adding a signlist

Many NFT projects use a **whitelist system** to favor and reward certain members of their community. There are several ways to set up whitelists in Solidity, but the most **optimized** technique I have found to date is based on **signing addresses**.

1. An account A is used to sign the address of the buyer B.
2. The signature is sent as an argument when calling the mint function.
3. The smart contract uses the `recover` method to prove the authenticity of the signature based on the sender.

Here is an example of the function used to verify the validity of the signature:

```javascript
/**
* @dev Does the user is whitelisted.
* Return 1 for yes else 0.
*/
function isWhiteList(bytes calldata _signature, address _targetSigner) view internal returns (uint8) {
	if (_targetSigner == keccak256(abi.encodePacked(
			"\x19Ethereum Signed Message:\n32",
			bytes32(uint256(uint160(msg.sender)))
	)).recover(_signature)) {
		return 1;
	}
		return 0;
}
```

For more information, I talk about it [on my Instagram](https://www.instagram.com/p/Cb93bcYt1jt/).

### The resolver

When a third-party service wants to display the **visual representation of an NFT**, it must call the `tokenURI(uint256 tokenId)` function to obtain a URL where the **NFT information** is located, in JSON format most of the time.

Several services, such as [Pinata](https://www.pinata.cloud/), let you easily upload your metadata online. However, I am not a fan of these solutions because you are **no longer in control of your data**, some of these services are **paid**, and you depend on their **resilience**.

That's why I set up a **Python** application using **FastAPI** and the **Alchemy** API to create my own metadata resolver.

The `tokenURI` method of my smart contract redirects to this **microservice** running on one of my servers. I then use **Alchemy's** services to determine whether the requested NFT has already been **minted or not**. If it has, I return the corresponding **metadata**.

*[image: Alchemy chart of the compute units consumed per day in May, with a peak of about 1,000 units]*

*Alchemy dashboard used to measure the usage of the API that validates metadata management.*

And what about data decentralization?

This system has a flaw: the NFT metadata is stored on a **conventional** server. However, this is not a deal-breaker for this type of project.

- Images are stored on **IPFS**; only metadata such as the name, description and attributes is stored on the server.
- To ensure **data integrity**, the hashes of all the metadata are made **public** at the beginning of the sale, and a way to verify their validity is provided.
- The user always has the option to **freeze** their data via OpenSea.
- Most NFT projects wish to make some adjustments shortly after their release. This gives them a little more flexibility while staying in line with their community.

### Integration on a website

A Next.js application was deployed for the project. It serves as a showcase website presenting the project and its designs. It also allows buyers to acquire their NFTs.

A web3 module allows wallet connection through MetaMask only. For this project, MetaMask was the only provider selected, as it was sufficient for the scope of the project. Moreover, this allowed for a manual implementation, with no need to rely on a third-party service to ensure the security or maintainability of the project.

*[image: Section of the showcase website presenting the three card categories: special (600), rare (200) and legendary (5)]*

### Deployment automation

To allow for **maximum responsiveness during the deployment** or development phases, many tasks are **automated**.

For the deployment of the smart contracts, scripted **deployment pipelines** were created to avoid paying high gas fees.

Numerous **unit** and **functional** tests cover all the project's features, and modules also make it possible to predict the amount of gas that will be consumed by the different methods. Security **audits** are also carried out using tools such as **Slither**.

*[image: Gas report listing the deployment cost of the MmaSP and MmaSPv2 contracts, with 61 passing tests]*

For deploying the web applications, database, reverse proxy, and resolver, **Docker** and **Docker Compose** are of great help. They make it possible to quickly **launch**, **rebuild**, **modify**, and **stop** the entire application stack or just a part of it. This is very useful, for example, for quickly scaling server power down or up depending on the situation.

*[image: Output of the docker ps command on the server, listing the reverse proxy, resolver, front-end, API and Redis containers]*

Cloudflare is also used as a **proxy** for the **production servers**. This enables caching, which reduces server load times, and brings more **security** to the project.

---

## Media

*[image: Salahdine NFT website showing a preview of the designs]*

*[image: OpenSea page of the Salahdine Parnasse collection, showing 28 items and 18 owners]*

*[image: Cloudflare overview over 30 days: 4.66k unique visitors, 79.65k requests and 96.95% cached]*

*[image: Mint section of the website: sales start on 01/05/2022 at 0.07 ETH, with a quantity field and a mint button]*
