CryptoVikings Integrates Chainlink VRF on Polygon for Fair and Equitable NFT Mints

There’s a huge demand right now for unique and interesting NFTs — just look at OpenSea’s incredible $3.4bn trading volume in August. Well-known genesis collections like CryptoPunks and CryptoKitties kickstarted an evolving trend towards a booming contemporary market of like-minded generative NFT ventures, and demand looks to be on the rise.

With a collective itch to take a first and meaningful step into the intensely fascinating world of Ethereum development, what would become the CryptoVikings team — a group of long-term friends; two developers and one artist — decided to take a deeper look at the growing wealth of generative NFT collections in early 2021 and make an attempt at bringing something interesting and different to the table.

Now, after many late nights, we’re excited to talk in more technical terms about the outcome of our work — CryptoVikings; a hand-drawn generative NFT art collection on Polygon. As part of the launch, we’ve integrated Chainlink VRF (Verifiable Random Function) into our procedural, truly random, and equitable minting/generation procedure. With Chainlink VRF providing a verifiably tamper-proof RNG, we’re able to produce a full and meaningful on-chain representation of a CryptoViking to use as a source of immutable truth for asset generation, resulting in a completely non-manipulable and provably-fair minting outcome.

The Problem: Vulnerabilities in Existing RNG Solutions

Early in our market research we identified a common design pattern for generative NFT collections and the critical issue it presented — a large majority of such collections are made up of a set of randomised and pregenerated assets, a very simple ERC-721 contract, and an API which serves metadata to secondary markets. Their concepts of rarity and scarcity come from the probability of the generation algorithm selecting any given piece from the sets that make up the final assets.

Taking a deeper look, we found that a lot of these collections were predictable or otherwise manipulable, despite having been produced off-chain and in private. We found open APIs serving metadata associated with unminted tokens and crawlable and revealing front ends, resulting in scriptable assurances of obtaining something valuable or rare within the set.

Existing solutions to this problem among this group of projects largely revolved around somehow delaying the reveal of the assets or metadata — employing the same setup but sidestepping the issue of equitability rather than really solving it.

So this is how we decided to differentiate ourselves — we’d solve this equitability issue not with a reveal, but by implementing a slightly more involved system that would enable us to avoid pregenerating our assets or artificially hiding them. We wanted to make them on-demand in a trustworthy and reproducible fashion, and to make the process provably fair for everyone.

For this, we needed secure and verifiable random numbers in our smart contract to bring the critical portion of the generation procedure on-chain. It doesn’t take much thought or research to find that producing random numbers in a deterministic environment like a blockchain is not a great idea for equitability — so we hunted for a solution.

The Solution: Chainlink VRF

A quick intro: Chainlink is a decentralised oracle network that enables smart contracts to securely access off-chain data and APIs and conduct various forms of trust-minimised off-chain computation. Chainlink is well known for providing highly secure and reliable oracles across top DeFi and NFT projects that help secure tens of billions of dollars in on-chain value.

A decentralised oracle network is a secure middleware that facilitates communication between blockchains and off-chain systems, enabling a huge wealth of functionality in smart contracts that would otherwise not be practical or possible with native implementation. The Chainlink blog’s own explainer on the oracle problem and how Chainlink solves it makes for some fantastic reading.

For our use-case, Chainlink VRF (Verifiable Random Function) was the perfect choice. It’s an oracle network that uses secure off-chain computation and on-chain verification to generate cryptographically secure and trustworthy random numbers for smart contracts, opening up cases like ours whereby trustworthy random numbers are critical.

Chainlink VRF works by combining block data that is still unknown when the request is made with the oracle node’s pre-committed private key to generate both a random number and a cryptographic proof. The CryptoViking minting contract will only accept the random number input if it has a valid cryptographic proof, and the cryptographic proof can only be generated if the VRF process is tamper-proof. This helps provide automated and publicly verifiable proof directly on-chain that minting CryptoVikings is provably fair and cannot be tampered with or predicted by the oracle, outside entities, or the CryptoVikings team.

With Chainlink VRF, we had our random numbers and the key to realising our goal.

On-Demand, Equitable Generation

Through much iterative development and testing, we arrived at a cooperative procedure between our API and two contracts, which produces CryptoVikings on-demand and in a provably fair way.

When you decide to mint a CryptoViking, your transaction kicks off the NFT mint itself and the sending of a request to Chainlink VRF for a random number. We handle the rest past this point — your transaction is complete.

The number we get back from Chainlink VRF is stored publicly against the token ID for future use and for anyone to see; the API is then prompted that a CryptoViking is ready to be generated and the process begins.

First, the API tells the main contract to use the random number to derive a data structure numerically representing the CryptoViking, called VikingStats. VikingStats contains a series of smaller numbers which we’ll use later to resolve and store some more information about the CryptoViking, and it’s also stored publicly against the token ID.

Next, the API asks the contract to resolve the CryptoViking’s component names and item conditions. CryptoVikings are made up of nine components, of which five items are modified by a condition — so we need the names of each component and the conditions of the items.

For this step, the contract sends the appropriate VikingStats to a second contract, which is responsible for resolving the names and conditions by using the selectors found in the VikingStats to implement a probability distribution for each asset within its set. The result of this resolution is two further data structures — VikingComponents and VikingConditions, which are returned to the main contract and stored publicly against the token ID.

At this stage, the main contract contains a full and public representation of the CryptoViking which can be used as a source of truth for metadata and image construction. Through an event, this representation is sent to the API, where these final steps are performed. The website is then prompted to reveal the newly-generated CryptoViking immediately to the buyer.

“With Chainlink VRF as a critical component, this process helps ensure that assigning traits to CryptoVikings NFTs is completely non-manipulable — everything is done at the point of purchase and the final outcome is based on a provably fair number, with both that and the CryptoViking’s full representation stored immutably for all to see,” said CryptoVikings Technical Founder Thor. “There’s no way for anyone to predict the outcome of any given mint, nor in any way ensure that they unfairly obtain the best of the collection — the issue of equitability in minting outcomes is solved without the need for any workarounds.”

A cool byproduct of this cooperative process and the on-chain storage of a CryptoViking’s representation is a protection against data loss that we’ve also found quite rare in generative NFT collections. Since we use the on-chain representation as a source of truth for metadata and image production, it’s possible to recover the entire CryptoVikings collection just by asking the contract for the right information. Our API is capable of actioning this recovery, as well as correcting any missing data on either side of the equation. CryptoVikings are forever protected against hosting issues, corruption, or data loss.

The Drop

CryptoVikings’ mint will open on Polygon on September 24th at 8PM EST — be there for the drop and find out more on our website.

In the meantime, you can check out our main smart contract here, come say hi to us on Discord, check out our whitepaper and follow us on Twitter.

We’ve had a ton of fun and learned a lot in making this work, and with this as a first step along the road we’re excited to see how we can evolve CryptoVikings in the future.

Learn More About Chainlink

Chainlink is the industry standard for building, accessing, and selling oracle services needed to power hybrid smart contracts on any blockchain. Chainlink oracle networks provide smart contracts with a way to reliably connect to any external API and leverage secure off-chain computations for enabling feature-rich applications. Chainlink currently secures tens of billions of dollars across DeFi, insurance, gaming, and other major industries, and offers global enterprises and leading data providers a universal gateway to all blockchains. Learn more about Chainlink by visiting or read the documentation at To discuss an integration, reach out to an expert.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


The CryptoVikings are a legion of 9873 verifiably-random and unique Viking NFTs who live on Polygon.