Reputation: 533
So I have followed multiple tutorials on getting started with smart contract development in Ethereum and have read many, many pages on security and development in OpenZeppelin. How exactly do I go about actually deploying my project to the Ethereum mainnet using Hardhat though? I can only find info on deploying to test networks!
Upvotes: 5
Views: 6871
Reputation: 31
In the context of hardhat, mainnet, testnet or any other network work in the same way. These are just the tags. you can define multiple networks in hardhat config
module.exports = {
solidity: "0.8.9",
defaultNetwork: "hardhat",
networks: {
hardhat: {},
rinkeby: {
url: RAPI_URL,
accounts: [RINKEBY_WALLET_ADDRESS_PRIVATE_KEY]
},
mainnet: {
url: ETH_MAINNET_RPC_URL,
accounts: [MAINNET_WALLET_ADDRESS_PRIVATE_KEY]
},
},
}
then for deploy use the command like this
npx hardhat run scripts/deploy.js --network rinkeby
or
npx hardhat run scripts/deploy.js --network mainnet
Upvotes: 2
Reputation: 43491
Expand the networks
section of the config file.
Example configuration:
mainnet: {
url: "https://mainnet.infura.io/v3/<your_infura_key>", // or any other JSON-RPC provider
accounts: [<your_private_key>]
}
Instead of specifying the private key directly, you can also specify the mnemonic
phrase.
For more details, see the docs.
Upvotes: 10