NFT
Prepare modules for production The final stage of development is to get the smart contract module ready for production. This work is mapped into create_nft_getting_production_ready.BSC.
We prepare the production module by:
Add TokenMintingEvent to emit a custom event to track tokens generated from this module.
Enable signature verification and introduce the concept of proof challenges to prevent bot spam.
Include unit tests to ensure our code works as expected.
Create NFT
Run the following command to attempt to mint an NFT, including your
<resource-account-address>
(failure expected):
Mint the NFT
Mint the NFT by calling the
mint_nft
function and an existing contract using the Aits CLI:
{ "Result": { "transaction_hash": "0x6e022532fb8d802324829d5ec85fd32c05a58a6f826751f63cdbf9bf313ff991",
"gas_used": 3944,
"gas_unit_price": 150,
"sender": "b9d394a7bc582a54e8610d6a7b973f62c8d9595c54c35cdbb95965aa8e5cd111",
"sequence_number": 0,
"success": true,
"timestamp_us": 1670969779029341,
"version": 385901038,
"vm_status": "Executed successfully" }
}
*/
NFT Airdrops
Using the NFT mint example replace the mint
function with an airdrop
function as below.
public entry fun airdrop(whitelist: vector) acquires ModuleData {
let module_data = borrow_global_mut(@mint_nft);
let count = vector::length(&whitelists);
let resource_signer = account::create_signer_with_capability(&module_data.signer_cap);
let token_id = token::mint_token(&resource_signer, module_data.token_data_id, count);
let i: u64 = 0;
let i: u64 = 0;
let receiver = vector::pop_back(&mut whitelist);
token_transfers::offer(&resource_signer, receiver, token_id, 1);
i = i + 1;
};
}
Refresh the page to view the latest documents
Last updated