📌Football Player Feed Contract

Introduction

The Football Player Feed Oracle is a decentralized smart contract designed to fetch real-time football player data and provide it to other smart contracts. Acting as a bridge between blockchain applications and external data sources, this oracle enables smart contracts to access and utilize football player information securely and transparently.

Technical Description

The Football Player Feed Oracle is implemented as a smart contract on a blockchain platform such as Ethereum. It listens for player data requests, fetches real-time data from an external sports API, and stores the data in a decentralized manner. This ensures accessibility, security, and immutability.

Workflow

  1. A user invokes the contract by providing a player_id.

  2. The contract makes an external API request to fetch player data.

  3. The retrieved data is stored in the contract’s storage and an event is triggered.

  4. Other smart contracts or users can monitor this event and retrieve the stored player data.

Key Features

  • Secure and tamper-proof storage of football player data.

  • Transparent and publicly accessible data.

  • Pay-per-use model for requesting player information.

  • Event-driven updates that notify subscribers when new data is available.

Usage

To interact with the Football Player Feed Oracle, follow these steps:

1. Deploy the Contract

Deploy the contract to the blockchain using the following Oracle Contract address:

0x020734aDA5b04bE7Aa81D3C4197bF6E02d7B81Cf

2. Request Football Player Data

Call the function:

requestPlayerData(player_id)
  • player_id: The ID of the football player whose data is being requested.

  • This is a payable function, meaning the user must pay a certain amount of Ether to access the player data.

  • On successful execution, the function returns a success message.

3. Retrieve Football Player Data

Once the data is available, call:

retrieveData(player_id)
  • player_id: The request ID received from the previous function.

  • This function retrieves the latest player data, including player name, nationality, and field position.

Smart Contract Implementation

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

interface Oracle {
    function getPlayerDetails(uint player_id) external view returns(string memory, string memory, uint);
    function requestPlayer(uint player_id) external payable returns(string memory);
}

contract PlayerFeedContract {
    address public oracleAddress;

    constructor(address _oracleAddress) {
        oracleAddress = _oracleAddress;
    }

    function requestPlayerData(uint256 _player_id) public payable returns (string memory) {
        return Oracle(oracleAddress).requestPlayer{value: msg.value}(_player_id);
    }

    function retrieveData(uint _player_id) public view returns(string memory, string memory, uint) {
        return Oracle(oracleAddress).getPlayerDetails(_player_id);
    }
}

Contract Functions

1. Constructor

constructor(address _oracleAddress)
  • Initializes the contract with the address of the Oracle smart contract.

2. Request Football Player Data

function requestPlayerData(uint256 _player_id) public payable returns (string memory)
  • Allows users to request data on a specific football player.

  • Requires a payable transaction where users must send Ether to access the data.

  • Takes in _player_id (player identifier) as a parameter.

  • Calls the requestPlayer function on the Oracle contract to fetch the data.

  • Returns a success message if the request is processed correctly.

3. Retrieve Football Player Data

function retrieveData(uint _player_id) public view returns (string memory, string memory, uint)
  • Fetches stored player data for a given player ID.

  • Calls getPlayerDetails function on the Oracle contract.

  • Returns:

    • player_name: The player's name.

    • club: The player's club.

    • age: The player's age.

Last updated