Say I have an ERC20 smart contract which I'm developing and testing in Hardhat:
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Erc20Token is ERC20, Ownable {
constructor(uint initialSupply) ERC20("ERC20 Token", "ETK") {
ERC20._mint(msg.sender, initialSupply);
}
}
I intend to deploy it to the RSK network with the following Hardhat deploy.js
script:
async function deploy() {
try {
const initialSupply = 1e6;
const ERC20TokenFactory = await ethers.getContractFactory('Erc20Token');
const erc20Token = await ERC20TokenFactory.deploy(initialSupply);
await erc20Token.deployed();
console.log(
`ERC20 Token was deployed on ${hre.network.name} with an address: ${erc20Token.address} `,
);
process.exit(0);
} catch (error) {
console.error(error);
process.exit(1);
}
}
deploy();
To run this script and deploy my smart contract on RSK mainnet I need to run the following command in terminal:
npx hardhat run scripts/deploy.js --network rskmainnet
However, before deploying the smart contract on a real blockchain, I would really like to know how much this deployment will cost (in EUR)! How to calculate the price of my smart contract deployment transaction on the RSK mainnet, priced in fiat?
For reference, this is the hardhat.config.js
file I'm using:
require('@nomiclabs/hardhat-waffle');
const { mnemonic } = require('./.secret.json');
module.exports = {
solidity: '0.8.4',
defaultNetwork: 'rsktestnet',
networks: {
rsktestnet: {
chainId: 31,
url: 'https://public-node.testnet.rsk.co/',
accounts: {
mnemonic,
path: "m/44'/60'/0'/0",
},
},
rskmainnet: {
chainId: 30,
url: 'https://public-node.rsk.co',
accounts: {
mnemonic,
path: "m/44'/60'/0'/0",
},
},
},
};