mintTicket
// Some code
```remix-solidity
/**
MintTicket: Mint tickets for the specified recipients, events, access levels, and amounts.
@param _to: Array of recipient addresses for whom tickets are to be minted.
@param _eventIds: Array of event IDs for which tickets are to be minted.
@param _accessLevels: Array of access levels for the tickets being minted.
@param _amounts: Array of amounts of tickets to be minted for each recipient.
Format: to, eventIds, accessLevels, amounts
*/
function mintTicket(
address[] calldata _to,
string[] calldata _eventIds,
string[] calldata _accessLevels,
uint256[] calldata _amounts
) public nonReentrant {
// Check if the lengths of input arrays match
if (!checkLengths(_to, _eventIds, _accessLevels, _amounts))
revert DecastGating__UnmatchedArrayLength();
// Iterate through each recipient
for (uint256 i = 0; i < _to.length; ++i) {
// Get the token ID for the specified event and access level
uint256 _tokenId = getTokenIdOfAccessLevel(
_eventIds[i],
_accessLevels[i]
);
// Check if the ticket price is greater than 0, indicating a paid ticket
if (getTicketPriceFromTokenId(_tokenId) > 0)
revert DecastGating__PaidTicket();
// Check if the recipient address is valid
if (_to[i] == address(0))
revert DecastGating__InvalidInputAddress();
// Check if the amount of tickets is valid
if (_amounts[i] <= 0) revert DecastGating__InvalidInputAmount();
// Check if the token ID exists for the specified event
if (!checkTokenIdExistsForEventId(_eventIds[i], _tokenId))
revert DecastGating__TokenIdDoesNotExists();
// Mint the ticket
_mintTicket(_eventIds[i], _to[i], _tokenId, _amounts[i]);
}
}
```Explanation:
Last updated