> For the complete documentation index, see [llms.txt](https://docs.relink.services/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.relink.services/architecture/installation-and-setup/evm-solidity.md).

# EVM / Solidity

### Smart Contracts

To use Relink Protocol from your EVM contract, and let users request Chainlink data, import our contract and call the public functions as shown below.

Note: to always get the most up to date information about the library, please see the README of the repo here: [**https://github.com/RelinkServices/relink-contracts-solidity-evm**](https://github.com/RelinkServices/relink-contracts-solidity-evm)

{% hint style="danger" %}
**Attention:** The following code is for showcase purposes only and is not production ready.
{% endhint %}

<pre class="language-solidity"><code class="lang-solidity">import "./ChainlinkVRFv2DirectFundingConsumerBase.sol";

<strong>contract ChainlinkVRFv2DirectFundingConsumerExample is ChainlinkVRFv2DirectFundingConsumerBase {
</strong>    using SafeERC20 for IERC20;

    // EVENTS
    event RandomnessProvided(
        bytes32 indexed requestId,
        uint256[] indexed randomWords
    );

    // ERRORS
    error RequestAlreadyExists(bytes32 requestId);
    error RequestDoesntExist(bytes32 requestId, uint256[] randomWords);

    // VARIABLES
    mapping(bytes32 => bool) public requestExists;

    constructor(
        address _proxyContractAddress,
        address[] memory permittedOracles,
        uint256 threshold
    ) ChainlinkVRFv2DirectFundingConsumerBase(_proxyContractAddress, permittedOracles, threshold) {
        // custom init code
    }

    function initiateRandomnessRequest() external payable {
        bytes32 requestId = requestRandomness(2);
        if (requestExists[requestId]) revert RequestAlreadyExists(requestId);
        requestExists[requestId] = true;
    }

    // user implemented
    function fulfillRandomWords(bytes32 _requestId, uint256[] memory _randomWords) internal override {
        if (!requestExists[_requestId])
            revert RequestDoesntExist(_requestId, _randomWords);
        emit RandomnessProvided(_requestId, _randomWords);
    }
}
</code></pre>


---

# 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.relink.services/architecture/installation-and-setup/evm-solidity.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.
