F

Football Bets with Chainlink

Betting on Football matches with External Adapters and Chainlink Keepers

The problem Football Bets with Chainlink solves

For More details see: https://medium.com/@harsha_90164/blockchain-betting-for-football-with-external-adapters-and-chainlink-keepers-7ec3535e1a4f

In earlier posts (Part 1 and Part 2), we introduced the concept of blockchain-based betting and its advantages. In this post, I will discuss betting on football matches using Chainlink’s External Adapters.
How is this different from betting on Chainlink’s pricefeeds that we introduced in Part 1? The data for the pricefeeds was readily available to us on-chain through Chainlink APIs. We only had to call a simple API and the latest price of any token was reliably available to us.

But for football matches there is no readymade on-chain information. Since smart contracts are inherently disconnected from the outside world, the information is available off-chain and needs to be brought on-chain. The deterministic nature of blockchain requires an oracle. You can read more about Chainlink Oracles here and here.
We also demonstrate the use of Chainlink Keepers and how they help us resolve bets.

We need a reliable way to bring football match results on-demand. For this purpose, we need three things:

  1. Source of reliable match data.

  2. External Adapter(EA) to fetch match data on-demand.

  3. Chainlink Oracle Node to call the EA and bring the match data on-chain.

  4. Chainlink Keepers — How we resolve bets

Challenges we ran into

  1. Finding a Chainlink Node:
    A job running on an Oracle will make a request to the EA and fetch the relevant data. This data is generally the match result (but it can be any other player / team / match related information) required by the smart contract to adjudicate the bet.
    Since running our own Oracle Node is a lot of work, I went scouting on the Chainlink Discord channels to find someone to host our job. The good people at LinkRiver were happy to help and easy to work with.

  2. Fetching matches and the gas fees problem:
    Smart contracts are inherently disconnected from the outside world and don’t know “when” to fetch a match’s result (or whether a particular match is completed). The user would need to request data from the EA, by expending gas fees. If the user is unaware of when the match will be completed, they might end up attempting to fetch the results multiple times.

Chainlink Keepers offers a way out of this. You register for a service and configure it to check the match results periodically. This way the user doesn’t need to periodically check for the result and it saves their gas fees. Bets are resolved as soon as the EA has the match result.

Discussion