Autopay is a system for creating and funding data feeds for use with Fetch.
Run setUpFeed
then fundFeed
/**
* @param _queryId unique identifier of desired data feed
* @param _reward tip amount per eligible data submission
* @param _startTime timestamp of first autopay window
* @param _interval amount of time between autopay windows
* @param _window amount of time after each new interval when reports are eligible for tips
* @param _priceThreshold amount price must change to automate update regardless of time (negated if 0, 100 = 1%)
* @param _queryData the data used by reporters to fulfill the query
function setupDataFeed(
bytes32 _queryId,
uint256 _reward,
uint256 _startTime,
uint256 _interval,
uint256 _window,
uint256 _priceThreshold,
bytes calldata _queryData
)
.......
/**
* @param _feedId unique feed identifier
* @param _queryId identifier of reported data type associated with feed
* @param _amount quantity of tokens to fund feed
*/
function fundFeed(
bytes32 _feedId,
bytes32 _queryId,
uint256 _amount
)
To tip a queryId, giving the tip to the next reporter to sumbit for that ID, run:
/**
* @param _queryId ID of tipped data
* @param _amount amount to tip
* @param _queryData the data used by reporters to fulfill the query
*/
function tip(
bytes32 _queryId,
uint256 _amount,
bytes calldata _queryData
) external {
To receive fees from a recurring feed:
/**
* @param _reporter address of Fetch reporter
* @param _feedId unique feed identifier
* @param _queryId ID of reported data
* @param _timestamps[] batch of timestamps array of reported data eligible for reward
*/
function claimTip(
address _reporter,
bytes32 _feedId,
bytes32 _queryId,
uint256[] memory _timestamps
)
To receive fees from a one time tip:
/**
* @param _queryId ID of reported data
* @param _timestamps[] batch of timestamps array of reported data eligible for reward
*/
function claimOneTimeTip(
bytes32 _queryId,
uint256[] calldata _timestamps
)
Install Dependencies
npm i
Install local dependencies. This project depends on usingFetch project. To install it, clone the repository in the same folder level than autoPay project.
git clone [email protected]:fetchoracle/usingfetch.git
Compile Smart Contracts
npx hardhat compile
Test Locally
npx hardhat test
This repository is maintained by the Fetch team
Check out our issues log here on Github or feel free to reach out anytime [email protected]
Set the env variable in the .env file. Rename .env.example to .env and set the private key of the deployer, RPC url, chain Id and the network (pulse_testnet or pulse_mainnet). The example below show the values for Pulsechain testnet.
PRIVATE_KEY=
NETWORK=pulse_testnet
NODE_URL_PULSECHAIN_TESTNET=https://rpc.v4.testnet.pulsechain.com
CHAIN_ID_PULSECHAIN_TESTNET=943
Please notice that for deploying AutoPay contract the Fetch Flex oracle address is needed. It need to be configured inside scripts/deploy.js file in this variables:
var fetchAddress = ''
For deploying autopay to Pulsechain testnet run the script below:
npx hardhat run scripts/deploy.js
The current version of the autopay contract is deployed in PulseChain testnet in this address:
0xa2B568c4C101522DB20C4B2BAa2E6eD55b9Df6DF
Fetch Inc. 2024