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 {
selfdestruct(_winner);
}
}
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.