<blockquote>
  <p>How do current betting sites handle the deposits/withdrawals of bitcoins, and how do they keep a comission out of it?</p>
</blockquote>

<p>Just like any other payment: you track the blockchain and keep balances in your server database.</p>

<ul>
<li>You can charge the commission on deposit (e.g. 0.5% fee, when depositing 10BTC just credit 9.95BTC)</li>
<li>You can charge per game (e.g. when each player bets 5BTC in a 2 player game = 10BTC, only pay the winner 4.95 from their rival) and keep 0.05 (0.5%).</li>
<li>In betting games you can also schew the long-term statistics against you so the house has an edge (just like casino roulettes have 0, and some even 00).</li>
</ul>

<blockquote>
  <p>Any small site could rely on trust and do this in a manual fashion, but I'd assume any professional site does not handle this manually. So, is there an existing library (I'll use Node.js, in case it matters) or third-party service for this? And should the bitcoins be stored in a conventional offline wallet(s)?</p>
</blockquote>

<p>This would work just like any other business, just browse this site. You can rely on external businesses to do this for you, or create the system yourself (leveraging libraries or not, you must listen to the blockchain events and act accordingly).</p>

<blockquote>
  <p>And last, is there a way to "prove" that the games are fair in order to establish trust?</p>
</blockquote>

<p>If games are deterministic (like chess) the issue boils down to trust between users (<em>is this guy going to cheat me using a chess engine?</em>) since you couldn't influence the outcome anyways.</p>

<p>If games are based on chance, either the users must have faith in you or you have to provide a way for the user to verify you're not cheating him. How such a scheme could be implemented depends on the detailed mechanics of the game (you could even leverage Bitcoin's blockchain for this).</p>

<blockquote>
  <p>Are there any legal requirements regarding to this?</p>
</blockquote>

<p>Dealing with the legal system is the hard part here. Just like any other legal matter... it depends on your jurisdiction! In my country you have to be audited before running a betting business.</p>

CC BY-SA 3.0
2014-01-13T05:58:15.950Z
Thank you very much for this thorough answer! Would tracking the blockchain and keeping the balances in the server database **manually** be too primitive? Considering I do not expect the site to become huge. The only downside to this I see is that there would be a delay between a deposit or a withdraw to be reflected as I would have to verify the transaction myself.
Robert
CC BY-SA 3.0
2014-01-13T11:19:25.640Z
@Robert there's nothing inherently wrong with that approach. The problem is there are hundreds of edge cases dealing with the blockchain (e.g. chain reorganizations) and a huge cost to run the payment infrastructure.
kaoD
CC BY-SA 3.0
2014-01-13T13:03:40.177Z
The way I've seen a lot of crypto-coin roulettes work is: they pre-generate the next pseudo-random selection of roulette, hash it, add a salt, then publish it BEFORE your bet. Once you place your bet and push the "Go" button, the pseudo-random number and the salt are revealed, so you can validate it against the published result. It'd be feasible, though computationally VERY expensive, for the virtual croupier to select a diff. number (to make you lose) then find a salt so that the published hash is the same, that's what creates a bit of trust.
Joe Pineda
CC BY-SA 3.0
2014-01-13T13:03:56.867Z
An example:
http://dogespin.l8.lv/?r=dogecoin_roulette#provablyfair
Joe Pineda
CC BY-SA 3.0
2014-01-12T21:10:17.580Z
2014-01-12T21:16:39.333Z
2014-01-12T21:16:39.333Z
kaoD
<p>Let's say I wanted to host a site in which</p>

<ul>
<li>users create their own accounts</li>
<li>they deposit bitcoins in said accounts</li>
<li>a commission of, say, 0.05% is kept of all the bitcoins that are deposited in the site</li>
<li>users play a competitive game with each other (e.g. chess, or others for more players) for a bet</li>
<li>the winner gets the full bet</li>
<li>each user can withdraw their bitcoins any time they want</li>
</ul>

<p>This, I figure, would be quite hard to get right due to all of the different aspects involved, such as user trust, security and technicalities.</p>

<p>My questions are:</p>

<ul>
<li><p>How do current betting sites handle the deposits/withdrawals of bitcoins, and how do they keep a commission out of it?</p></li>
<li><p>Any small site <em>could</em> rely on trust and do this in a manual fashion, but I'd assume any professional site does not handle this manually. So, is there an existing library (I'll use Node.js, in case it matters) or third-party service for this? And should the bitcoins be stored in a conventional offline wallet(s)?</p></li>
<li><p>And last, is there a way to "prove" that the games are fair in order to establish trust? Are there any legal requirements regarding to this?</p></li>
</ul>

CC BY-SA 3.0
2014-01-12T21:07:46.310Z
Obtaining the legal permits for operating a gambling site sounds more expensive than actually developing such a site.
CodesInChaos
CC BY-SA 3.0
2014-01-12T21:10:11.210Z
The whole idea is weird too. Sounds like an exercise in sandbagging. The stronger player will win on average, so games will only happen if one of the players is misinformed about the other player's strength. For many games cheating is possible (e.g. for chess, computers are much stronger than humans) which causes further difficulties.
CodesInChaos
CC BY-SA 3.0
2014-01-12T21:12:46.633Z
@CodesInChaos just like in betting games: twice the strength, double (or square) the payout. Think of it as probabilities. You could risk playing stronger players (say they could win you 75% of games) just to be paid more.
kaoD
CC BY-SA 3.0
2014-01-12T21:21:28.210Z
@kaoD That doesn't change the main issue: Players who don't try to misrepresent their strength will pay to players who do. It's a competition of who cheats hardest, not who plays best.
CodesInChaos
CC BY-SA 3.0
2014-01-12T21:31:24.870Z
@CodesInChaos what do you mean? To misrepresent your strength you have to lose games, i.e. pay. If it can be balanced out (which you might be suggesting it can't?) the optimal strategy is to play players near your level and play legitimately.
kaoD
CC BY-SA 3.0
2014-01-12T23:10:42.673Z
@CodesInChaos Regarding obtaining legal permits for operating a gambling site, as far as I know you don't need any permits. Bitcoin is not a FIAT money, there are no gambling regulations on it what so ever, thus no gambling license is required (assuming the site doesn't accept FIAT money).
User2344452
CC BY-SA 3.0
2014-01-13T02:05:13.503Z
@BabyPuncher I don't think it's that easy. In my country there are gambling regulations regardless of the medium of exchange. As long as it has value, it's taxable. A country might even forbid gambling in non-fiat to avoid tax evasion.
kaoD
CC BY-SA 3.0
2014-01-13T05:51:45.707Z
I guess it could work as long as users are forced to go thru a series of matches vs. computer to assess their strength, you use a kind of handicap, either monetary (so a pro vs. a noobie has the noobie risking more) or as is done in shogi (Japanese chess) where the stronger player has some of their pieces removed. Of course, strength assessment should be updated after each game (a la Yahoo Games) and the initial assessment process must be long and tedious enough to disuade creating sock puppets for easy wins.
Joe Pineda
CC BY-SA 3.0
2014-01-13T06:12:49.733Z
I only used chess as an example. But yes, it's not a trivial task to assess the players' ability to make it fair play. The whole point of making it a competitive game is to disassociate the site from making payments (and thus, risk) and only take a comission. @JoePineda that's a good idea. Matching players with a similar percentage of "won" games could be an alternative (faking that would imply having risked money and so, it'd naturally disuade malicious users to do it).
Robert
CC BY-SA 3.0
2014-01-13T06:18:05.957Z
Aditionally, the "mechanics" of the game would have to be NP-hard (such as Tetris') so that there is no shortcut or smart algorithm that will solve them swiftly. Making it impossible to cheat.
Robert
CC BY-SA 3.0
2014-01-13T12:54:18.390Z
The other idea just struck me is hosting a site to play a virtual version of a trading card game, like Yugi-oh or Magic-the-Gathering. Either you get a license for those or you design your own cards, with a game-play similar to those. You could then let the players play for free, charging a small fee for users exchanging cards or sell them directly some new ones your designers have created. In these games there's a lot of random (easier for newbies), and if you're willing to pay enough you can get powerful cards.
Joe Pineda
<security><api><payment><websites><gambling>
What's needed to host a competitive game site
Robert
# What's needed to host a competitive game site

(Asked by: username_0 on 2014-01-12)

Let's say I wanted to host a site in which

* users create their own accounts
* they deposit bitcoins in said accounts
* a commission of, say, 0.05% is kept of all the bitcoins that are deposited in the site
* users play a competitive game with each other (e.g. chess, or others for more players) for a bet
* the winner gets the full bet
* each user can withdraw their bitcoins any time they want

This, I figure, would be quite hard to get right due to all of the different aspects involved, such as user trust, security and technicalities.

My questions are:

* How do current betting sites handle the deposits/withdrawals of bitcoins, and how do they keep a commission out of it?
* Any small site *could* rely on trust and do this in a manual fashion, but I'd assume any professional site does not handle this manually. So, is there an existing library (I'll use Node.js, in case it matters) or third-party service for this? And should the bitcoins be stored in a conventional offline wallet(s)?
* And last, is there a way to "prove" that the games are fair in order to establish trust? Are there any legal requirements regarding to this?

**Tags:** security, api, payment, websites, gambling

> **Comments:**
> **username_1**: Obtaining the legal permits for operating a gambling site sounds more expensive than actually developing such a site.  
> **username_1**: The whole idea is weird too. Sounds like an exercise in sandbagging. The stronger player will win on average, so games will only happen if one of the players is misinformed about the other player's strength. For many games cheating is possible (e.g. for chess, computers are much stronger than humans) which causes further difficulties.  
> **username_2**: @username_1 just like in betting games: twice the strength, double (or square) the payout. Think of it as probabilities. You could risk playing stronger players (say they could win you 75% of games) just to be paid more.  
> **username_1**: @username_2 That doesn't change the main issue: Players who don't try to misrepresent their strength will pay to players who do. It's a competition of who cheats hardest, not who plays best.  
> **username_2**: @username_1 what do you mean? To misrepresent your strength you have to lose games, i.e. pay. If it can be balanced out (which you might be suggesting it can't?) the optimal strategy is to play players near your level and play legitimately.  
> **username_3**: @username_1 Regarding obtaining legal permits for operating a gambling site, as far as I know you don't need any permits. Bitcoin is not a FIAT money, there are no gambling regulations on it what so ever, thus no gambling license is required (assuming the site doesn't accept FIAT money).  
> **username_2**: @BabyPuncher I don't think it's that easy. In my country there are gambling regulations regardless of the medium of exchange. As long as it has value, it's taxable. A country might even forbid gambling in non-fiat to avoid tax evasion.  
> **username_4**: I guess it could work as long as users are forced to go thru a series of matches vs. computer to assess their strength, you use a kind of handicap, either monetary (so a pro vs. a noobie has the noobie risking more) or as is done in shogi (Japanese chess) where the stronger player has some of their pieces removed. Of course, strength assessment should be updated after each game (a la Yahoo Games) and the initial assessment process must be long and tedious enough to disuade creating sock puppets for easy wins.  
> **username_0**: I only used chess as an example. But yes, it's not a trivial task to assess the players' ability to make it fair play. The whole point of making it a competitive game is to disassociate the site from making payments (and thus, risk) and only take a comission. @username_4 that's a good idea. Matching players with a similar percentage of "won" games could be an alternative (faking that would imply having risked money and so, it'd naturally disuade malicious users to do it).  
> **username_0**: Aditionally, the "mechanics" of the game would have to be NP-hard (such as Tetris') so that there is no shortcut or smart algorithm that will solve them swiftly. Making it impossible to cheat.  
> **username_4**: The other idea just struck me is hosting a site to play a virtual version of a trading card game, like Yugi-oh or Magic-the-Gathering. Either you get a license for those or you design your own cards, with a game-play similar to those. You could then let the players play for free, charging a small fee for users exchanging cards or sell them directly some new ones your designers have created. In these games there's a lot of random (easier for newbies), and if you're willing to pay enough you can get powerful cards.  

---

## 1 answers

### Answer by username_2 on 2014-01-12. Score: 0 | Accepted answer

> How do current betting sites handle the deposits/withdrawals of bitcoins, and how do they keep a comission out of it?

Just like any other payment: you track the blockchain and keep balances in your server database.

* You can charge the commission on deposit (e.g. 0.5% fee, when depositing 10BTC just credit 9.95BTC)
* You can charge per game (e.g. when each player bets 5BTC in a 2 player game = 10BTC, only pay the winner 4.95 from their rival) and keep 0.05 (0.5%).
* In betting games you can also schew the long-term statistics against you so the house has an edge (just like casino roulettes have 0, and some even 00).

> Any small site could rely on trust and do this in a manual fashion, but I'd assume any professional site does not handle this manually. So, is there an existing library (I'll use Node.js, in case it matters) or third-party service for this? And should the bitcoins be stored in a conventional offline wallet(s)?

This would work just like any other business, just browse this site. You can rely on external businesses to do this for you, or create the system yourself (leveraging libraries or not, you must listen to the blockchain events and act accordingly).

> And last, is there a way to "prove" that the games are fair in order to establish trust?

If games are deterministic (like chess) the issue boils down to trust between users (*is this guy going to cheat me using a chess engine?*) since you couldn't influence the outcome anyways.

If games are based on chance, either the users must have faith in you or you have to provide a way for the user to verify you're not cheating him. How such a scheme could be implemented depends on the detailed mechanics of the game (you could even leverage Bitcoin's blockchain for this).

> Are there any legal requirements regarding to this?

Dealing with the legal system is the hard part here. Just like any other legal matter... it depends on your jurisdiction! In my country you have to be audited before running a betting business.

> **Comments:**
> **username_0**: Thank you very much for this thorough answer! Would tracking the blockchain and keeping the balances in the server database **manually** be too primitive? Considering I do not expect the site to become huge. The only downside to this I see is that there would be a delay between a deposit or a withdraw to be reflected as I would have to verify the transaction myself.  
> **username_2**: @username_0 there's nothing inherently wrong with that approach. The problem is there are hundreds of edge cases dealing with the blockchain (e.g. chain reorganizations) and a huge cost to run the payment infrastructure.  
> **username_4**: The way I've seen a lot of crypto-coin roulettes work is: they pre-generate the next pseudo-random selection of roulette, hash it, add a salt, then publish it BEFORE your bet. Once you place your bet and push the "Go" button, the pseudo-random number and the salt are revealed, so you can validate it against the published result. It'd be feasible, though computationally VERY expensive, for the virtual croupier to select a diff. number (to make you lose) then find a salt so that the published hash is the same, that's what creates a bit of trust.  
> **username_4**: An example: http://dogespin.l8.lv/?r=dogecoin_roulette#provablyfair  

---

