📂 dApp Developers

# dataFeedIdToReaderToWhitelistStatus()

Table of Contents

For on-chain smart contracts, the function dataFeedIdToReaderToWhitelistStatus() (opens new window) returns read access information with the expirationTimestamp and indefiniteWhitelistCount of a reader for the specified dAPI data feed.

The reader will not be able to read the dAPI data feed past the expirationTimestamp (assuming their indefiniteWhitelistCount is 0 ). If the indefiniteWhitelistCount is greater than 0 , the reader will be able to read the data feed indefinitely (regardless of the value of expirationTimestamp).

# Example Code

// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@api3/airnode-protocol-v1/contracts/dapis/interfaces/IDapiServer.sol";
contract mySmartContract {
  function myReadable(
    address _dapiServerContractAddress,
    bytes32 _datafeedId
  ) external {
    uint64 expirationTimestamp;
    uint192 indefiniteWhitelistCount;
    // Calling the DapiServer for reader status
    // where "this" is the contract address of this contract (myReadable).
    (expirationTimestamp, indefiniteWhitelistCount) =
      IDapiServer(_dapiServerContractAddress).dataFeedIdToReaderToWhitelistStatus(_datafeedId, address(this));
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

dAPI name

If you want to check the status for a dAPI name, you first need to calculate the hash off-chain of name as shown below. Then pass the value of dapiNameHash as _datafeedId in the example above.

dapiNameHash = ethers.utils.solidityKeccak256(['string'], [dapiName]);
1

# Parameters

readerCanReadDataFeed(bytes32 datafeedId, address reader)

  • bytes32 datafeedId - The ID of a dAPI, Beacon, or Beacon set.
  • address reader - The address to verify such as the reader's smart contract address or another address.

# Returns

  • expirationTimestamp - Timestamp at which the whitelisting of the reader will expire.

  • indefiniteWhitelistCount - Number of times reader was whitelisted indefinitely for dataFeedId.

Last Updated: 7/25/2022, 1:11:53 PM