PayableMint Trait
So far, our mint()
function is quite generic, giving freedom to a caller to mint any token, but at the same time not allowing insight into which tokens have already been minted. In this section we will more clearly define mint()
, and add several utility functions commonly found in popular NFT projects, that will make this example contract more suitable for production release.
Extending the Trait with Utility Functions
Changes are applied in the logics/traits/payable_mint.rs
file.
mint(to: AccountId, mint_amount: u64)
The mint()
function will now accept an NFT receiver account, and amount of tokens to be minted.
This will allow the contract to control which token will be minted next, and minting of more than one token at a time.
withdraw()
Since our contract accepts native token fees for minting, the owner needs to be able to withdraw the funds, otherwise they'll be locked in the contract forever. This function is set with an only_owner
modifier, that restricts the ability to withdraw funds to the contract owner, only, which are then transferred to the owner's address.