Using Hardhat
Setting up and launching an DRC20 Token Smart Contract on the Deelance Testnet using Hardhat.
Last updated
$ npx hardhat
888 888 888 888 888
888 888 888 888 888
888 888 888 888 888
8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888
888 888 "88b 888P" d88" 888 888 "88b "88b 888
888 888 .d888888 888 888 888 888 888 .d888888 888
888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.
888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888
Welcome to Hardhat v2.17.1
? What do you want to do? …
▸ Create a JavaScript project
Create a TypeScript project
Create an empty hardhat.config.js
Quitnpm install --save-dev "hardhat@^2.17.1" "@nomicfoundation/hardhat-toolbox@^3.0.0"$ npx hardhat
Hardhat version 2.17.1
Usage: hardhat [GLOBAL OPTIONS] <TASK> [TASK OPTIONS]
GLOBAL OPTIONS:
--config A Hardhat config file.
--emoji Use emoji in messages.
--flamegraph Generate a flamegraph of your Hardhat tasks
--help Shows this message, or a task's help if its name is provided
--max-memory The maximum amount of memory that Hardhat can use.
--network The network to connect to.
--show-stack-traces Show stack traces (always enabled on CI servers).
--tsconfig A TypeScript config file.
--typecheck Enable TypeScript type-checking of your scripts/tests
--verbose Enables Hardhat verbose logging
--version Shows hardhat's version.
AVAILABLE TASKS:
check Check whatever you need
clean Clears the cache and deletes all artifacts
compile Compiles the entire project, building all artifacts
console Opens a hardhat console
coverage Generates a code coverage report for tests
flatten Flattens and prints contracts and their dependencies. If no file is passed, all the contracts in the project will be flattened.
gas-reporter:merge
help Prints this message
node Starts a JSON-RPC server on top of Hardhat Network
run Runs a user-defined script after compiling the project
test Runs mocha tests
typechain Generate Typechain typings for compiled contracts
verify Verifies a contract on Etherscan
To get help for a specific task run: npx hardhat help [task]project-root/
├── hardhat.config.js
├── contracts/
│ └── YourContract.sol
├── scripts/
│ └── yourScript.js
├── test/
│ └── yourTest.js
├── node_modules/
├── package.json
├── package-lock.json
└── .gitignore// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract PepeDeelance is ERC20, Ownable {
constructor() ERC20("PepeDeelance", "PEPEDLANCE") {
_mint(msg.sender, 1000000000 * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}const hre = require("hardhat");
async function main() {
console.log("Deploying Contract....");
const PepeDeelanceFactory = await hre.ethers.getContractFactory(
"PepeDeelance"
);
const PepeDeelance = await PepeDeelanceFactory.deploy();
console.log("waiting for Transaction Confirmations");
const res = await PepeDeelance.deploymentTransaction().wait(2);
console.log(`==============================`);
console.log(`Contract Deployed : ${res.contractAddress}`);
console.log(`Transaction Hash : ${res.hash}`);
console.log(`Gas Used : ${res.gasUsed}`);
console.log(`Gas Price : ${res.gasPrice}`);
console.log(`==============================`);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.19",
networks: {
deelanceTestnet: {
url: "https://testnet-rpc.deelance.com/",
chainId: 455214,
accounts: ["<PRIVATE_KEY>"],
},
},
};npx hardhat run --network deelanceTestnet scripts/deploy.js$ npx hardhat run --network deelanceTestnet scripts/deploy.js
Deploying Contract....
waiting for Transaction Confirmations
==============================
Contract Deployed : 0xFe52162DCe322Ba797FB0329b2a9409CCe29Eb32
Transaction Hash : 0xffc881d291732891006fbda071cdeF124d1a6E139bc30550daf36453411eb9bd
Gas Used : 1518972
Gas Price : 7
==============================