Giter VIP home page Giter VIP logo

bonfida-name-tokenizer-ffe4b298's Introduction

Name tokenizer



Tokenize domain name into Metaplex NFTs


Table of contents


  1. Program ID
  2. Introduction
  3. Collection
  4. Mint
  5. NFT
  6. 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.


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

bonfida-name-tokenizer-ffe4b298's People

Contributors

dr497 avatar lcchy avatar ellttben avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.