Generate deployer account.
yarn generate
It will create file in packages\hardhat
with mnemonic.
Change destination in packages\hardhat\hardhat.config.js
(example for ropsten
testnet):
const defaultNetwork = "ropsten";
Update credentials for deployment in packages\hardhat\.env
(example for ropsten
testnet):
# Ropsten
ROPSTEN_INFURA_KEY=<infura-secret-key>
ROPSTEN_DEPLOYER_PRIV_KEY=<deployer-private-key>
Deploy to target network
yarn deploy
You might need to tweak gas in packages\hardhat\hardhat.config.js
for your network :
networks: {
...
ropsten: {
url: "https://ropsten.infura.io/v3/<infura-project-id>",
gasPrice: 10*1000000000, // default gas price might be too low
accounts: {
mnemonic: mnemonic(),
},
},
...
}
Example yaml for ropsten
testnet. You need to create accounts on infura and pinata and generate api keys.
Update file packages/react-app/.env
:
REACT_APP_PROVIDER=https://ropsten.infura.io/v3/<your-infura-project-id>
REACT_APP_NETWORK=ropsten
REACT_APP_PINATA_API_KEY=<pinata-api-key>
REACT_APP_PINATA_API_SECRET=<pinata-api-secret>
The main idea is to have fully distributed application setup, thus it worth to deploy front-end to IPFS
Build production version of react-application
yarn build
And deploy it to IPFS
yarn ipfs
In the end you would see destination address in console output, like the following:
🛰 Sending to IPFS...
📡 App deployed to IPFS with hash: QmcKXUATLnKyozrN61jbcT195ipf9aUQFTcuPmWN8SWhPG
🚀 Deployment to IPFS complete!
Use the link below to access your app:
IPFS: https://ipfs.io/ipfs/QmcKXUATLnKyozrN61jbcT195ipf9aUQFTcuPmWN8SWhPG
It is good idea to pin this url in pinata to make sure it would not disappear randomly.