I would like to create a simple smart contract between me and a couple of friends (basically, I'm putting money on the line and betting them that I will do something that they don't think I'll do.)

We want to write a simple (arbitration bound) smart contract that will allow us to put ether (or whatever, not bound to ether if someone knows a better platform) into 'escrow' so that we can bet on the outcome and then deliver the funds (we've had problems with people not paying afterwards because they 'weren't serious' about the bet, this would make them be serious).

Any recommendations for apps/dapps/platforms/annoyingly complicated solidity scripts that could do this for me?

closed as too broad by Briomkez, Rosco Kalis, Achala Dissanayake, shane, Ismael Jan 20 at 21:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I assume by "arbitration bound" you mean there's a trusted third party who will decide the outcome of the bet. If so, why don't you just give that person the money and let them give it to the bet winner later? – smarx Jan 19 at 6:56
  • By arbitration bound I mean that we will argue about the meaning of words until someone gets angry. And no, then we couldn't overcomplicate it. – Connor McCormick Jan 19 at 7:18
  • I want an excuse to play with ethereum smart contracts. Why the downvote? – Connor McCormick Jan 19 at 7:19
  • @ConnorMcCormick is asking for an example of a simple betting contract which I think is a totally reasonable request. I do not understand the downvotes. – Thorkil Værge Jan 19 at 13:18

The simplest useful example that I could come up with is something along these lines. This is a contract where the participants can deposit ether to the contract and the admin can settle the bet and determine who has won. Initially the contract creator is admin but this can be changed prior to any funds being deposited. This contract only allows for one winner. If the admin is another contract, complete trust in one single person is not necessary.

I have not tested the below code, so you should only consider it inspiration. You want to test it before you deposit real money into this.

pragma solidity ^0.5.2;

contract Exchange {
  address public admin;

  modifier onlyAdmin {
    require(msg.sender == admin);

  function Exchange() {
    admin = msg.sender;

  function changeAdmin(address _newAdmin) onlyAdmin {
    require(_newAdmin != address(0));
    admin = _newAdmin();

  function deposit() payable {

  function settle(address _winner) onlyAdmin {

The constructor Exchange() sets the class variable admin of type address to the address that publishes this contract onto the blockchain. The admin can give this role to a person or an Ethereum smart contract through the method changeAdmin.

The participants can then deposit funds into the contract by calling deposit when they trust the admin and the admin can settle the bet by calling settle. The settle method sends the balance of this contract to the argument with which the method is called as is described here. Only the creator of the contract can call the settle method. The settle method also deletes this contract from the blockchain and refunds some of the gas that the admin incurred when calling settle.

You can build a lot more logic into the betting contract, if you like. You could for example ensure that the admin can only pay the funds out to the participants and not to himself (which is possible in the above contract). It is questionable how much sense this contract makes as long as you have not done this. And you can opt to make the bet in ERC20 tokens instead of, as above, in Ether.

  • 1
    This is a very good starting point, in my opinion. I would avoid selfdestruct in favor of Pausable and use a standard Ownable with transferrable ownership (admin). When the "admin" is itself another contract, then the betting and the arbitration can be approached as separate concerns. – Rob Hitchens B9lab Jan 19 at 16:21
  • That's a good idea. I will change my proposal accordingly. – Thorkil Værge Jan 19 at 16:54
  • I made the admin role transferable. Did you want to make the contract pausable so it could be used for other bets in the future? – Thorkil Værge Jan 19 at 17:02
  • It's good to keep things brief here, imo, so the answer stays on point. selfdestruct creates dangerous voids on the blockchain so I wouldn't use it in production. – Rob Hitchens B9lab Jan 19 at 17:05
  • contract Betting is Pausable would take care of multiple concerns. The contract would be stopped instead of destroyed. – Rob Hitchens B9lab Jan 19 at 17:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.