smartcontractkit/documentation

[Bug]: VRFv2Consumer.sol sample has incorrect import

Closed this issue · 4 comments

Describe the bug

When copying the sample code for VRFv2Consumer, the import for VRFCoordinatorV2Mock is incorrect, as presumably, the location of it has changed recently.

To Reproduce

  1. Go to 'https://docs.chain.link/vrf/v2/subscription/examples/get-a-random-number#analyzing-the-contract'
  2. Copy the code snippet into a file on your local machine.
  3. Attempt to compile the smart contract.
  4. Receive compiler error for the import.

URLs

Expected behavior

The ability to copy the code and have it compile

Additional context

No response

Hi @Hotmanics

which version of the @chainlink/contracts NPM package are you using? If you are using v1.0.0 then it's still beta.

If you use v0.8.0 then it will work fine . Example with Remix IDE:

  1. Open the link that you shared: https://docs.chain.link/vrf/v2/subscription/examples/get-a-random-number#analyzing-the-contract
  2. Go below the contract and click on "Open in Remix"
  3. The following link will open and you'll notice the version is pinned to the imports.
import {VRFCoordinatorV2Interface} from "@chainlink/contracts@0.8.0/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import {VRFConsumerBaseV2} from "@chainlink/contracts@0.8.0/src/v0.8/vrf/VRFConsumerBaseV2.sol";
import {ConfirmedOwner} from "@chainlink/contracts@0.8.0/src/v0.8/shared/access/ConfirmedOwner.sol";

@aelmanaa I am actually installing the github repo as a library in foundry through
forge install smartcontractkit/chainlink --no-commit.

@aelmanaa I am actually installing the github repo as a library in foundry through

forge install smartcontractkit/chainlink --no-commit.

Thanks @Hotmanics !
Yes indeed foundry by default installs the latest GitHub main branch ( if you don't specify a release tag or a commit id).

We are currently working on adapting all our examples to work with the latest version. This PR will fix this issue. Also we will add callouts to explain how to install the latest npm version using npm,yarn, and foundry

Closing for now. let me know if you still run into issues