Knowledge Base
Search
K

Highlight code snippet

Overview

Integrating the Highlight code snippet into your code gives you access to a suite of utility functions and enables interaction with different Highlight modules.
The hl-gen.js script gives you access to a number of pieces of data from the blockchain, including the transaction hash, block hash, minting wallet address, token ID, edition size, and more. It also provides helper functions to generate deterministic randomness within your project. These helper functions are seeded by a combination of the transaction hash (or a predetermined hash if you choose) and the token ID.

Hl-gen.js overview | Variables

Variables
Type
Description
hash
String
The transaction hash or pre-determined hash
blockHash
String
The block hash of the transaction to mint a token
timestamp
String
The timestamp of the block hash
walletAddress
String
The wallet address of the wallet minting the token
tokenId
String
The token ID of the token being minted
editionSize
String
The total number of tokens in this collection
mintSize
String
The number of tokens currently being minted (1 if not batch mint)
mintIteration
String
The iteration of token being rendered within the current mint (from 1 to mintSize)
contractAddress
String
The address of the contract
chainId
String
The id of the blockchain
gasPrice
String
The price per unit of gas (in gwei) at the time of mint
gasUsed
String
The amount of gas used in a specific mint transaction

Hl-gen.js overview | Functions

Function
Type
Description
random
number
Random number between 0 (inclusive) and 1 (exclusive)
random: (max)
number
Random number between 0 (inclusive) and max (exclusive)
random: (min, max)
number
Random number between min (inclusive) and max (exclusive)
randomInt: ()
number
Random integer between 0 (inclusive) and 100 (inclusive)
randomInt: (max)
number
Random integer between 0 (inclusive) and max (inclusive)
randomInt: (min, max)
number
Random integer between min (inclusive) and max (inclusive)
randomBool: (percent)
boolean
Random bool with percent chance of being true
randomElement: (array)
any
Random element from the provided array
capturePreview: ()
void
Triggers capture of preview image for the token