Deploy Smart Contract
- Open the folder and search for a file called hardhat.config.js. This is the file that contains the configuration for our project. Open it and add the following code to it:
- Download and install metamask extension in your browser. Installations instructions can be found here: https://codexam.vercel.app/docs/project/DeCryptX/dcx3 (opens in a new tab)
- Use any goreli testnet faucet to get some testnet ether. You can use this one: https://faucet.goerli.mudit.blog/ (opens in a new tab)
- Go to three dots on the top right corner of the metamask extension and click on "Account details" and then "Export Private Key". Copy the private key with a password.
- Now go to project folder and create a file called .env and paste the following code in it:
PRIVATE_KEY=565a4qefasf4a6f4a64f6a4f64a6df46afggfaerqavxcvxdgag4674g64a6f4a6
(replace the private key with the one you copied from metamask)- Now go to the web browser and go to https://www.ankr.com/rpc/eth/eth_goerli/ (opens in a new tab) and copy the RPC URL https://rpc.ankr.com/eth_goerli (opens in a new tab) and paste it in the hardhat.config.js file in the url field.
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
version: '0.8.9',
defaultNetwork: 'goerli',
networks: {
hardhat: {},
goerli: {
url: 'https://rpc.ankr.com/eth_goerli',
accounts: [`0x${process.env.PRIVATE_KEY}`]
}
},
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
};
- Now go to the terminal and run the following command:
npm run deploy
and wait for the contract to be deployed. Once the contract is deployed, you will see the contract address in the terminal.
✔ Compilation successful
✔ Processing contract: "CrowdFunding"
✔ Deployment parameters written to deployArgs.json in your project directory
✔ Upload successful
✔ Open this link to deploy your contracts: https://thirdweb.com/contracts/deploy/fsfsfsfsfsfsfsfggfdg
- Go to the link which is provided in the terminal and click on "Deploy". Now click on "Connect Wallet" and connect your metamask wallet. Now click on "Deploy" and wait for the contract to be deployed and it will deduct some ether from your account.
Now you have successfully deployed your smart contract. You can see your dashboard