Knowledge Base
  • ๐Ÿ‘จโ€๐ŸŽจFor creators
    • ๐Ÿ‘‹Intro to creating with Highlight
    • ๐Ÿ“œProject quick start guides
      • Launch an open edition
      • Launch a delayed reveal collection
      • Launch a 1-of-1 auction
      • Launch a generative artwork
      • Launch an open edition generative artwork
      • Launch a PFP project
      • Launch a generative, image-based PFP project
      • Launch a ranked auction
      • Launch an onchain project
      • Launch a collector's choice project
      • Ongoing drops with the same contract
    • ๐ŸŽ‡Learn the creation flows
      • ERC-721 vs. ERC-1155 Token Standards
      • Edition flow
      • Generative flow
      • Series flow
      • The importance of testing your collections
    • ๐Ÿ‘ฉโ€๐Ÿ’ปUse embeds to build custom mint sites
      • Case Study: How Superchain Chiblings launched a fully custom website on Highlight x Base
      • Running a collector's choice mint via embeds
    • ๐Ÿ’ธSelling your NFTs
      • Available sale methods
        • Ranked auction
        • Dutch auction
        • English auction
      • Setting up gates (allowlists)
      • Combining sale methods
      • Configuring payment currencies
        • Accepting ERC20 payments
        • Accepting credit card payments
      • Payouts, royalties & splits
      • Livestream on the mint page
    • ๐Ÿ› ๏ธManaging your collections
      • Hiding a collection
      • Mint creator reserves
      • Airdropping tokens
      • Updating collection metadata
      • Getting verified
      • Sponsored mints
      • Reducing collection size
    • ๐Ÿ”ฎGenerative & onchain art tools
      • Highlight Studio
      • Onchain file system
      • Storing SVGs onchain
      • Downloading token metadata
      • How onchain is Highlight?
    • ๐ŸŒIntegrations & ecosystem
      • Farcaster
      • Paragraph.xyz
      • Foundation Worlds
        • Importing a collection to Worlds
        • Foundation ร— Highlight FAQs
      • Export generative art from Cables.gl
      • Highlight on mobile
    • ๐Ÿค“Advanced
      • Reusing contracts
      • Randomization algorithm
      • Upload asset specifications
      • Fulfilling auctions for non-transferable tokens
    • โœจAbout Highlight
      • Artwork policies
      • Highlight fees
  • For Collectors
    • ๐Ÿ’ณBuying
      • Buying on secondary
      • Exchange currency across chains
  • ๐Ÿ’ฒSelling
    • Selling on secondary
    • Instantly sell & relist NFTs
  • ๐Ÿ””Notifications
  • For developers
    • Intro to the Highlight Protocol
    • NFT contracts
      • Official addresses
      • ERC721GeneralSequence
      • ERC721General
      • ERC721EditionsDFS
      • ERC721SingleEditionDFS
      • ERC721GenerativeOnchain
      • Deprecated contracts
    • Custom metadata renderers
      • Example custom renderers
    • Minting protocol
      • Mint Managers
      • Mint Mechanics
        • Dutch auction mechanic
        • Ranked auction mechanic
        • Verisart mechanic
        • Seed-based mechanic
        • Auction Manager *
      • Referral Manager
    • Management modules
      • TokenManager
      • RoyaltyManager
    • Observability
    • Onchain File Storage
    • Mint fee oracle
    • Protocol rewards
      • Creator rewards
      • Mint referral rewards
    • Crosschain burn / redeem
  • Official links
    • โœจHighlight website
    • ๐ŸŸฃHighlight Farcaster
    • ๐ŸฆHighlight Twitter
    • ๐Ÿ‘‹About us
Powered by GitBook
On this page
  • Build your own onchain renderer
  • Deploy your Highlight collection
  • Handling seeds
  • CustomMintData
  • Custom renderer interface
  1. For developers

Custom metadata renderers

PreviousDeprecated contractsNextExample custom renderers

Last updated 6 months ago

The metadata for each collection type described above can be configured easily in the Highlight creation flows. It can also be 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

struct CustomRendererConfig {
  address renderer;
  bool processMintDataOnRenderer;
}

setCustomRenderer(CustomRendererConfig calldata _customRendererConfig)

Deploy your Highlight collection

Handling seeds

It's important that your onchain outputs match the outputs of the uploaded script. The demo above has the script query the contract to understand the output. In case you'd like to use a more complex, unpredictable seed (the demo uses the tokenId) that's generated onchain, or you'd like to avoid querying the chain on render every time, the Highlight Generative Engine provides an easy method for your renderer to pass a custom seed into the script at render time.

In a mint transaction, if the following event is emitted at any point from any contract in the transaction, the Highlight engine will pass the data field in as hl.tx.customMintData via hl-gen.js:

event CustomMintData(address indexed sender, address indexed contractAddress, bytes data);

Your script will need to use the seed as the renderer does to replicate outputs, rather than using the hl.random utilities. This means that if the renderer uses the seed to select entries in an array by seed % arrayLength, the script will also need to do this. Use the customMintData field as the seed if passed in, and default to using the transaction hash and tokenId combined as the seed if it doesn't exist, so that test outputs work properly on the mint page.

const onchainSeed = hl.tx.customMintData == "0x" 
 ? hl.tx.hash + hl.tx.tokenId 
 : hl.tx.customMintData;
 
// then use the onchainSeed to select outputs, just like the onchain renderer does
// for eg. if the onchain renderer mods the seed over the array length:
const colorCombinations = [...];
const selectedColorCombination = colorCombinations[
 BigInt(onchainSeed) % BigInt(colorCombinations.length)
];

CustomMintData

In general, the CustomMintData event is a way to pass any form of onchain data to your offchain script. This can be used to facilitate a wide array of use cases, like collector-curated seeds or fully onchain rendered projects.

Custom renderer interface

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 and 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).

To implement your own custom renderer, simply ensure it adheres to the .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 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.

Once you launch your own custom renderer, go through the Highlight 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 (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.

ERC721GenerativeOnchain
ERC721GeneralSequence
gm@highlight.xyz
IHLRenderer
IHLRenderer
Generative flow
TokenManager
updated
A walkthrough for launching a fully onchain Highlight project
47KB
Onchain Demo.zip
archive
Demo zip from the video
Logohl-evm-contracts/contracts/erc721/inchain-rendering/interfaces/IHLRenderer.sol at v1.5.1 ยท highlightxyz/hl-evm-contractsGitHub