Lesson9: Error: invalid BigNumber value #1326
-
I got the below error when deploying my Raffle contract to rinkeby network Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.6.2)
at Logger.makeError (C:\Users\PC\Desktop\DEVELOPEMENT\hardhat-smartcontract-lottery-fcc\node_modules\@ethersproject\logger\src.ts\index.ts:261:28)
at Logger.throwError (C:\Users\PC\Desktop\DEVELOPEMENT\hardhat-smartcontract-lottery-fcc\node_modules\@ethersproject\logger\src.ts\index.ts:273:20) at Logger.throwArgumentError (C:\Users\PC\Desktop\DEVELOPEMENT\hardhat-smartcontract-lottery-fcc\node_modules\@ethersproject\logger\src.ts\index.ts:277:21) 01-deploy-raffle.js const { network, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-hardhat-config")
const { verify } = require("../helper-hardhat-config")
const VRF_FUND_AMOUNT = ethers.utils.parseEther("30")
module.exports = async function ({getNamedAccounts, deployments}){
const { deploy, log } = deployments
const {deployer} = await getNamedAccounts()
const chainId = network.config.chainId
// chainId of vrfco-ordinator
let vrfCoordinatorV2Address
if(developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1)
subscriptionId = transactionReceipt.events[0].args.subId
//Fund the sunscription
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_FUND_AMOUNT)
// if we are not on a local network
// vrfCoordinator will be derived from networkconfig
// in helper-hardhat-config
// import the networkConfig
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"]
subscriptionId = networkConfig[chainId]["subscription"]
}
const entranceFee = networkConfig[chainId]["entranceFee"]
const gasLane = networkConfig[chainId]["gasLane"]
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"]
const interval = networkConfig[chainId]["interval"]
const args = [
vrfCoordinatorV2Address,
subscriptionId,
gasLane,
interval,
entranceFee,
callbackGasLimit,
//all the above must be in the same order as constructor..
]
const raffle = await deploy("Raffle", {
from: deployer,
args: args ,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
//from args[], pass contructor contracts into it
//create a Helpers config()
})
if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY){
log("Verifying......")
await verify(raffle.address, args)
}
log("...........................")
}
module.exports.tags = ["all", "raffle"] hardhat-helper-config.js const { ethers } = require("hardhat")
const networkConfig = {
4: {
name: "rinkeby",
vrfCoordinatorV2: "0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314",
subscriptionId: "9196",
callbackGasLimit: "500000", //500,000
interval: "30",
},
31337: {
name: "hardhat",
vrfCoordinatorV2: "0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314",
subscriptionId: "9196",
callbackGasLimit: "500000", //500,000
interval: "30",
},
1: {
name:"mainnet",
interval: "30",
}
}
const developmentChains = ["hardhat", "localhost"]
module.exports = {
networkConfig,
developmentChains,
} hardhat.config.js require("@nomiclabs/hardhat-waffle")
require("@nomiclabs/hardhat-etherscan")
require("hardhat-deploy")
require("solidity-coverage")
require("hardhat-gas-reporter")
require("hardhat-contract-sizer")
require("dotenv").config()
const RINKEBY_RPC_URL = process.env.RINKEBY_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
// // If you want to do some forking, uncomment this
// forking: {
// url: MAINNET_RPC_URL
// }
chainId: 31337,
},
localhost: {
chainId: 31337,
},
rinkeby: {
url: RINKEBY_RPC_URL,
accounts:[PRIVATE_KEY],
// accounts: {
// mnemonic: MNEMONIC,
// },
saveDeployments: true,
chainId: 4,
},
},
etherscan: {
// yarn hardhat verify --network <NETWORK> <CONTRACT_ADDRESS> <CONSTRUCTOR_PARAMETERS>
apiKey: {
rinkeby: ETHERSCAN_API_KEY,
},
},
gasReporter: {
enabled: false,
currency: "USD",
outputFile: "gas-report.txt",
noColors: true,
// coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
contractSizer: {
runOnCompile: false,
only: ["Raffle"],
},
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
},
player: {
default: 1,
},
},
solidity: {
compilers: [
{
version: "0.8.7",
},
{
version: "0.4.24",
},
],
},
mocha: {
timeout: 500000, // 500 seconds max for running tests
},
} |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Jul 26, 2022
Replies: 2 comments 12 replies
-
@Maakai123 I saw this issue - subscriptionId = networkConfig[chainId]["subscription"]
+ subscriptionId = networkConfig[chainId]["subscriptionId"] |
Beta Was this translation helpful? Give feedback.
12 replies
Answer selected by
alymurtazamemon
-
transactionReceipt.events[0].args.subId Only Change the code that is inside your IF statement. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Maakai123 I saw this issue