Question formatting practice. Not a really question. #5351
AKIN-THOMAS
started this conversation in
General
Replies: 3 comments 1 reply
-
I might use this thread to practice as well, thanks! function fund() public payable {
require(msg.value.getConversionRate() >= minimumUsd, "Didn't send enough");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
}
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Hardhat config file require("@nomicfoundation/hardhat-toolbox")
require("dotenv").config()
require("@nomiclabs/hardhat-etherscan")
require("hardhat-gas-reporter")
require("solidity-coverage")
require("hardhat-deploy")
require("@nomiclabs/hardhat-ethers")
/** @type import('hardhat/config').HardhatUserConfig */
const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || ""
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY
module.exports = {
solidity: {
compilers: [{ version: "0.8.18" }, { version: "0.6.6" }],
},
defaultNetwork: "hardhat",
networks: {
sepolia: {
url: SEPOLIA_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 11155111,
blockConfirmations: 6,
},
localhost: {
url: "http://127.0.0.1:8545/",
chainId: 31337,
},
},
etherscan: {
apiKey: {
sepolia: ETHERSCAN_API_KEY,
},
},
gasReporter: {
enabled: false,
outputFile: "gas-report.txt",
noColors: true,
currency: "USD",
coinmarketcap: COINMARKETCAP_API_KEY,
token: "MATIC",
},
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
},
},
}
01-deploy-fundme //imports
const { network } = require("hardhat")
const { networkConfig } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
require("dotenv").config()
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let ethUsdPriceFeedAddress
//When should use a mock when going for localhost network or hardhat
if (chainId === 31337) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
}
const args = [ethUsdPriceFeedAddress]
log("Deploying Fundme contract and waiting for confirmations...")
const fundMe = await deploy("FundMe", {
from: deployer,
args: args, //The Price Feed Address to enter the constructor in the contract.
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
log(`Fudme contracts deployed at: ${fundMe.address}`)
log("___________________________________________")
// await verify(fundMe.address, args)
if (!chainId == 31337 && process.env.ETHERSCAN_API_KEY) {
await verify(fundMe.address, args)
}
}
module.exports.tabs = ["all", "fundme"] Verify const { run } = require("hardhat")
async function verify(contractAddress, args) {
console.log("Verifying contract...")
try {
await run("verify:verify", {
address: contractAddress,
constructorArgument: args,
})
} catch (e) {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Already verified contract")
} else {
console.log(e)
}
}
}
module.exports = { verify } helper hardhat const networkConfig = {
31337: {
name: "localhost"
},
11155111: {
name: "sepolia",
ethUsdPriceFeed: "0x694AA1769357215DE4FAC081bf1f309aDC325306",
},
// 137: {
// name: "mumbai", //Polygon Testnet
// ethUsdPriceFeed: "0x0715A7794a1dc8e42615F059dD6e406A6594651A",
// },
}
const developmentChains = ["hardhat", "localhost"]
module.export = {
networkConfig,
developmentChains,
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
require("@nomicfoundation/hardhat-toolbox")
require("dotenv").config()
require("@nomiclabs/hardhat-etherscan")
require("hardhat-gas-reporter")
require("solidity-coverage")
require("hardhat-deploy")
require("@nomiclabs/hardhat-ethers")
/** @type import('hardhat/config').HardhatUserConfig */
const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || ""
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY
module.exports = {
solidity: {
compilers: [{ version: "0.8.18" }, { version: "0.6.6" }],
},
defaultNetwork: "hardhat",
networks: {
sepolia: {
url: SEPOLIA_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 11155111,
blockConfirmations: 6,
},
localhost: {
url: "http://127.0.0.1:8545/",
chainId: 31337,
},
},
etherscan: {
apiKey: {
sepolia: ETHERSCAN_API_KEY,
},
},
gasReporter: {
enabled: false,
outputFile: "gas-report.txt",
noColors: true,
currency: "USD",
coinmarketcap: COINMARKETCAP_API_KEY,
token: "MATIC",
},
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
},
},
}
// npm i --save-dev @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Sorry I don's have a question. I'm just practicing my question formatting like you said we should do on the course.
Beta Was this translation helpful? Give feedback.
All reactions