TL;DR: NostrDice is a provably fair game built on Nostr and Lightning.
# Why build NostrDice
Nostr has been around for a while now, but we’ve only used it as a social network. We had not had a chance to look under the hood to see how things work and what you can do with it.
We wanted to get our hands dirty. But we didn’t just want to follow some tutorials; we wanted to build something fun and see how far Nostr could take us.
After some brainstorming, we landed on the legendary game SatoshiDICE. Why not bring the OG of all Bitcoin games to Lightning using Nostr?
> We are going to build our own SatoshiDICE, with blackjack and hookers
NostrDice is SathoshiDICE on steroids. I mean, it’s built with Nostr and Lightning.
## Design Goals of NostrDice
Before we jump into it, these are our design goals for the game.
1. Provably fair. The NostrDice server must not be able to control the outcome of a die roll. Players must be able to verify that the NostrDice server is not cheating.
2. Easy to use. The game should be compatible with any Nostr client (which supports Zaps). No new clients should be required to play the game.
3. Have fun building it! This was the main goal if we’re honest :D
Looking into how Zaps work we quickly figure out a way to use them to place bets and pay out lucky winners.
### How NostrDice Works
We set up 3 accounts on Nostr:
- NostrDice Game: This is where you play. Zap your chosen multiplier note, roll the die and win some sats, sometimes. @NostrDice Game
- NostrDice Nonces: Here you can find proof that the server is playing fair with your dice rolls. @npub1nstr...zcwp
- NostrDice Social: A place for us to promote the game. Follow us to get the latest updates. @NostrDice
1. Commitment to a Secret Nonce
A new round starts when the NostrDice server posts a commitment to a nonce on @npub1nstr...zcwp. The server does this *before* receiving any information from the player, so it can choose the nonce based on the player’s input.
2. **Placing a Bet**
The player chooses their multiplier and wager by zapping one of 11 notes on @NostrDice Game. The multiplier also determines the target the die roll needs to hit. For example, to win a 2x multiplier, the player must roll a number lower than 31784 (out of 65535 possibilities).
3. **Determining the Outcome**
The server calculates the player’s die roll based on the secret nonce, the player’s npub and the zap memo. Player’s are encouraged to use the zap memo to make it impossible for the server to anticipate their input to the die roll.
4. **Immediate Payouts**
If the player hits the target, the NostrDice server will pay out instantly.
The server zaps the player’s npub to credit them with their winnings. To this end, the player must have a valid LNURL configured if they want to get paid!
5. **House Edge**
The server retains a small house edge on every bet. For a specific
target, the payout is slightly less than the true odds to account for
this edge.
### NostrDice as a Provably Fair Game
The key to NostrDice being fair is that the outcome of a die roll is random and verifiable. For an in-depth explanation on this, check out the .md in our repository GitHub
GitHub - nostrdice/nostrdice
Contribute to nostrdice/nostrdice development by creating an account on GitHub.
GitHub
rust-nostr
Rust implementation of the nostr protocol, high level nostr client library, bindings and more! - rust-nostr
GitHub
GitHub - scsibug/nostr-rs-relay: Mirror of https://sr.ht/~gheartsfield/nostr-rs-relay/
Mirror of https://sr.ht/~gheartsfield/nostr-rs-relay/ - scsibug/nostr-rs-relay
GitHub
GitHub - nostrdice/nostrdice
Contribute to nostrdice/nostrdice development by creating an account on GitHub.
GitHub
GitHub - benthecarman/lnurl-rs: A rust implementation of LNURL
A rust implementation of LNURL. Contribute to benthecarman/lnurl-rs development by creating an account on GitHub.
GitHub
GitHub - benthecarman/nostr-wallet-connect-lnd
Contribute to benthecarman/nostr-wallet-connect-lnd development by creating an account on GitHub.