Skip to content

AlexandriaDAO/NFT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Framework for ICRC7 NFT implementation for Internet Computer

Simple NFT

add next to dependences in Cargo.toml

uncensored-greats-dao = "0.1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
candid = "0.10"

to create NFT struct TestToken with symbol TT and name TestToken in src/lib.rs add

use serde::{Deserialize, Serialize};
use uncensored_greats_dao::{Icrc7, Metadata, Storage};
use candid::CandidType;

#[derive(
    CandidType, Clone, Hash, Default, Serialize, Deserialize,
)]
pub struct TestToken {
    pub name: String,
    pub description: Option<String>,
}

impl Metadata for TestToken {
    fn metadata(&self) -> String {
        serde_json::to_string(&serde_json::json!({
            "name": self.name,
            "description": self.description
        }))
            .unwrap_or_default()
    }
}

#[derive(Icrc7, Storage, Deserialize, Serialize, Default)]
#[icrc7(token_type = "TestToken")]
#[icrc7(symbol = "TT")]
#[icrc7(name = "Test Token")]
pub struct TokenCollections {}

build and deploy to test network

rustup target add wasm32-unknown-unknown
cargo install candid-extractor
cargo build --release --target wasm32-unknown-unknown --package test_token
candid-extractor target/wasm32-unknown-unknown/release/test_token.wasm > test_token.did

dfx start --clean --background
dfx deploy test_token

creating token

dfx canister call test_token create_token \
  "(record{
      token=record {
              name=\"test\";
              description=opt\"test description\"
      };
   })"

mint created token

dfx canister call test_token mint \
    "(record{
        token_id=1;
        holders=vec{record{owner=principal\"$YOU\"}}
    })"

to check more methots please check examples/test_token

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages