[Bug]: VRFv2Consumer.sol sample has incorrect import
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
- Go to 'https://docs.chain.link/vrf/v2/subscription/examples/get-a-random-number#analyzing-the-contract'
- Copy the code snippet into a file on your local machine.
- Attempt to compile the smart contract.
- Receive compiler error for the import.
URLs
- https://docs.chain.link/vrf/v2/subscription/examples/get-a-random-number
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:
- Open the link that you shared: https://docs.chain.link/vrf/v2/subscription/examples/get-a-random-number#analyzing-the-contract
- Go below the contract and click on "Open in Remix"
- The following link will open and you'll notice the version is pinned to the imports.
import {VRFCoordinatorV2Interface} from "@chainlink/[email protected]/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import {VRFConsumerBaseV2} from "@chainlink/[email protected]/src/v0.8/vrf/VRFConsumerBaseV2.sol";
import {ConfirmedOwner} from "@chainlink/[email protected]/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