Lesson 9: Error: value out-of-bounds (argument="subscriptionId"...). How create a subscriptionId V2 instead V2.5? #6621
-
I was trying to deploy my Raffle.sol to Sepolia network, but the following error appears: Error: value out-of-bounds (argument="subscriptionId", value="57523992536066914636542733918698497913286620907923606939974052550738514442581", code=INVALID_ARGUMENT, version=abi/5.7.0) I know where the error is but I don't know how to solution, so the scripts are the following: const { network, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
const VRF_SUB_FUND_AMOUNT = ethers.parseEther("30")
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let vrfCoordinatorV2Address, subscriptionId
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.target
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1)
subscriptionId = transactionReceipt.logs[0].args.subId
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT)
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"]
subscriptionId = networkConfig[chainId]["subscriptionId"]
}
const entranceFee = networkConfig[chainId]["entranceFee"]
const gasLane = networkConfig[chainId]["gasLane"]
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"]
const interval = networkConfig[chainId]["interval"]
const args = [
vrfCoordinatorV2Address,
entranceFee,
gasLane,
subscriptionId,
callbackGasLimit,
interval,
]
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
if (chainId == 31337) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
await vrfCoordinatorV2Mock.addConsumer(Number(subscriptionId), raffle.address)
log("Adding consumer...")
log("Consumer added!")
}
if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
log("Verifying...")
await verify(raffle.address, args)
}
log("---------------------------------------------------")
}
module.exports.tags = ["all", "raffle"] helper-hardhat-config.js const { ethers } = require("hardhat")
const networkConfig = {
11155111: {
name: "sepolia",
vrfCoordinatorV2: "0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625",
entranceFee: ethers.parseEther("0.01"),
gasLane: "0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c",
subscriptionId:
"57523992536066914636542733918698497913286620907923606939974052550738514442581",
callbackGasLimit: "500000",
interval: "30",
},
31337: {
name: "hardhat",
entranceFee: ethers.parseEther("0.01"),
gasLane: "0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c",
callbackGasLimit: "500000",
interval: "30",
},
}
const developmentChains = ["hardhat", "localhost"]
module.exports = {
networkConfig,
developmentChains,
} So, the problem is that the subscriptionId that Chainlink gave me is so much longer than an uint64; how can I create a subscription V2 instead V2.5? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You can create a subscription V2 from the contract (in Sepolia): |
Beta Was this translation helpful? Give feedback.
-
you can click this two links below to change the subscriptionId from uint64 to uint256. |
Beta Was this translation helpful? Give feedback.
You can create a subscription V2 from the contract (in Sepolia):
0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625