---
# System prepended metadata

title: _setTokenURI

---



# _setTokenURI

Found [here](https://github.com/briqNFT/briq-protocol/blob/next/contracts/set_erc721/token_uri.cairo#L133)

- This *internal* function is only called once, from [setTokenURI_](https://github.com/briqNFT/briq-protocol/blob/next/contracts/set_erc721/token_uri.cairo#L171). However, the comment above indicates this is only for testing.
    - In which case, this testing function should be put in a separate contract so as to separate the test case-specific functionality from core protocol functionality.
- It is also only called with `may_use_special_token_mode == 0`. This means that [`if uri_len * may_use_special_token_mode == 2`](https://github.com/briqNFT/briq-protocol/blob/next/contracts/set_erc721/token_uri.cairo#L143) will never evaluate to `true`.
- "special token mode" appears to be a condition where the URI's first 59 bits of the first element in `uri : felt*` are considered a separate part of the URI. Not sure what the point of this is.
- Regardless, **I think** we want to enforce that if `may_use_special_token_mode == 1`, then `uri_len == 2`
- If [`uri[1] != rem`](https://github.com/briqNFT/briq-protocol/blob/next/contracts/set_erc721/token_uri.cairo#L152), it seems to just ignore the special token ID result from [line `144`](https://github.com/briqNFT/briq-protocol/blob/next/contracts/set_erc721/token_uri.cairo#L144).
    - This indicates to me that if `uri[1]` has bits set other than the first 59, it doesn't use special token ID mode.
- When fetching a token URI that has a special ID mode (first 2 LSBs == 3), the second element of the returned `uri: felt*` == the `token_id` for which we are trying to fetch the URI, masked with `2**59 - 1`.

### ...potential finding...
- This means that [when the `uri[1]` is set in special token ID mode](https://github.com/briqNFT/briq-protocol/blob/next/contracts/set_erc721/token_uri.cairo#L144), [it is not actually read when fetching the URI
](https://github.com/briqNFT/briq-protocol/blob/next/contracts/set_erc721/token_uri.cairo#L101-L103)
    - However, it is hard to 100% confirm if this is an issue because I'm not 100% sure on what special token ID mode is supposed to do.