0

I'm new to this entire space, so please bear with me.

I'm trying to create a betting app. I want people to sign the contract and say they'll put up some money that they'll either win or lose depending on the outcome of some event.

Lets say I want them to put up money by 8 AM, then all funds are locked in for that betting pool.

Then the event might have an outcome from any time between 8 AM and say 3 PM, but I want the bet to be settled whenever the outcome is decided within that window. Ex: if it ends at 11, settle at 11. If it ends at 2, settle at 2.

The only way I can retrieve the outcome of the event is by doing an API call. The API will look at this specific event, and it returns "undecided" if the event is ongoing but not over. Only once the event is over will it return either "success" or "fail".

Would I have to just periodically check this with an oracle to settle this bet? That seems like a waste of money since there's fees on these oracle calls. Ideally I'd want to have some intermediary script calling the API on my app's end without any blockchain involved, then once it notices that the event has been decided, it can try to settle the bet between the two parties and use an oracle to verify the result (that would be just one API call).

Intuitively my idea on how to do this is to just use myself (the application) as the intermediary in these bets. Put my app's "intermediary" address in the pool along with all other people who actually want to bet. Have some external function/file somewhere else constantly checking the API for the outcome of the event to be either success or fail, and once it has been decided, tell my app's intermediary address to call the settle() function for the bet - paying the oracle fee and paying out the right people based on the result of the API call.

To do this, I'd need to call a .sol function or contract function from an external file - is this possible?

I'll take any ideas, thank you for the help.

0

One way you could do this is by having a process in a backend managing the outcome of the events (that you receive through APIs). Whenever a result for a bet is available, the process would call the smart contract to settle the bet and transfer the reward to the winner/s.

This smart contract function for settlements is certainly restricted to an admin address (e.g: contract deployer) that you will be using from the backend to call the smart contract.

In summary, the contract will only have the logic to close a bet, decide winners and assign rewards, but the process to manage the results and inform the contract will be done offchain (your backend is essentially the Oracle for your contract).

0
  1. Have nodes off-chain checking that API for when the event happens
  2. Allow them to publish only when there is an update.
  3. That way, you only have to pay once, when they report the data.

You could do a custom setup on a network of chainlink nodes to do this.

This could be done pretty easy in a centralized way with 1 chainlink node. The v2 version would be to use Chainlink OCR to get the data in a decentralized manner.

Disclaimer, I am a Chainlink developer advocate

0

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.