diff --git a/src/content/quickstarts/pass-cost-to-end-user.mdx b/src/content/quickstarts/pass-cost-to-end-user.mdx
index a480b4dc6d9..eb4ea5b80c9 100644
--- a/src/content/quickstarts/pass-cost-to-end-user.mdx
+++ b/src/content/quickstarts/pass-cost-to-end-user.mdx
@@ -150,7 +150,7 @@ This gives you an existing [Foundry](https://github.com/foundry-rs/foundry) proj
export PRIVATE_KEY=
# Explorer API key used to verify contracts
- export EXPLORER_KEY=
+ export ETHERSCAN_API_KEY=
```
1. In your `.env` file, fill in these values:
@@ -195,11 +195,11 @@ Test the contract as the end-user.
1. Open the [LINK Token Contract](https://docs.chain.link/resources/link-token-contracts) write functions for your network in an explorer. For example, on Ethereum Sepolia you can open the [0x779877A7B0D9E8603169DdbD7836e478b4624789](https://sepolia.etherscan.io/token/0x779877A7B0D9E8603169DdbD7836e478b4624789#writeContract) contract.
-1. Connect your wallet to the scanning app so you can run write functions.
+1. Connect your wallet to the block explorer (e.g. [Etherscan](https://sepolia.etherscan.io/) for Ethereum Sepolia) so you can run write functions.
@@ -211,15 +211,15 @@ Test the contract as the end-user.
style="max-width: 50%;"
/>
-1. Open your deployed contract in the scanner.
+1. Open your deployed contract in the block explorer.
1. On the **Contract** tab, open the **Write Contract** functions list for your deployed contract.
-1. Again, connect your wallet to the scanner so you can run write functions on the deployed contract.
+1. Again, connect your wallet to the block explorer so you can run write functions on the deployed contract.
@@ -261,37 +261,46 @@ struct RequestStatus {
mapping(uint256 => RequestStatus) public s_requests;
```
-The `requestRandomWords()` function uses a method in the VRF wrapper contract to calculate the request cost upfront, and then transfers enough LINK to the VRF wrapper to cover the request. After sending the request, it sets up the `RequestStatus` with the cost and other attributes to be updated after request fulfillment.
+The `requestRandomWords` function calls the `calculateRequestPrice` function on the VRF wrapper contract to calculate the request cost upfront, and then transfers enough LINK to the VRF wrapper to cover the request. After sending the request, the `requestRandomWords` function stores the `RequestStatus` with the cost and other request attributes, and emits a `RequestSent` event.
```solidity
-uint256 requestPrice = vrfWrapper.calculateRequestPrice(
- requestConfig.callbackGasLimit
- );
-
-require(
- linkTokenContract.transferFrom(
- msg.sender,
- address(this),
- requestPrice
- ),
- "Not enough LINK"
+function requestRandomWords() external returns (uint256) {
+ // Calculate the price required for the VRF request based on the configured parameters.
+ uint256 requestPrice = calculateRequestPrice();
+
+ // Transfer the required LINK tokens from the caller's address to this contract.
+ transferLinkFromUser(requestPrice);
+
+ // Send the randomness request to the VRF Wrapper contract and retrieve the request ID and the paid price.
+ bytes memory extraArgs = VRFV2PlusClient._argsToBytes(VRFV2PlusClient.ExtraArgsV1({nativePayment: false}));
+ (uint256 requestId, uint256 reqPrice) = requestRandomness(
+ requestConfig.callbackGasLimit, requestConfig.requestConfirmations, requestConfig.numWords, extraArgs
);
- ...
+ // Record the request details.
+ s_requests[requestId] = RequestStatus({paid: reqPrice, randomWords: new uint256[](0), fulfilled: false});
+ requestIds.push(requestId);
+ lastRequestId = requestId;
- s_requests[requestId] = RequestStatus({
- paid: requestPrice,
- randomWords: new uint256[](0),
- fulfilled: false
- });
+ // Emit an event indicating that a request has been sent.
+ emit RequestSent(requestId, requestConfig.numWords);
+
+ return requestId;
+}
+
+[...]
+
+function calculateRequestPrice() internal view returns (uint256) {
+ return i_vrfV2PlusWrapper.calculateRequestPrice(requestConfig.callbackGasLimit, requestConfig.numWords);
+}
```
-After the VRF service fulfills your randomness request, it calls back your `fulfillRandomWords()` function, where you implement logic to handle the random values. It's recommended to keep the processing in your callback function minimal to save on gas costs. In this case, the example contract updates the `RequestStatus` in the request mapping, and emits an event indicating that the request has been fulfilled. Another part of your application can listen for this event and further process the random values separately from the callback function.
+After the VRF service fulfills your randomness request, it calls back your `fulfillRandomWords` function, where you implement logic to handle the random values. It's recommended to keep the processing in your callback function minimal to save on gas costs. In this case, the example contract updates the `RequestStatus` in the request mapping, and emits an event indicating that the request has been fulfilled. Another part of your application can listen for this event and further process the random values separately from the callback function.
```solidity
function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override {
- require(s_requests[_requestId].paid > 0, "request not found");
- s_requests[_requestId].fulfilled = true;
- s_requests[_requestId].randomWords = _randomWords;
- emit RequestFulfilled(_requestId, _randomWords, s_requests[_requestId].paid);
+ require(s_requests[_requestId].paid > 0, "request not found");
+ s_requests[_requestId].fulfilled = true;
+ s_requests[_requestId].randomWords = _randomWords;
+ emit RequestFulfilled(_requestId, _randomWords, s_requests[_requestId].paid);
}
```
diff --git a/src/content/quickstarts/vrf-mystery-box.mdx b/src/content/quickstarts/vrf-mystery-box.mdx
index dda678d5de4..eeb539de498 100644
--- a/src/content/quickstarts/vrf-mystery-box.mdx
+++ b/src/content/quickstarts/vrf-mystery-box.mdx
@@ -11,15 +11,21 @@ import { Accordion, Aside, CodeSample } from "@components"
## Overview
-This is a template for NFT collection with a mystery box mechanic powered by [Chainlink VRF](https://vrf.chain.link/).
+This is a template for NFT collection with a mystery box mechanic powered by [Chainlink VRF V2.5](https://docs.chain.link/vrf).
-Smart contracts are based on the gas efficient [ERC721Psi](https://github.com/estarriolvetch/ERC721Psi) and are fully tested. It's super easy to deploy and configure with most of the steps automated in the deploy script.
+Smart contracts are based on the gas efficient [ERC721Psi](https://github.com/estarriolvetch/ERC721Psi). It's super easy to deploy and configure with most of the steps automated in the deploy script.
-Some of the key features of this template include private minting stage with a merkle tree, rate limited batch minting, delayed reveal with randomization technique to save gas, provenance hash to verify the authenticity of the metadata, royalties for secondary sales, and configurable parameters.
+The key features of this template include:
+- a private minting stage with a merkle tree
+- rate limited batch minting
+- delayed reveal with randomization technique to save gas
+- provenance hash to verify the authenticity of the metadata
+- royalties for secondary sales
+- configurable parameters
## Objective
-You will use a HardHat project with the Chainlink Hardhat Plugin to deploy an existing MysteryBox application on Avalanche Fuji testnet.
+You will use a Hardhat project to deploy an existing MysteryBox application on Ethereum Sepolia.