Skip to content

Instantly share code, notes, and snippets.

@puneetkaura
Created June 21, 2024 08:24
Show Gist options
  • Save puneetkaura/b9d0dfd72f985483b45c56244b9d06fc to your computer and use it in GitHub Desktop.
Save puneetkaura/b9d0dfd72f985483b45c56244b9d06fc to your computer and use it in GitHub Desktop.
Logo
Beta
API Docs
Copilot
Gas Viewer
Decompiler
Setting
0xc1...312f
Token Design for GPT
Bonnie image
Stage 1: Planning 🤔
Certainly, I'm excited to bring your vision to life with a secure and efficient NFT smart contract on the Sui blockchain. I have created a table to illustrate the properties of your SUI smart contract design. Please feel free to edit it as needed.
TITLE VALUE DESCRIPTION
Name ExclusiveNFT A unique name for the NFT collection to be easily identified.
Symbol EXNFT A short, memorable symbol to represent the NFT on exchanges and wallets.
Purpose Rewarding high coin holders with exclusive NFTs To incentivize holding a certain coin by offering a unique NFT as a reward.
Total Supply 1000 Only 1000 NFTs can be minted to maintain rarity and value.
Coin Image URL https://example.com/coin.png Default image for the coin, used in wallets and exchanges.
Decimals 9 Coins will be displayed with 9 decimals to ensure precision in transactions.
Minting Requirement 10000 A wallet must hold 10000 or more of the specified coin to mint the NFT.
Minting Limitation 1 Each wallet is restricted to minting only one NFT to ensure fair distribution.
Should Owner Mint More or Capped? Capped The total supply is capped at 1000 NFTs, with no additional minting allowed.
Bonnie image
Stage 2: Search SUI Mainnet 🔍
Discovered 2 SUI smart contracts associated with your coin definition. Explore them further with SuiGPT by clicking on each listed coin below.
Coin: FUD
Coin: REAP
Bonnie image
Stage 3: Generate SUI Move Code 👩‍💻
address 0x1;
module ExclusiveNFT {
use 0x1::coin;
use 0x1::sui::tx_context;
use 0x1::sui::transfer;
use 0x1::std::option;
use 0x1::std::vector;
use 0x1::url;
const MAX_SUPPLY: u64 = 1000;
const MINTING_REQUIREMENT: u64 = 10000;
const NFT_DECIMALS: u8 = 9;
struct NFT has key {
id: u64,
image_url: vector<u8>,
}
struct NFTCollection has key {
nfts: vector<NFT>,
}
struct MintedNFTs has key {
minted: bool,
}
public fun init(ctx: &mut tx_context::TxContext) {
let sender = tx_context::sender(ctx);
transfer::create_owned_resource<MintedNFTs>(sender, MintedNFTs { minted: false }, ctx);
transfer::create_owned_resource<NFTCollection>(sender, NFTCollection { nfts: vector::empty() }, ctx);
}
public entry fun mint_nft(ctx: &mut tx_context::TxContext, coin_type: type, image_url: vector<u8>) {
let sender = tx_context::sender(ctx);
let sender_balance = coin::balance<coin_type>(sender);
let minted_nfts = transfer::borrow_global_mut<MintedNFTs>(sender);
let nft_collection = transfer::borrow_global_mut<NFTCollection>(sender);
assert!(sender_balance >= MINTING_REQUIREMENT, 1, "Insufficient balance to mint NFT");
assert!(!minted_nfts.minted, 2, "NFT already minted for this account");
assert!(vector::length(&nft_collection.nfts) < MAX_SUPPLY, 3, "Max NFT supply reached");
let nft_id = vector::length(&nft_collection.nfts) + 1;
vector::push_back(&mut nft_collection.nfts, NFT { id: nft_id, image_url: image_url });
minted_nfts.minted = true;
}
public fun get_nft_collection(owner: address): vector<NFT> acquires NFTCollection {
*&borrow_global<NFTCollection>(owner).nfts
}
public fun get_minted_status(owner: address): bool acquires MintedNFTs {
borrow_global<MintedNFTs>(owner).minted
}
}
This Move smart contract implements the specifications provided by the client. It includes functionality to initialize the NFT collection and minting status for a user, mint an NFT if the user meets the specified coin balance requirement, and ensures that only one NFT can be minted per wallet and that the total supply does not exceed 1000 NFTs. It also provides functions to retrieve the NFT collection and minting status of a user.
Regenerate
Bucket Ecosystem Product
SuiGPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment