checkTokenIdExistsForEventId

This view function checks if a specific token ID exists for a given event. It takes two parameters:

  • _eventId: The unique identifier for the event.

  • _tokenId: The token ID to be checked for existence.

// Some code

```remix-solidity
/**
    CheckTokenIdExistsForEventId: Check if a specific token ID exists for a given event.
    @param _eventId: The unique identifier for the event.
    @param _tokenId: The token ID to be checked for existence.
    @return bool: A boolean indicating whether the token ID exists for the event.
    */
    function checkTokenIdExistsForEventId(
        string calldata _eventId,
        uint256 _tokenId
    ) public view returns (bool) {
        // Retrieve all token IDs associated with the event
        uint256[] memory _tokenIds = getTokenIdsFromEventId(_eventId);
        // Loop through token IDs to check for the existence of the specified token ID
        for (uint256 i = 0; i < _tokenIds.length; ++i) {
            if (_tokenIds[i] == _tokenId) {
                return true;
            }
        }
        return false;
    }
```

Explanation:

The function retrieves all token IDs associated with the event using the getTokenIdsFromEventId function. Then, it iterates through these token IDs to check if the specified token ID exists among them. If it finds a match, indicating that the token ID exists for the event, the function returns true; otherwise, it returns false.

Last updated