Custom metadata renderers

The metadata for each collection type described above can be configured easily in the Highlight creation flows. It can also be updated after the contract is deployed. However, sometimes creators will want to customize their metadata in ways that arenโ€™t directly supported by the Highlight UI.

Build your own onchain renderer

For these cases, Highlight supports the ability for creators to point to their own metadata โ€œrendererโ€โ€”another smart contract which will serve up the metadata however you like. To take advantage of this, you can invoke the following method on the ERC721GenerativeOnchain and ERC721GeneralSequence contracts (let us know at if youโ€™d like to use this for other collection types), passing in the address where the renderer is served, and a boolean indicating whether to pass mint data to the renderer (in cases where, for example, you want to do something like store a random seed for a token at mint time).

struct CustomRendererConfig {
  address renderer;
  bool processMintDataOnRenderer;

setCustomRenderer(CustomRendererConfig calldata _customRendererConfig)

To implement your own custom renderer, simply ensure it adheres to the IHLRenderer.sol interface. If processMintDataOnRenderer is false, then the only integration that the contract has with your custom renderer is to hook into your renderer's tokenURI implementation, rather than it's own. If processMintDataOnRenderer is true, then the NFT contract will call the processing hooks on the IHLRenderer interface to process custom logic on your renderer. A common use for these hooks is to store a seed at mint time, where the seed is used when calling tokenURI on the renderer, to construct the metadata fully on-chain.

Deploy your Highlight collection

Once you launch your own custom renderer, go through the Highlight Generative flow and launch a Highlight collection. In the first step of that flow, you'll be asked to upload a local (offchain) version of your project. This powers cool UI features like cycling through example mint iterations on the mint page. For these cases, we recommend simply fetching preview outputs from your smart contract. We have a boilerplate, which can be found in sketch.js in the code below, which you can use to simply substitute in some of your own variables.

It's also important to note that if there is a TokenManager (management module) applied to an individual token, edition, or contract, then the metadata update logic enforced by the TokenManager will dictate whether the metadata update can happen.

Last updated