Lesson 9 - Error: value out-of-bounds (argument="callbackGasLimit", value="100000000000000000", code=INVALID_ARGUMENT, version=abi/5.6.3) #307
-
During TypeScript conversion I'm getting this error while deploying the contract to the local test net. Error -
I could assume it has something to do with either
export interface networkConfigItem {
name?: string;
subscriptionId?: string;
gasLane?: string;
keepersUpdateInterval?: string;
raffleEntranceFee?: string;
callbackGasLimit?: string;
vrfCoordinatorV2?: string;
}
export interface networkConfigInfo {
[key: number]: networkConfigItem;
}
export const networkConfig: networkConfigInfo = {
4: {
name: 'rinkeby',
subscriptionId: '6258',
gasLane:
'0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc', // 30 gwei
keepersUpdateInterval: '30',
raffleEntranceFee: '100000000000000000', //'100000000000000000', // 0.1 ETH
callbackGasLimit: '500000', // 500,000 gas
vrfCoordinatorV2: '0x6168499c0cFfCaCD319c818142124B7A15E857ab',
},
31337: {
name: 'hardhat',
subscriptionId: '6258',
raffleEntranceFee: '100000000000000000',
gasLane:
'0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc', // 30 gwei
callbackGasLimit: '50000', // 500,000 gas
keepersUpdateInterval: '30',
vrfCoordinatorV2: '0x6168499c0cFfCaCD319c818142124B7A15E857ab',
},
};
export const developmentChains = ['hardhat', 'localhost'];
export const VERIFICATION_BLOCK_CONFIRMATIONS = 6;
import '@typechain/hardhat';
import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-etherscan';
import '@nomiclabs/hardhat-ethers';
import 'hardhat-deploy';
import 'solidity-coverage';
import 'hardhat-gas-reporter';
import 'hardhat-contract-sizer';
import 'dotenv/config';
import { HardhatUserConfig } from 'hardhat/types';
/**
* @type import('hardhat/config').HardhatUserConfig
*/
const RINKEBY_RPC_URL = process.env.RINKEBY_RPC_URL || 'https://eth-rinkeby';
const RINKEBY_PRIVATE_KEY = process.env.RINKEBY_PRIVATE_KEY || '0xkey';
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || 'key';
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY || 'key';
const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
networks: {
hardhat: {
chainId: 31337,
// gasPrice: 130000000000,
},
rinkeby: {
url: RINKEBY_RPC_URL,
accounts: [RINKEBY_PRIVATE_KEY],
chainId: 4,
},
},
solidity: {
compilers: [
{
version: '0.8.7',
},
{
version: '0.8.8',
},
],
},
gasReporter: {
enabled: false,
outputFile: 'gas-report.txt',
noColors: true,
currency: 'USD',
coinmarketcap: COINMARKETCAP_API_KEY,
token: 'ETH',
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
namedAccounts: {
deployer: {
default: 0,
1: 0,
},
player: {
default: 1,
},
},
mocha: {
timeout: 200000, // 400 seconds
},
};
export default config; In any case, here's the import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import {
developmentChains,
networkConfig,
VERIFICATION_BLOCK_CONFIRMATIONS,
} from '../helper-hardhat-config';
import verify from '../utils/verify';
type chainId = number;
const VRF_SUB_FUND_AMOUNT = '1000000000000000000000';
const deployRaffle: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts, network, ethers } = hre;
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId: chainId = network.config.chainId!;
// const chainId = 31337;
let vrfCoordinatorV2Address, subscriptionId;
// if (developmentChains.includes(network.name)) {
if (chainId == 31337) {
const vrfCoordinatorV2Mock = await ethers.getContract(
'VRFCoordinatorV2Mock'
);
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address;
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription();
const transactionReceipt = await transactionResponse.wait();
subscriptionId = transactionReceipt.events[0].args.subId;
// Fund the subscription \
await vrfCoordinatorV2Mock.fundSubscription(
subscriptionId,
VRF_SUB_FUND_AMOUNT
);
} else {
vrfCoordinatorV2Address =
networkConfig[network.config.chainId!]['vrfCoordinatorV2'];
subscriptionId = networkConfig[network.config.chainId!]['subscriptionId'];
}
const waitBlockConfirmations = developmentChains.includes(network.name)
? 1
: VERIFICATION_BLOCK_CONFIRMATIONS;
log('------------------------------------------------');
const args = [
vrfCoordinatorV2Address,
subscriptionId,
networkConfig[network.config.chainId!]['gasLane'],
networkConfig[network.config.chainId!]['keepersUpdateInterval'],
networkConfig[network.config.chainId!]['raffleEntranceFee'],
networkConfig[network.config.chainId!]['callbackGasLimit'],
];
const raffle = await deploy('Raffle', {
from: deployer,
args: args,
log: true,
waitConfirmations: waitBlockConfirmations,
});
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
log('Verifying...!');
await verify(raffle.address, args);
}
log('------------------------------------------------');
};
export default deployRaffle;
deployRaffle.tags = ['all', 'raffle']; |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
maybe this number is too large you also didn't put a ? here what does the ? do btw? |
Beta Was this translation helpful? Give feedback.
-
@mattjaf fixed the problem. Thanks for the help. I lowered the value of The updated code block looks like this now - 31337: {
name: 'hardhat',
subscriptionId: '6258',
raffleEntranceFee: '100000000',
gasLane:
'0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc', // 30 gwei
callbackGasLimit: '50000', // 500,000 gas
keepersUpdateInterval: '30',
vrfCoordinatorV2: '0x6168499c0cFfCaCD319c818142124B7A15E857ab',
}, |
Beta Was this translation helpful? Give feedback.
@mattjaf fixed the problem. Thanks for the help. I lowered the value of
raffleEntranceFee
in thehelper-hardhat-config.ts
file.The updated code block looks like this now -