# OoO ConsumerBase smart contract
This contract can be imported by any smart contract wishing to include off-chain data or data from a different network within it.
The consumer initiates a data request by forwarding the request to the Router smart contract, from where the data provider(s) pick up and process the data request, and forward it back to the specified callback function.
# Functions:
constructor(address _router, address _xfund) internal
_setRouter(address _router) internal
_increaseRouterAllowance(uint256 _amount) internal
_requestData(address _dataProvider, uint256 _fee, bytes32 _data) internal
rawReceiveData(uint256 _price, bytes32 _requestId) external
receiveData(uint256 _price, bytes32 _requestId) internal
getRouterAddress() external
# Function constructor(address _router, address _xfund) internal
Contract constructor. Accepts the address for the router smart contract, and a token allowance for the Router to spend on the consumer's behalf (to pay fees).
The Consumer contract should have enough tokens allocated to it to pay fees and the Router should be able to use the Tokens to forward fees.
# Parameters:
_router
: address of the deployed Router smart contract
# Function _setRouter(address _router) internal -> bool
No description
# Parameters:
# Function _increaseRouterAllowance(uint256 _amount) internal -> bool
No description
# Parameters:
# Function _requestData(address _dataProvider, uint256 _fee, bytes32 _data) internal -> bytes32
_requestData - initialises a data request. forwards the request to the deployed Router smart contract.
# Parameters:
_dataProvider
: payable address of the data provider_fee
: uint256 fee to be paid_data
: bytes32 value of data being requested, e.g. PRICE.BTC.USD.AVG requests average price for BTC/USD pair
# Return Values:
# Function rawReceiveData(uint256 _price, bytes32 _requestId) external
rawReceiveData - Called by the Router's fulfillRequest function in order to fulfil a data request. Data providers call the Router's fulfillRequest function The request is validated to ensure it has indeed been sent via the Router.
The Router will only call rawReceiveData once it has validated the origin of the data fulfillment. rawReceiveData then calls the user defined receiveData function to finalise the fulfilment. Contract developers will need to override the abstract receiveData function defined below.
# Parameters:
_price
: uint256 result being sent_requestId
: bytes32 request ID of the request being fulfilled has sent the data
# Function receiveData(uint256 _price, bytes32 _requestId) internal
receiveData - should be overridden by contract developers to process the data fulfilment in their own contract.
# Parameters:
# Function getRouterAddress() external -> address
getRouterAddress returns the address of the Router smart contract being used