Skip to content

Commit

Permalink
Adds more VRF versioning signposts (#1947)
Browse files Browse the repository at this point in the history
* More versioning signposts

* fix imports?

* Update import

* Update package lock

---------

Co-authored-by: Dwight Lyle <dwightjl@gmail.com>
  • Loading branch information
thedriftofwords and dwightjl committed May 17, 2024
1 parent fd0b4f5 commit 0a447a9
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 96 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/content/vrf/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ metadata:
description: "Learn how to securely generate random numbers for your smart contract with Chainlink VRF (an RNG). This guide uses Solidity code examples."
---

import VrfCommon from "@features/vrf/v2-5/VrfCommon.astro"
import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import { Aside } from "@components"

<VrfCommon callout="security" />
<Vrf2_5Common callout="security" />

**Chainlink VRF (Verifiable Random Function)** is a provably fair and verifiable random number generator (RNG) that enables smart contracts to access random values without compromising security or usability. For each request, Chainlink VRF generates one or more random values and cryptographic proof of how those values were determined. The proof is published and verified onchain before any consuming applications can use it. This process ensures that results cannot be tampered with or manipulated by any single entity including oracle operators, miners, users, or smart contract developers.

Expand Down
4 changes: 2 additions & 2 deletions src/content/vrf/v2-5/best-practices.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ metadata:
description: "Best practices for using Chainlink VRF."
---

import VrfCommon from "@features/vrf/v2-5/VrfCommon.astro"
import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import { CodeSample } from "@components"

<VrfCommon callout="security" />
<Vrf2_5Common callout="security" />

These are example best practices for using Chainlink VRF. To explore more applications of VRF, refer to our [blog](https://blog.chain.link/).

Expand Down
18 changes: 7 additions & 11 deletions src/content/vrf/v2-5/migration-from-v2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ date: Last Modified
title: "Migrating from VRF v2"
---

import VrfCommon from "@features/vrf/v2-5/VrfCommon.astro"
import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import { Aside, CodeSample } from "@components"
import { Tabs, TabsContent } from "@components/Tabs"

<VrfCommon callout="security" />
<Vrf2_5Common callout="security" />

## Benefits of VRF v2.5

Expand Down Expand Up @@ -245,7 +245,6 @@ Compare the major changes between V2.5 and V2:
pragma solidity 0.8.19;

///// UPDATE IMPORTS TO V2.5 /////
import {IVRFCoordinatorV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol";
import {VRFConsumerBaseV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol";
import {VRFV2PlusClient} from "@chainlink/contracts/src/v0.8/vrf/dev/libraries/VRFV2PlusClient.sol";

Expand All @@ -261,9 +260,8 @@ import {VRFV2PlusClient} from "@chainlink/contracts/src/v0.8/vrf/dev/libraries/V
///// INHERIT NEW CONSUMER BASE CONTRACT /////
contract SubscriptionConsumer is VRFConsumerBaseV2Plus {
...

///// USE NEW COORDINATOR /////
IVRFCoordinatorV2Plus COORDINATOR;
///// No need to declare a coordinator variable /////
///// Use the `s_vrfCoordinator` from VRFConsumerBaseV2Plus.sol /////

///// SUBSCRIPTION ID IS NOW UINT256 /////
uint256 s_subscriptionId;
Expand All @@ -278,16 +276,13 @@ contract SubscriptionConsumer is VRFConsumerBaseV2Plus {

...

///// USE NEW CONSUMER BASE AND COORDINATOR CONSTRUCTORS /////
///// USE NEW CONSUMER BASE CONSTRUCTOR /////
constructor(
///// UPDATE TO UINT256 /////
uint256 subscriptionId
)
VRFConsumerBaseV2Plus(0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B)
{
COORDINATOR = IVRFCoordinatorV2Plus(
0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B
);
s_subscriptionId = subscriptionId;
}

Expand All @@ -298,7 +293,8 @@ contract SubscriptionConsumer is VRFConsumerBaseV2Plus {
{
///// UPDATE TO NEW V2.5 REQUEST FORMAT /////
// To enable payment in native tokens, set nativePayment to true.
requestId = COORDINATOR.requestRandomWords(
// Use the `s_vrfCoordinator` from VRFConsumerBaseV2Plus.sol
requestId = s_vrfCoordinator.requestRandomWords(
VRFV2PlusClient.RandomWordsRequest({
keyHash: keyHash,
subId: s_subscriptionId,
Expand Down
4 changes: 2 additions & 2 deletions src/content/vrf/v2-5/overview/direct-funding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ After you submit your request, it is processed using the [Request & Receive Data

## Limits

You can see the configuration for each network on the [Supported networks](/vrf/v2/direct-funding/supported-networks) page. You can also view the full configuration for each VRF v2 Wrapper contract directly in Etherscan. As an example, view the [Ethereum Mainnet VRF v2 Wrapper contract](https://etherscan.io/address/0x5A861794B927983406fCE1D062e00b9368d97Df6#readContract) configuration by calling `getConfig` function.
You can see the configuration for each network on the [Supported networks](/vrf/v2/direct-funding/supported-networks) page. You can also view the full configuration for each VRF v2.5 Wrapper contract directly in Etherscan. As an example, view the [Ethereum Mainnet VRF v2.5 Wrapper contract](https://etherscan.io/address/0x02aae1A04f9828517b3007f83f6181900CaD910c#readContract) configuration by calling `getConfig` function.

- Each wrapper has a `maxNumWords` parameter that limits the maximum number of random values you can receive in each request.
- The maximum allowed `callbackGasLimit` value for your requests is defined in the [Coordinator contract supported networks](/vrf/v2/subscription/supported-networks) page. Because the VRF v2.5 Wrapper adds an overhead, your `callbackGasLimit` must not exceed `maxGasLimit - wrapperGasOverhead`. Learn more about [estimating costs](/vrf/v2/estimating-costs).
- The maximum allowed `callbackGasLimit` value for your requests is defined in the [Coordinator contract supported networks](/vrf/v2-5/supported-networks) page. Because the VRF v2.5 Wrapper adds an overhead, your `callbackGasLimit` must not exceed `maxGasLimit - wrapperGasOverhead`. Learn more about [estimating costs](/vrf/v2-5/billing).
4 changes: 2 additions & 2 deletions src/content/vrf/v2-5/overview/subscription.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ metadata:
description: "Learn how to securely generate random numbers for your smart contract with Chainlink VRF v2.5(an RNG). This guide uses the subscription method."
---

import VrfCommon from "@features/vrf/v2-5/VrfCommon.astro"
import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import { Aside, ClickToZoom } from "@components"
import { TabsContent } from "@components/Tabs"
import { YouTube } from "@astro-community/astro-embed-youtube"

<VrfCommon callout="security" />
<Vrf2_5Common callout="security" />

This section explains how to generate random numbers using the subscription method.

Expand Down
6 changes: 3 additions & 3 deletions src/content/vrf/v2-5/subscription/create-manage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ date: Last Modified
title: "Create and manage VRF V2.5 subscriptions"
---

import VrfCommon from "@features/vrf/v2-5/VrfCommon.astro"
import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import { CodeSample } from "@components"
import { Tabs, TabsContent } from "@components/Tabs"

<VrfCommon callout="security" />
<Vrf2_5Common callout="security" />

## Using the VRF Subscription Manager

The private version of the VRF Subscription Manager is available to help you create and manage VRF V2.5 subscriptions. Alternatively, you can [create and manage subscriptions programmatically](#create-a-subscription-programmatically).
The [VRF Subscription Manager](https://vrf.chain.link/) is available to help you create and manage VRF V2.5 subscriptions. You can create and manage new V2.5 subscriptions, and manage existing V2 subscriptions, but you can no longer create new V2 subscriptions in the VRF Subscription Manager. Alternatively, you can [create and manage subscriptions programmatically](#create-a-subscription-programmatically).

### Create a subscription

Expand Down
6 changes: 2 additions & 4 deletions src/content/vrf/v2-5/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ metadata:
image: "/files/OpenGraph_V3.png"
---

import VrfCommon from "@features/vrf/v2-5/VrfCommon.astro"
import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import ResourcesCallout from "@features/resources/callouts/ResourcesCallout.astro"
import { Address, Aside, CopyText } from "@components"
import { TabsContent } from "@components/Tabs"

<VrfCommon callout="security" />
<Vrf2_5Common callout="security" />

Chainlink VRF allows you to integrate provably fair and verifiably random data in your smart contract.

Expand All @@ -30,8 +30,6 @@ These parameters are configured in the coordinator contract. You can view these

## Configurations

<VrfCommon callout="availability" />

VRF v2.5 coordinators for subscription funding are available on several networks.

<ResourcesCallout callout="bridgeRisks" />
Expand Down
45 changes: 28 additions & 17 deletions src/content/vrf/v2/direct-funding/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ metadata:
image: "/files/OpenGraph_V3.png"
---

import VrfCommon from "@features/vrf/v2/common/VrfCommon.astro"
import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import ResourcesCallout from "@features/resources/callouts/ResourcesCallout.astro"
import { Address, Aside } from "@components"

<VrfCommon callout="directFunding" />
<Vrf2_5Common callout="supportednetworks" />

Chainlink VRF allows you to integrate provably fair and verifiably random data in your smart contract.

Expand Down Expand Up @@ -51,6 +51,8 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### Ethereum mainnet

<Vrf2_5Common callout="supportednetworks" />

| Item | Value |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| LINK Token | <Address contractUrl="https://etherscan.io/token/0x514910771AF9Ca656af840dff83E8264EcF986CA" urlId="1_0x514910771AF9Ca656af840dff83E8264EcF986CA" urlClass="erc-token-address"/> |
Expand All @@ -66,10 +68,10 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### Sepolia testnet

<Aside type="note" title="Sepolia Faucets">
Testnet LINK and ETH are available from <a href="https://faucets.chain.link/sepolia">faucets.chain.link</a>.<br />
Testnet ETH is also available from several public <a href="https://faucetlink.to/sepolia">ETH faucets</a>.
</Aside>
<Vrf2_5Common callout="supportednetworks" />

Testnet LINK and ETH are available from <a href="https://faucets.chain.link/sepolia">faucets.chain.link</a>.
Testnet ETH is also available from several public <a href="https://faucetlink.to/sepolia">ETH faucets</a>.

| Item | Value |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -87,6 +89,8 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### BNB Chain mainnet

<Vrf2_5Common callout="supportednetworks" />

<Aside type="tip" title="Important">
The LINK provided by the [BNB Chain Bridge](https://www.bnbchain.world/en/bridge) is not ERC-677 compatible, so cannot
be used with Chainlink oracles. However, it can be [**converted to the official LINK token on BNB Chain using
Expand All @@ -108,9 +112,9 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### BNB Chain testnet

<Aside type="note" title="BNB Chain Faucet">
Testnet LINK is available from https://faucets.chain.link/bnb-chain-testnet
</Aside>
<Vrf2_5Common callout="supportednetworks" />

Testnet LINK is available from https://faucets.chain.link/bnb-chain-testnet

| Item | Value |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -127,6 +131,8 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### Polygon (Matic) mainnet

<Vrf2_5Common callout="supportednetworks" />

<Aside type="tip" title="Important">
The LINK provided by the [Polygon (Matic) Bridge](https://wallet.polygon.technology/bridge) is not ERC-677 compatible,
so cannot be used with Chainlink oracles. However, it can be [**converted to the official LINK token on Polygon
Expand All @@ -148,6 +154,8 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### Avalanche mainnet

<Vrf2_5Common callout="supportednetworks" />

| Item | Value |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| LINK Token | <Address contractUrl="https://snowtrace.io/address/0x5947BB275c521040051D82396192181b413227A3" urlId="43114_0x5947BB275c521040051D82396192181b413227A3" urlClass="erc-token-address"/> |
Expand All @@ -163,9 +171,9 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### Avalanche Fuji testnet

<Aside type="note" title="Avax Fuji Faucet">
Testnet LINK is available from https://faucets.chain.link/fuji
</Aside>
<Vrf2_5Common callout="supportednetworks" />

Testnet LINK is available from https://faucets.chain.link/fuji

| Item | Value |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -184,7 +192,8 @@ VRF v2 coordinators for direct funding are available on several networks. To see
### Fantom mainnet

<Aside type="tip" title="Important">
You must use ERC-677 LINK on Fantom. ERC-20 LINK will not work with Chainlink services.
You must use ERC-677 LINK on Fantom. ERC-20 LINK will not work with Chainlink services. Fantom is not supported in VRF
V2.5.
</Aside>

| Item | Value |
Expand All @@ -204,7 +213,7 @@ VRF v2 coordinators for direct funding are available on several networks. To see
### Fantom testnet

<Aside type="note" title="Fantom Testnet Faucet">
Testnet LINK is available from https://faucets.chain.link/fantom-testnet
Testnet LINK is available from https://faucets.chain.link/fantom-testnet.
</Aside>

| Item | Value |
Expand All @@ -223,6 +232,8 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### Arbitrum mainnet

<Vrf2_5Common callout="supportednetworks" />

| Item | Value |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| LINK Token | <Address contractUrl="https://arbiscan.io/address/0xf97f4df75117a78c1A5a0DBb814Af92458539FB4" urlId="42161_0xf97f4df75117a78c1A5a0DBb814Af92458539FB4" urlClass="erc-token-address"/> |
Expand All @@ -239,9 +250,9 @@ VRF v2 coordinators for direct funding are available on several networks. To see

### Arbitrum Sepolia testnet

<Aside type="note" title="Arbitrum Sepolia Testnet Faucet">
Testnet LINK is available from https://faucets.chain.link/arbitrum-sepolia
</Aside>
<Vrf2_5Common callout="supportednetworks" />

Testnet LINK is available from https://faucets.chain.link/arbitrum-sepolia

| Item | Value |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down

0 comments on commit 0a447a9

Please sign in to comment.