# VRF Consumer

This page guides you through an example of consuming randomness from your consumer contract. The example consumer contract on the test network is at the [GitHub repository](https://github.com/bkcoracle/vrf-consumer-contract)

As you can see in the [VRFConsumerSample](https://github.com/bkcoracle/vrf-consumer-contract/blob/main/contracts/sample/VRFConsumerSample.sol) contract, we must create a variable to store

* Subscription ID: you can get this after creating a subscription via our website
* VRF Address: you can get the address from [this page](/utilities/contract-addresses.md)
* Key Hash: you can get the key hash from [this page](/utilities/key-hash.md)

**Requirements**

* Your contract has to inherit [VRFConsumerBaseV2](https://github.com/bkcoracle/vrf-consumer-contract/blob/main/contracts/libs/VRFConsumerBaseV2.sol)&#x20;
* Your contract has to implement a function&#x20;

<pre><code><strong>function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override
</strong></code></pre>

To get randomness, you must call the function called requestRandomWords() to the VRF coordinator by sending these parameters:

* keyHash: you can get the key hash from [this page](/utilities/key-hash.md)
* subscriptionId: your subscription id
* requestConfirmations: the amount of block to confirm the transaction.
* callbackGasLimit: gas limit when VRF node calls your fulfillRandomWords function
* numWords: the amount of randomness

{% hint style="info" %}
Make sure your subscription has enough KDEV funding before requesting
{% endhint %}

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bkcoracle.com/examples/vrf-consumer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
