> For the complete documentation index, see [llms.txt](https://docs.bkcoracle.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bkcoracle.com/examples/vrf-consumer.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
