Skip to main content

tokenURI

Contract: JBProjects​‌

Interface: IERC721Metadata​‌

Returns the URI where the ERC-721 standard JSON of a project is hosted.

Definition

function tokenURI(uint256 _projectId) public view override returns (string memory) { ... }
  • Arguments:
    • _projectId is the ID of the project to get a URI of.
  • The view function can be accessed externally by anyone.
  • The view function does not alter state on the blockchain.
  • The function overrides a function definition from the IERC721Metadata interface.
  • The function returns the token URI to use for the provided _projectId.

Body

  1. Keep a reference to the resolver.

     // Keep a reference to the resolver.
    IJBTokenUriResolver _tokenUriResolver = tokenUriResolver;

    Internal references:

  2. Return an empty string if there is no URI resolver set.

    // If there's no resolver, there's no URI.
    if (_tokenUriResolver == IJBTokenUriResolver(address(0))) return '';
  3. Resolve the URI for the project.

    // Return the resolved URI.
    return _tokenUriResolver.getUri(_projectId);

    External references: