Hardhat
Deploying Smart Contracts using Hardhat
Last updated
touch your_contract.soltouch secrets.json{
"privateKey": "YOUR-PRIVATE-KEY-HERE"
}//hardhat.config.js
require('@nomiclabs/hardhat-ethers');
const { privateKey } = require('./secrets.json');
module.exports = {
solidity: "0.8.1",
defaultNetwork: "rinkeby",
networks: {
rinkeby: {
url: "https://eth-rinkeby.alchemyapi.io/v2/123abc123abc123abc123abc123abcde",
accounts: [privateKey]
},
atletaOlympia: {
url: "https://testnet-rpc.atleta.network", // Insert your RPC URL Here
chainId: 2340, //Insert your ChainID Here
}
},
}npx hardhat compilejsmkdir scripts && cd scripts
touch deploy.js// scripts/deploy.js
async function main() {
// 1. Get the contract to deploy
const Your_Contract = await ethers.getContractFactory('your_contract');
console.log('Deploying Your_Contract...');
// 2. Instantiating a new smart contract
const your_contract = await Your_Contract.deploy();
// 3. Waiting for the deployment to resolve
await your_contract.deployed();
// 4. Use the contract instance to get the contract address
console.log('Your_Contract deployed to:', your_contract.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});npx hardhat run scripts/deploy.js --network atletaOlympia