Home GamingCasinoWhy are minimum bets in on-chain roulette set in gwei?

Why are minimum bets in on-chain roulette set in gwei?

by Angelina Aidan

On-chain roulette contracts on Ethereum and its layer 2 networks, including any crypto games roulette table built there, store every amount in wei and quote the minimum bet in gwei, because gwei is the unit gas is priced in and the unit at which the arithmetic of a spin stops being swamped by rounding. Ten points cover why and what the figure means when you read it.

  1. Wei is the base unit, and it has no decimals. One ether is ten to the eighteenth wei. A contract cannot hold a fraction, so every balance, stake and payout is a whole number of wei, and every calculation the contract does is integer arithmetic on those numbers.
  2. Gwei is a billion wei, and it is the unit gas is priced in. A gas price of 20 gwei means 20 billion wei per unit of gas. Quoting the minimum bet in the same unit puts the stake and the fee it has to cover side by side.
  3. Ether is a billion gwei, and it is the unit your wallet shows. A minimum of 10,000,000 gwei is 0.01 ether. The table interface does the conversion for the screen, but the contract only ever sees the wei count.
  4. The fee sets the floor. A bet call uses around 150,000 gas. At 20 gwei on the main chain, that is 3,000,000 gwei per spin, or 0.003 ether. A table where gas is a third of the stake is unplayable, so the minimum is set at several times the typical fee, which on the main chain lands near 0.01 ether.
  5. Layer 2 networks lower the floor. Gas there is priced in fractions of a gwei, so the same call costs a few thousand gwei, and the minimum can drop to 100,000 gwei or less without gas becoming a large share of the stake.
  6. Rounding sets a second floor. A straight-up win multiplies the stake by 36, and a la partage refund halves it. Integer division drops any remainder. At stake are millions of gwei, the remainder is a billionth of a per cent, and nobody notices. The minimum sits well above the range where it would.
  7. Storage sets a third floor. Recording a bet writes several values to contract storage, the most expensive thing a transaction does. A stake worth less than the cost of writing it down is not worth accepting.
  8. The minimum can move. Contracts with an owner or a DAO can raise or lower it as gas prices change, and main-chain tables adjust more often than layer 2 tables. Read it on the day rather than from memory.
  9. Compare the minimum with the day’s gas before betting it. The minimum is set so that gas is under a tenth of a minimum stake on a normal day, and on a busy main-chain day, that ratio worsens until a minimum bet can cost more in gas than it stakes.
  10. The maximum is stored the same way. It is also a wei count quoted in gwei, and the gap between the two figures is the whole range the table will accept from a single wallet on a single spin.

A minimum quoted in gwei is a minimum quoted in the same unit as the fee, which is why the number looks larger than it is and why dividing by a billion is the only step needed to read it.

Related Articles