forked from glitchpilot/sui_TN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mint_nft.move
27 lines (25 loc) · 949 Bytes
/
mint_nft.move
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Mint NFT function
public fun mint_nft(community_id: u64, recipient: address, metadata: vector<u8>): bool {
let community: &mut Community;
if borrow_global<Community>(community_id) {
community = copy(g);
let sender = get_txn_sender();
// Check if the sender is the owner of the community
if sender == community.owner {
let nft_id = 1; // Generate a unique NFT ID (you should implement this logic)
let new_nft = NFT {
id: nft_id,
metadata: metadata,
owner: recipient,
community_id: community_id,
};
// Transfer ownership of the NFT to the recipient
move_to(new_nft, &mut Ctx.self_nfts);
true
} else {
false // Only the owner can mint NFTs
}
} else {
false // Community with the given ID does not exist
}
}