NFT Nickname Program — add nicknames to Solana NFTs

Alber Erre
4 min readAug 15, 2022
Street of Lisbon
Photo by Joan Costa

Hey! — nice to see you around 👋🏼 — to reach out, click here.

In case you want to interact with the NFT Nickname program directly, visit:

https://nftnickname.xyz/

Introduction

This post is about a side project I’ve been building to learn Solana, specifically the account model and how PDAs work.

If what I said sounds greek to you 🏛, you should visit PaulX post. It covers almost everything you need to know about Solana, but I suggest you to take 1–2 days to read it through. — It’s intense reading 🔥.

🌍 The photo you see above is a street in Lisbon, it was during a trip in this city where I started digging about the Solana ecosystem. Good memories.

Motivation

The core idea about this project was to provide some sort of infrastructure to the solana ecosystem. — At the moment of this writing, there isn’t a layer to put nicknames/names on top of NFT’s mint addresses on Solana.

So, why not? — Let’s build this thing 🔧.

My aim was to build something everyone could use, and almost everyone in the space has an NFT in their wallet — easy deal.

Architecture

I’ve learnt to love diagrams in this space. — It brings a lot of clarity while thinking about how solana accounts work with each other.

This post is no less, so here is the diagram of the account model for this nickname program:

Nickname PDA diagram
Nickname PDA diagram

In case you haven’t grasp what PDAs are yet. You also may look this brief intro from Solana cookbook.

As you can see in the diagram, there is a NicknamePDA for each NFT mint account, this PDA is where your nickname is stored 📦.

There is some checks in place on the program’s entrypoint that ensures only the current NFT owner is allowed to add/update nicknames.

Oh yes! — I said current owner. — Because the nickname PDA is attached directly to the mint account 🔒 (as seen in the diagram). Therefore, if you sell your NFT, this nickname is still attached to it. And the new owner could just keep it as it comes, or update it. — Up to them to decide.

But wait, why is this?

To answer this question, we need to remember how Solana account model works. And more specifically, how the SPL Token Program works.

Understanding Mint, Token accounts and Nickname PDA

When you create a token, you create a Mint account 🌱.

Then, every user who wants to hold tokens from this mint needs to have an account to hold them, this is called associatedTokenAccount.

When a Nickname PDA account is created, we use two seeds to generate this PDA. The first seed is the NFT mint account address, the second seed is a string, which contains the word “nickname” — Also, there is a bump that secures us to be out of the ed25519 elliptic curve.

🚨 As you can see, the associatedTokenAccount holding your NFT is not used as seed for ourNickname PDA 🙈.

Why?

Well, this associatedTokenAccount is different for each NFT owner.

Therefore, attaching our nickname to this account would cause we need to create a new PDA every time our NFT changes its owner. — That’s boring, and not good at all.

What if the previous owner doesn’t ever get the NFT back?

That would be a waste of space! — as the PDA account created for the previous owner would still exist (unless the previous owner delete it manually through a CLI) — and believe me, space is expensive, check it out here if you want to know why.

For this reason, our nickname PDA depends exclusively on the Mint account, which is exactly the same for each NFT holder.

This allow us to maintain one, and only one, nickname PDA account for each NFT. — Saving a lot of block space in the process ✅.

User Interface (Frontend)

As typing Mint addresses and fetching accounts through a CLI could be very boring, a fresh frontend website has been put in place 🎉.

Therefore, to interact with this program, you can visit the following website and start playing around with your nicknames

https://nftnickname.xyz/

You need to connect your wallet and insert an NFT mint address — Give it a try! In case you’re the owner, you are allowed to add/update its nickname.

Pheew, that has been a lot! — If you have arrived here, congratulations! 🎉

If you want to keep posted, give me a follow on twitter! 📰

Cheers!

Alber Erre.

--

--

Alber Erre

Messy Blockchain Adventures 🚀 & Front End Development