- use https://www.alchemy.com/ to push smart contract to blockchain.
- Alchemy essentially helps us broadcast our contract creation transaction so that it can be picked up by miners as quickly as possible. Once the transaction is mined, it is then broadcasted to the blockchain as a legit transaction. From there, everyone updates their copy of the blockchain.
require("@nomiclabs/hardhat-waffle");
module.exports = {
solidity: "0.8.0",
networks: {
rinkeby: {
url: "YOUR_ALCHEMY_API_URL", // check alchemy.com
accounts: ["YOUR_PRIVATE_RINKEBY_ACCOUNT_KEY"],
},
},
};
or rename .env.example
to .env
and update the content if .env
. Then refer below to use dotenv
...
require("dotenv").config();
...
module.exports = {
...
networks: {
rinkeby: {
url: process.env.ALCHEMY_URL,
accounts: [process.env.PRIVATE_KEY],
},
},
...
}
MetaMask > Network "Rinkeby Test Network" > 3 dot > Account Details > Export Privatge Key
npx hardhat run scripts/run.js
npx hardhat node
npx hardhat run scripts/deploy.js --network localhost
npx hardhat run scripts/deploy.js --network rinkeby
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts.
Try running some of the following tasks:
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
node scripts/sample-script.js
npx hardhat help