3

Newbie here, making my first steps in the smart contracts/dapps world; let's assume a simple scenario, 2 people making a wager on a game outcome. They agree on the amount waged, and who ever wins is automatically credited with the waged amount. How would one go and "lock" in place the waged amount from the 2 wallets? Or what other means of reserving that amount can be employed in a smart contract? I'm particularly interested in the core logic, not necessarily the code for it.

Thank you.

1

The contract would act as an escrow. Both parties would send their funds to the contract. No function would exist for either party to simply withdraw their funds anytime they want.

Instead, functions would exist to allow them to withdraw funds in the case that they won (separate concern) the bet/game and possibly if the game expires so funds wouldn't become marooned there in edge cases e.g. the other player never showed up.

Hope it helps.

0

Well it is true that the idea of an automatic judge who will hold the money and then give the winner both sums is actually vague and seems not possible.

I had that idea at first, but the thing i missed is that the contract and its semantics are the real judge. The contract has his own wallet and when bidding, both parties would send their money to the contract ( this does actually require trust between the players sending their money and the contract and happens by invoking functions from the contract). after the winner is decided the contract would send back both sums to the winner.

To be able to perfectly play this kind of games, the contract would allow( via coded methods) the players to gain back their money in case of any kind of error, players not showing up, etc. but they don't have to.

It might still feel hard to grasp but the minute you run your first contract, it would become much more clear.

0

A contract could be implemented with something like the following flow, utilising a deposit to ensure co-operation:

  1. Both players "wager" their bet in the contract along with some deposit amount (I am unsure of the exact ratio of wager/deposit that will ensure honest co-operation).
  2. The bet takes place and both players must submit the same honest answer to receive their deposit back along with their potential winnings (decided using the submitted result, if they match).

You could even create a contract which permanently locks all funds if either party submits a dishonest result if it helps ensure co-operation!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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