File size: 5,099 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface VRFCoordinatorV2Interface {
  /**

   * @notice Get configuration relevant for making requests

   * @return minimumRequestConfirmations global min for request confirmations

   * @return maxGasLimit global max for request gas limit

   * @return s_provingKeyHashes list of registered key hashes

   */
  function getRequestConfig()

    external

    view

    returns (

      uint16,

      uint32,

      bytes32[] memory

    );

  /**

   * @notice Request a set of random words.

   * @param keyHash - Corresponds to a particular oracle job which uses

   * that key for generating the VRF proof. Different keyHash's have different gas price

   * ceilings, so you can select a specific one to bound your maximum per request cost.

   * @param subId  - The ID of the VRF subscription. Must be funded

   * with the minimum subscription balance required for the selected keyHash.

   * @param minimumRequestConfirmations - How many blocks you'd like the

   * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS

   * for why you may want to request more. The acceptable range is

   * [minimumRequestBlockConfirmations, 200].

   * @param callbackGasLimit - How much gas you'd like to receive in your

   * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords

   * may be slightly less than this amount because of gas used calling the function

   * (argument decoding etc.), so you may need to request slightly more than you expect

   * to have inside fulfillRandomWords. The acceptable range is

   * [0, maxGasLimit]

   * @param numWords - The number of uint256 random values you'd like to receive

   * in your fulfillRandomWords callback. Note these numbers are expanded in a

   * secure way by the VRFCoordinator from a single random value supplied by the oracle.

   * @return requestId - A unique identifier of the request. Can be used to match

   * a request to a response in fulfillRandomWords.

   */
  function requestRandomWords(

    bytes32 keyHash,

    uint64 subId,

    uint16 minimumRequestConfirmations,

    uint32 callbackGasLimit,

    uint32 numWords

  ) external returns (uint256 requestId);

  /**

   * @notice Create a VRF subscription.

   * @return subId - A unique subscription id.

   * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer.

   * @dev Note to fund the subscription, use transferAndCall. For example

   * @dev  LINKTOKEN.transferAndCall(

   * @dev    address(COORDINATOR),

   * @dev    amount,

   * @dev    abi.encode(subId));

   */
  function createSubscription() external returns (uint64 subId);

  /**

   * @notice Get a VRF subscription.

   * @param subId - ID of the subscription

   * @return balance - LINK balance of the subscription in juels.

   * @return reqCount - number of requests for this subscription, determines fee tier.

   * @return owner - owner of the subscription.

   * @return consumers - list of consumer address which are able to use this subscription.

   */
  function getSubscription(uint64 subId)

    external

    view

    returns (

      uint96 balance,

      uint64 reqCount,

      address owner,

      address[] memory consumers

    );

  /**

   * @notice Request subscription owner transfer.

   * @param subId - ID of the subscription

   * @param newOwner - proposed new owner of the subscription

   */
  function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;

  /**

   * @notice Request subscription owner transfer.

   * @param subId - ID of the subscription

   * @dev will revert if original owner of subId has

   * not requested that msg.sender become the new owner.

   */
  function acceptSubscriptionOwnerTransfer(uint64 subId) external;

  /**

   * @notice Add a consumer to a VRF subscription.

   * @param subId - ID of the subscription

   * @param consumer - New consumer which can use the subscription

   */
  function addConsumer(uint64 subId, address consumer) external;

  /**

   * @notice Remove a consumer from a VRF subscription.

   * @param subId - ID of the subscription

   * @param consumer - Consumer to remove from the subscription

   */
  function removeConsumer(uint64 subId, address consumer) external;

  /**

   * @notice Cancel a subscription

   * @param subId - ID of the subscription

   * @param to - Where to send the remaining LINK to

   */
  function cancelSubscription(uint64 subId, address to) external;

  /*

   * @notice Check to see if there exists a request commitment consumers

   * for all consumers and keyhashes for a given sub.

   * @param subId - ID of the subscription

   * @return true if there exists at least one unfulfilled request for the subscription, false

   * otherwise.

   */
  function pendingRequestExists(uint64 subId) external view returns (bool);
}