#domain-name #nft #name-service #tokenize #solana #mint #metaplex

name-tokenizer

A Solana program which enables the tokenization of a Solana Name Service into an NFT

2 stable releases

2.0.0 Jun 4, 2024
1.0.0 Dec 20, 2023

#9 in #metaplex

Download history 124/week @ 2024-06-26 193/week @ 2024-07-03 256/week @ 2024-07-10 261/week @ 2024-07-17 333/week @ 2024-07-24 333/week @ 2024-07-31 356/week @ 2024-08-07 298/week @ 2024-08-14 255/week @ 2024-08-21 246/week @ 2024-08-28 252/week @ 2024-09-04 90/week @ 2024-09-11 64/week @ 2024-09-18 113/week @ 2024-09-25 128/week @ 2024-10-02 89/week @ 2024-10-09

402 downloads per month
Used in 2 crates (via sns-sdk)

MIT license

70KB
1.5K SLoC

Name tokenizer



Tokenize domain name into Metaplex NFTs


Table of contents


  1. Program ID
  2. Introduction
  3. Security
  4. Reproducible build
  5. Collection
  6. Mint
  7. NFT
  8. Tests
    • Rust
    • JS

Program ID


Mainnet program ID nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk


Introduction


This program allows people to tokenize their domain name in NFTs that follow the Metaplex standard with a creation/redemption mechanism.


Reproducible build


A reproducible build script (build.sh) can be used to build the program using docker


Security


For security disclosures or to report a bug, please visit ImmuneFi for more information on our bug bounty program.


Collection


NFTs are all part of a verified collection E5ZnBpH9DYcxRkumKdS4ayJ3Ftb6o3E8wSbXw4N92GWg.


Mint


NFT mints are PDAs derived from the domain name key they represent. The derivation is made as follow:

pub const MINT_PREFIX: &[u8; 14] = b"tokenized_name";

// ...

let (mint, mint_nonce) = Pubkey::find_program_address(
    &[MINT_PREFIX, &accounts.name_account.key.to_bytes()],
    program_id,
);

NFT


When a domain name is tokenized its ownership is transfered to a PDA that will be holding the domain while it's tokenized. In exchange, the program mints an NFT for the user. When redeeming the domain is transfered back to the NFT holder and the NFT burned.

During the tokenization process an NftRecord is created with the following state:

pub struct NftRecord {
    /// Tag
    pub tag: Tag,

    /// Nonce
    pub nonce: u8,

    /// Name account of the record
    pub name_account: Pubkey,

    /// Record owner
    pub owner: Pubkey,

    /// NFT mint
    pub nft_mint: Pubkey,
}

If funds are sent by mistake to the NftRecord instead of the NFT holder while the domain is tokenized the owner has the possibility to withdraw them. The "correct owner" is determined as follow:

  • If the NftRecord is active i.e domain is tokenized: The correct owner is the NFT holder
  • If NftRecord is inactive i.e the NFT has been redeemed: The correct owner is the last person who redeemed (owner field in the NftRecord)

Tests


Rust

Functional Rust tests can be run with

cargo test-bpf --features devnet

JS

End to end tests can be run with

yarn jest

Dependencies

~37MB
~633K SLoC