Building Onchain LootBoxes With Chainlink

ChainSafe secured a grant from Chainlink, leveraging their Verifiable Random Function (VRF) tool to introduce a new level of integrity and trust to onchain LootBoxes. 

Building Onchain LootBoxes With Chainlink

"We believe web3 gaming adoption is starting to accelerate, and we will see many more innovative use cases, so we feel this is a significant step toward enabling developers to create captivating gaming experiences without having to worry about the security implications of utilizing randomness in their use case" Chainlink Labs

The challenge: transparency in loot boxes

A LootBox is a type of unlockable “treasure chest” that can be bought or won in a video game. Loot boxes typically contain a random selection of in-game items, such as cosmetics, characters, equipment, and more.

Players don’t know what’s inside the loot box until they open it, revealing a random reward that has a predetermined chance of appearing. Loot boxes can be tiered, with some carrying more common loot and others (typically more expensive) hoarding the rare stuff.

Their opaque nature naturally raises questions about fairness and trust. Traditionally, loot boxes are programmed with “pseudorandomness,” meaning the generated numbers (or rewards in a loot box) are made to look and feel random. But with no way to verify how they were calculated, buyers have no guarantee that they are random at all. This can lead to people tampering and potentially influencing which reward they unlock.

Why does this matter? Consider MapleStory, a popular MMORPG and one of the first games to introduce a loot box mechanic in 2003. This past January, Nexon, the developers behind MapleStory, were fined over $8 million for lowering the probability of certain loot box items without communicating the changes to their player base.

Nearly a decade before the Bitcoin whitepaper was published, Micali, Rabin, and Vadhan understood the need to introduce verifiable cryptographic methods to pseudorandom functions. In 1999, the concept of VRF (verifiable random function) was introduced as a way to produce proof with each generated output, ensuring that every random value was accurately calculated.

In 2020, Chainlink built on this work and released the first version of its VRF tool to the Ethereum mainnet, providing verified randomness to blockchain developers. VRF is ideal for smart contracts that need to prove the integrity of their random outputs, and it has since been employed in various use cases. With this grant, ChainSafe’s LootBoxes are added to that growing list!

Our LootBoxes stand as a compelling proof of concept for Chainlink's technology, underlining the pivotal role of decentralized oracles in enhancing digital asset ecosystems. Armed with VRF, ChainSafe LootBoxes are a clear-cut example of how the technology introduces transparency and fairness in places where they’re needed.

"The web3 gaming space has been evolving toward more and more high-level development tools, so having Chainlink VRF natively available in ChainSafe’s SDK was the natural next step" – Chainlink Labs

Building onchain LootBoxes

This project's objective was to develop an onchain LootBox system that utilized Chainlink VRF to generate random outcomes for rewards. By doing so, it creates a verifiably fair system where the process and outcomes are both transparent and trustless.

This work was split into three key parts:

ChainSafe integrated Chainlink VRF to ensure the contents of each LootBox were determined in a tamper-proof and verifiable manner. This integration meant that every player could independently verify the randomness and fairness of their LootBox outcomes.

The verification process, while robust, introduces a layer of complexity from a user's perspective. Typically, the direct interaction with Chainlink's VRF would occur through a developer's dedicated wallet, which bears the cost associated with invoking the VRF service. This setup, although slightly indirect, ensures that the process remains secure and cost-effective for game developers. 

To maintain transparency and allow players to independently verify the fairness of their loot box outcomes, developers can provide users with a link to the transaction on a block explorer. Through this link, players can see the VRF call and confirm that verifiable randomness was used to determine their loot box contents. 

This approach, although it may seem cumbersome at first, strikes a balance between operational efficiency and the imperative for transparency, ensuring that the system's integrity remains intact without placing undue burden on users. A proactive and transparent developer could work this integrity check into the LootBox flow itself, easing verification for their users.

Smart contract development

The smart contract development for LootBoxes goes beyond simple coding—it represents a meticulous design of secure, efficient contracts that request and receive verified random numbers from Chainlink VRF.

Following the guidelines provided by Chainlink's documentation, these contracts form the structure within which LootBoxes operate, guaranteeing game developers and players both engage with a system where fairness is verifiable.

User interface and experience

Traditionally, crafting a LootBox from scratch would require the deployment of multiple specialized contracts, including a warehouse contract to store and manage LootBoxes, a contract for the LootBoxes themselves which specifies the contents, and a contract to integrate Chainlink's VRF for randomness.

ChainSafe's LootBox dashboard transforms this intricate setup into a simplified, intuitive process that can be completed in a few clicks. This approach drastically lowers the barrier of entry for content creators of all skill levels, helping them to contribute user-generated content and engage with the web3 ecosystem without needing in-depth blockchain knowledge.

Here’s a step-by-step guide on how to use the ChainSafe Gaming dashboard to create, manage, and deploy LootBoxes efficiently.

0:00
/5:36

The benefits of ChainSafe LootBoxes

ChainSafe Gaming’s LootBoxes provide a fair foundation where players can be sure about their chances of winning. This not only enhances the interaction but also sets a new standard for digital rewards, community building, game financing, user-generated content, collaboration, and more! 

Community building 👥

The inherent fairness of LootBoxes can foster a stronger, more engaged community around games. Players feel more confident participating in games that employ transparent practices, which in turn can lead to increased player retention and a more vibrant community.

Developers can leverage this trust to host community events, challenges, and competitions that revolve around LootBoxes, further enhancing community engagement and loyalty.

Game financing💰

Developers can use our LootBoxes as a way to fund their projects through pre-sales. By offering loot boxes that contain exclusive items, skins, or early access tokens as part of a crowdfunding campaign, developers can generate seed money while providing backers with verifiable value. 

This approach not only secures upfront financing but also builds anticipation and a sense of ownership among the game's early supporters.

User-generated content ✅

ChainSafe LootBoxes opens up new avenues for user-generated content. Players can create and submit their own items or content to be included in LootBoxes, confident in the knowledge that the selection process will be transparent and fair.

This encourages creativity within the community, allowing players to contribute to the game's ecosystem in meaningful ways and potentially earn from their creations.

Collaborative cross-game opportunities 🤝

The standardized, transparent framework provided by Chainlink VRF for LootBoxes can facilitate collaboration between different games and developers. Items or rewards from one game could be made available in another, creating a cross-promotional ecosystem where assets have utility and value across multiple platforms.

This not only enhances the utility and appeal of LootBoxes but also opens up marketing opportunities through collaborative events and shared player bases.

Bundling assets for marketplaces and launchers 🚀

ChainSafe Gaming’s LootBoxes guarantee fairness and transparency, making them an attractive add-on for bundling assets. Marketplaces and game launchers can offer bundled LootBoxes containing items from various games, providing players with a diverse and exciting selection of rewards.

This not only increases exposure for participating games but also offers a unique and appealing value proposition for players.


"Working with ChainSafe has been nothing short of extraordinary. We were impressed with the team’s knowledge and professionalism, as well as their commitment to building open-source software to help bring the web3 ecosystem to the next level" Chainlink Labs


LootBoxes in action

To demonstrate the power of LootBoxes, we’ve built a dApp where users can win verifiably fair prizes. We run sporadic campaigns with this dApp, so stay tuned for the latest. Here's a sneak peek.

0:00
/0:40