Back to blog
Atlas Corp
Rob-authoredOriginally October 19, 2022

Atlas Innovates ERC-1155 Minting with Chainlink VRF

By Rob678 wordsarticle

Earlier Chainlink VRF article; later version exists separately.

Atlas CORP, a leading provider of web3 development services, has recently launched a smart contract that demonstrates a novel way of minting from ERC-1155 collections. Using Chainlink VRF, users can mint from a contract and receive a verifiably random selection of an 1155 collection. This is a first of a kind deployment which we expect to see deployed in many different forms in subsequent use cases.

Created in partnership with the PHTO team, web3 purveyors of fine art photograph, the Atlas CORP team recently developed the PHTO – Innovation of Influence smart contract. [1 – More info on PHTO]

A mint would select from one of 102 unique collections on the 1155 contract, but the choice of token number is randomly assigned by a Chainlink VRF call. Each mint makes its own call to Chainlink VRF which would result in the user receiving a random token, each with varying degrees of rarity.

Gas Savings & Optimization

One of the primary challenges the team solved was the cost to mint. As the team was providing free mints to Access Pass holders, minimizing gas per mint was of the utmost importance to ensure the project mint costs were feasible. In addition purchasers were not required to bring their own $LINK to the contract to fund the VRF calls; the team provided $LINK on behalf of the users to simplify the purchasing experience. As the VRF callback would trigger the minting on the 1155 smart contract, the majority of the gas spent minting NFTs was paid in $LINK.

This means the team was responsible for covering the costs of the majority of the gas expenditures – both for claims and purchases! It was extremely important to optimize the amount of gas required.

To do so, the Atlas CORP team implemented a binary search tree to determine which token number to assign on the return of the VRF call. Binary search trees are ideal for probability density functions with even distributions; it would have been optimal if each of the 102 tokens on the contract had the exact same supply. As the tokens came in varying supplies and rarities, it was discovered that the execution of the function could be further optimized using a weighted binary tree. This got to the token to be distributed more quickly, further reducing the gas requirement of the mint to that of a more standard ERC-1155 mint.

What’s Next

The pioneering of this technology opens the door for several additional use cases for Chainlink VRF. Project teams can now mint “card packs” – groups of 1155s of varying rarity – in a single, verifiably random transaction. Just like opening a pack of baseball cards where there are standard cards with varying rarities. NFTs can be sold the same way instead of leveraging ERC-721s that don’t stack and have to be separately managed, allowing all the individual cards to be part of the same contract with a small number of token-numbered collections.

This project also portends a future state of the world in which project teams can encourage their community members to “bring their own $LINK” when minting. While the historical trend has been for project teams to supply the $LINK needed for randomness, this typically considers the use case where a single call to Chainlink VRF is used at the onset of a mint and not a unique call to Chainlink VRF with every mint. Contracts can be architected to accept $LINK in lieu of or in addition to the cost of minting an NFT.

If you are looking to build smart contracts that leverage Chainlink VRF, reach out to Atlas CORP today!

************ Additional Content if Desired ************

[1] The latest PHTO initiative is “a collection of historically significant mid century fine art photography showcasing a rarely-seen series of portraits of an emerging brunette starlet named Norma Jeane in 1946 when she was an Armed Forces pinup.” Holders of the PHTO All Access Pass could claim a free mint, followed by an open mint where anyone can purchase.

Source Links