Deploying an NFT collection on Aptos

Dev Insights by Hypotenuse Labs

NFT Collection “Hype Collection” on the Aptos blockchain

Project overview

Move modules

public entry fun initialize_auction<CoinType>(sender: &signer, creator: address, collection_name: vector<u8>, token_name: vector<u8>, min_selling_price: u64, duration: u64, property_version: u64) acquires AuctionItem, AuctionEvents {
let sender_addr = signer::address_of(sender);
let token_id = token::create_token_id_raw(creator, string::utf8(collection_name), string::utf8(token_name), property_version);

// Check if the seller actually owns the NFT
assert!(token::balance_of(sender_addr, token_id) > 0, ESELLER_DOESNT_OWN_TOKEN);

let start_time = timestamp::now_microseconds();
let end_time = duration + start_time;

// Creating a Coin<CoinType> with zero value which would be increased when someone bids
let zero_coin = coin::zero<CoinType>();
let withdrawCapability = token::create_withdraw_capability(sender, token_id, 1, end_time + 1000000);
let item = Item{
min_selling_price,
end_time,
start_time,
current_bid: zero_coin,
current_bidder: sender_addr,
token: token_id,
withdrawCapability
};

...
}
public entry fun create_collection_token_and_list<CoinType>(
creator: &signer,
collection_name: vector<u8>,
collection_description: vector<u8>,
collection_uri: vector<u8>,
collection_maximum: u64,
collection_mutate_setting: vector<bool>,
token_name: vector<u8>,
token_description: vector<u8>,
token_uri: vector<u8>,
royalty_payee_address: address,
royalty_points_denominator: u64,
royalty_points_numerator: u64,
token_mutate_setting: vector<bool>,
property_keys: vector<string::String>,
property_values: vector<vector<u8>>,
property_types: vector<string::String>,
list_price: u64,
expiration_time: u64,
) acquires ListingItem, ListingEvents {
token::create_collection_script(
creator,
string::utf8(collection_name),
string::utf8(collection_description),
string::utf8(collection_uri),
collection_maximum,
collection_mutate_setting
);
token::create_token_script(
creator,
string::utf8(collection_name),
string::utf8(token_name),
string::utf8(token_description),
1, // amount
1, // maximum
string::utf8(token_uri),
royalty_payee_address,
royalty_points_denominator,
royalty_points_numerator,
token_mutate_setting,
property_keys,
property_values,
property_types
);
let token_id = token::create_token_id_raw(creator_addr, string::utf8(collection_name), string::utf8(token_name), 0);

assert!(!exists<ListingItem<CoinType>>(creator_addr), EITEM_ALREADY_EXISTS);

// Check if the seller actually owns the NFT
assert!(token::balance_of(creator_addr, token_id) > 0, ESELLER_DOESNT_OWN_TOKEN);

let start_time = timestamp::now_microseconds();
let end_time = expiration_time + start_time;

let withdrawCapability = token::create_withdraw_capability(creator, token_id, 1, expiration_time);

let item = Item {
list_price,
end_time,
token: token_id,
withdrawCapability
};

TODOs (for anyone wishing to branch off)

Building incredible web, AI, and blockchain products since 2018

--

--

Building incredible web, AI, and blockchain solutions since 2018.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hypotenuse Labs

Building incredible web, AI, and blockchain solutions since 2018.