guides
On-Chain Casinos: How Smart-Contract Gambling Works and What Can Go Wrong
On-chain casinos run game logic in smart contracts. See how randomness, oracles and no-loss lotteries work, what TVL means and which technical and legal risks apply.
By Casino Software Hub Editorial Team · Reviewed by Casino Software Hub Editorial Team · Published Oct 30, 2026 · Updated Oct 30, 2026 · 4 min read
Key takeaways
- An on-chain casino puts the game rules and payouts into a smart contract. Anyone can read the code and the transaction history, but the code can still contain bugs.
- Randomness is the hard part. Contracts depend on oracles with verifiable random functions or on commit-reveal schemes.
- TVL measures deposits, not safety. Most on-chain gambling has no licence, no dispute process and no way to reverse a transaction.
What “on-chain” means
At a conventional online casino the operator’s servers run the games and keep the balances. In an on-chain casino a smart contract does both. The player sends a transaction from a wallet, the contract resolves the bet and the payout moves by another transaction. The contract’s code and every past bet are public.
This is different from a regular crypto casino, which only accepts crypto payments while the games still run on the operator’s servers. See our guide to what crypto casino software is for that model.
Common contract types
The simplest on-chain games are dice and coin-flip contracts. The player picks a target or a side, sends a stake, and the contract returns a payout if the random result matches. The house edge is set as a parameter in the code and can be checked by reading it.
Other designs include roulette-style contracts, crash-style games and pooled bankrolls, where liquidity providers fund the house side and share its results, including its losses.
Where randomness comes from
A blockchain is deterministic: every node must compute the same result. That means a contract cannot simply call a random function. Two approaches are common:
| Method | How it works | Main weakness |
|---|---|---|
| Verifiable random function (VRF) via an oracle | An external service generates a number and a cryptographic proof that the contract verifies | Depends on the oracle service and adds delay and fees |
| Commit-reveal | Each side commits to a hidden value, then reveals it; the result is derived from both | A party can refuse to reveal, so timeouts are needed |
| Block data (hash, timestamp) | The contract reads values from the chain | Block producers can influence these values, so it is considered weak |
The idea behind verification is the same as in provably fair games: the player can check after the fact that the result was not altered.
No-loss lotteries
A no-loss lottery works differently from a dice contract. Participants deposit funds into a pool. The pool earns yield through a lending protocol, and the yield, not the deposits, is awarded as prizes to randomly selected participants. Depositors can usually withdraw their principal.
PoolTogether is the best-known example of this design. “No-loss” refers to the prize mechanism only. The deposit still faces smart-contract risk, the risk of the underlying lending protocol and, for non-stablecoin deposits, price risk. Yield rates and prize sizes vary and are not guaranteed.
What TVL tells you
Total value locked is the sum of assets held in a protocol’s contracts, usually quoted in US dollars. It is a size indicator. A larger TVL means more deposits, but it can also mean a larger target for attackers. It does not measure fairness, audit quality or legal standing, and it moves with token prices.
Our on-chain page lists protocols with data pulled from DefiLlama. It is a data catalogue, not an endorsement, and a listing does not mean a protocol is safe or legal where you live.
Risks specific to smart-contract gambling
- Contract bugs. Code that handles money can have errors. Audits reduce the risk but do not remove it.
- Exploits. Attackers have drained DeFi contracts through logic flaws, manipulated price feeds and compromised admin keys.
- Randomness failures. A weak source of randomness can be predicted or influenced.
- Admin control. Some contracts have upgrade or pause keys held by a small group, which means “trustless” may be only partly true.
- Irreversibility. A confirmed transaction cannot be recalled, and a mistaken address or a wrong network is usually a permanent loss.
- No licence or recourse. Most protocols have no regulator, no complaints body and no player-protection tools such as limits or self-exclusion.
- Legal status. Online gambling law applies to a player’s location regardless of where a protocol is deployed.
Reading the information
When a protocol states that its games are fair, the useful questions are factual ones. Is the contract source verified on a block explorer? Has an independent firm published an audit, and which version of the code did it cover? Who can change the contract? How is randomness produced? If these cannot be answered from public sources, the claim cannot be checked.
For tools that help players control their own spending, and for why they are scarce in this part of the market, see our responsible gambling page.
This article is information, not advice to gamble. You must be 18 or older.
FAQ
What is an on-chain casino?
An on-chain casino is a game whose rules and payouts are written in a smart contract on a blockchain. Bets and results are recorded as public transactions instead of in a private operator database.
How does a smart contract get random numbers?
A contract cannot generate true randomness by itself, because every node must reach the same result. It usually relies on an oracle service that returns a random value with a cryptographic proof, or on a commit-reveal scheme.
What does TVL mean for a gambling protocol?
TVL, total value locked, is the value of assets held in a protocol's contracts. It shows how much money is deposited. It says nothing about whether the protocol is safe, fair or legal.
Is on-chain gambling regulated?
Many on-chain gambling protocols have no gambling licence and no complaints process. Whether they are legal depends on the law where the player lives.