A technical look at the pink.network smart contracts

Jul 27 · 4 min read

pink.network is building a decentralized bankroll service on the WAX io blockchain. You can learn more here.

The core of the pink.network bankroll service are the smart contracts running on the WAX blockchain. All important logic happens within these contracts and is 100% verifiable and decentralized. The API and npm module that we are building help simplify access to the contracts significantly, but in the end, the magic is happening on the blockchain. It is therefore important to understand what happens when a user places a bet with the pink.network API.

All smart contracts are completely open source and available on Github.

Lets start with the bankroll contract:

The very first thing that has to happen to place a roll is to announce it. The announceroll() action saves all the basic information about a roll into the tables of the contract. No information about the bets are stored yet. To add bets, the announcebet() action needs to be called. Note that even when announcing the bets, no WAX is transferred yet. The information about the bet is once again stored in the contract tables, like the bet amount and multiplier, and also who will receive the payout if the bet wins. Only the creator of a roll can announce bets for this roll.

After having announced a roll and all bets, the bet now has to be started. This is done by transferring WAX to the pinkbankroll account with a special memo

startroll <creator_id>

The creator_id was set by the creator when announcing the roll and is therefore known. The contract then verifies that the sent amount equals the sum of all announced bets, and also checks if the bets are acceptable for the bankroll management. If that is not the case, the transaction will be thrown, and no WAX will be transferred. This ensures that no WAX are lost.

To compute the outcome of the roll, a source of randomness is required. This can’t be generated directly on the blockchain because of the inherent boundaries that all blockchains have, but it is possible to verify that the randomness was created fairly. The pinkgambling contract will use the official WAX RNG oracle for generating randomness as soon as it is available. But because it currently hasn’t launched yet, we created an own system, that mirrors the functionality that the official oracle will have. Just like the rest of our contracts, the code for this is completely open source and 100% provably fair.

Looking at it from the bankroll contract’s perspective, this means calling an action in the RNG oracle contract and then waiting for the oracle to callback with the generated random hash. This hash is then converted to a result (1≤ result ≤ max result of the roll), which will be used for determining which bets win.

The most intuitive way to go forward would be to simply pay out all the bets that won. However, because of the way token transfers work with the eosio system, this would allow malicious players to reject the whole transaction and therefore make it impossible for all other players to receive their payouts. The solution to this is to first add the outstanding payouts for each player into a table, and then call a deferred action to pay out the players individually. Deferred actions will execute independently from the transaction that started them. That means that if a single player rejects his payout, all other players still receive their payouts.

But the players don’t interact with the bankroll directly.

Instead they interact with the pinkgambling contract. It acts as an interface for the bankroll contract, and allows for simpler interaction. The contract has two main features:

Quick bets

It is possible to place custom bets in a single transaction by sending WAX to the pinkgambling contract with a special memo. The gambling contract will then automatically announce a new roll and bet, and then send the Wax to the bankroll contract to start the roll, all within a single transaction.


Cycles are basically recurring bets. They first have to be created manually by the developer that intends to use them for his service. On top of the parameters needed for the rolls, the developer also specifies a cycle time. pink.network runs a script that will automatically finish the cycle after the specified cycle time. To ensure decentralization, finishing the cycle is however also possible for anyone else. To reduce spam, our script will stop finishing the cycles if no player joins them for more than 24 hours, and creating a cycle will cost 10 WAX. Those values are subject to change if we detect that the Wax network is congested unnecessarily.

Users can then join an existing cycle with a single transaction. All user bets are pooled within the gambling contract and are then sent to the bankroll contract at once when the cycle is finished. This allows developers to create gamemodes that all players can play together.

When using the pink.network API, all you will be interacting with is the pinkgambling contract. You can get more information about the interactions here, and can also create new cycles directly.

Hopefully you are now able to understand our smart contracts better.

If you are a developer and are interested in building an own gambling application, the pink.network bankroll service is exactly what you need. You can start building right away without having to worry about any of the risks traditionally involved with running a gambling project.

If you want to keep up to date with this project, follow us on Twitter so that you don’t miss any news!


Written by

pink.network is aiming to strengthen the community around the WAX blockchain by creating tools that enable developers to build awesome stuff.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade