MetaNova Verse Documentation
  • MetaNova Verse Introduction
    • Metanovaverse
    • Tokens
    • Transactions
    • Inflation
    • Keys
      • Keyring
      • Multisig
    • Gas Fees
    • Wallet and Accounts
      • Adding Metanovaverse to Metamask
      • Adding Metanovaverse to Keplr
      • Transfers Between Wallets
      • Backup
    • Deploying Smart Contracts
      • Remix
      • Hardhat
  • Metanovaverse Summary
  • The MNV Token
  • Governance
    • Proposals
      • Proposal Tips
      • Submit a Proposal
    • Community Pool
    • Chain Parameters
  • Technical Concepts
    • Architecture
    • Accounts
    • Chain ID
    • Encoding
    • Pending State
  • dApp Developers
    • Establishing Connections
    • Metanovaverse Clients
    • Guides
      • Wallet Integration
      • Smart Contract Incentive Registration
      • Tracing Transactions
      • Query Balances
    • Testnet
      • Testnet Commands
    • Ethereum JSON-RPC
      • JSON-RPC Server
      • Running the Server
      • Namespaces
      • JSON-RPC Methods
      • Events
  • Protocol Developers
    • Modules
      • auth
        • Concepts
        • State
        • AnteHandlers
        • Keepers
        • Vesting
        • Parameters
        • Client Auth
      • bank
        • State
        • Keepers
        • Messages
        • Events
        • Parameters
        • Client
      • crisis
        • State
        • Messages
        • Events
        • Parameters
        • Client
      • distribution
        • Concepts
        • State
        • Begin Block
        • Messages
        • Hooks
        • Events
        • Parameters
        • Client
      • epochs
        • Concepts
        • State
        • Events
        • Keepers
        • Hooks
        • Queries
        • Future Improvements
      • erc20
        • Concepts
        • State
        • State Transitions
        • Transactions
        • Hooks
        • Events
        • Parameters
        • Clients
      • evidence
        • Concepts
        • State
        • Messages
        • Events
        • Parameters
        • BeginBlock
        • Client
      • evm
        • Concepts
        • State
        • State Transitions
        • Transactions
        • ABCI
        • Hooks
        • Events
        • Parameters
        • Client
      • feemarket
        • Concepts
        • State
        • Begin block
        • End block
        • AnteHandlers
        • Keeper
        • Events
        • Client
        • Future Improvements
        • Parameters
      • feesplit
        • Concepts
        • State
        • State Transitions
        • Transactions
        • Hooks
        • Events
        • Parameters
        • Clients
        • Future Improvements
      • gov
        • Concepts
        • State
        • Messages
        • Events
        • Future Improvements
        • Parameters
        • Client
      • incentives
        • Concepts
        • State
        • State Transitions
        • Transactions
        • Hooks
        • Events
        • Parameters
        • Clients
      • ibc-core
      • inflation
        • Concepts
        • State
        • Hooks
        • Events
        • Parameters
        • Clients
      • slashing
        • Concepts
        • State
        • Messages
        • BeginBlock
        • Hooks
        • Events
        • Staking Tombstone
        • Parameters
        • CLI
      • staking
        • State
        • State Transitions
        • Messages
        • Begin-Block
        • End-Block
        • Hooks
        • Events
        • Parameters
        • Client
      • upgrade
        • Concepts
        • State
        • Events
        • Client
        • Resources
      • vesting
        • Concepts
        • State
        • State Transitions
        • Transactions
        • AnteHandlers
        • Events
        • Clients
  • Validators
    • Quick Start
    • Telemetry
    • Security
      • Tendermint KMS
      • Tendermint KMS + Ledger
      • Validator Security Checklist
      • Validator Backup
    • Snapshots, Archive Nodes
    • FAQ
  • Delegators
    • Staking Process
  • Tokenomics
  • Block Explorers
Powered by GitBook
On this page
  1. MetaNova Verse Introduction
  2. Deploying Smart Contracts

Hardhat

PreviousRemixNextMetanovaverse Summary

Last updated 8 months ago

is another essential tool that should be found in every dApp developer's arsenal. Hardhat allows seamless deployment of smart contracts, running of tests, and debugging outside of live environments.

One of the biggest advantages of Hardhat is its flexibility - there is a series of plugins available for different types of developers, and Hardhat's extensible ecosystem allows for efficient tooling.

This guide assumes that the reader has at least some familiarity with the Solidity programming language for smart contracts, and general dApp development on the Ethereum network.

The following is a short guide for deploying a smart contract using Hardhat. The best solution is to use a development environment like VSCode for an optimal deployment experience.

1. First of all, make sure you have HardHat set up on your local machine. Check out this guide if you encounter problems:

2. There are 3 files that you will have to edit. First, create a Solidity file under the contracts folder. You can right click on the folder and create a new file. For this example, we named it HHToken.sol

3. Paste this piece of simple contract code in your HHToken.sol equivalent file:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";\

contract HHToken is ERC20, ERC20Burnable, Ownable {
    
    constructor() ERC20("HHToken", "HHT") {
        _mint(msg.sender, 1000 * 10 ** 18);
    }
    
    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

4. Once you’re done, go to the scripts folder, then look for deploy.js. As part of the setting up Hardhat, there are already some lines in the that file. You will just have to edit some variables like the ones below:

const hre = require("hardhat");

async function main() {

    const Token = await hre.ethers.getContractFactory("HHToken");
    const token = await Token.deploy();
    await token.deployed();

    console.log("Token deployed to:", token.address);
}

main()
  .then(() => process.exit(0));
  .catch((error) => {
    console.error(error);
    process.exit(1);
});

Make sure that for getContractFactory you enter the contract name of your token.

5. Once you have entered your contract name, go to the main folder and look for the file named hardhat.config.js. Enter the Metanovaverse Network details:

  • RPC: https://web3.metanovaverse.com

  • Chain ID: 10096

module.exports = {
  defaultNetwork: "Metanovaverse",
  networks: {
    blockx: {
      url: "https://web3.metanovaverse.com",
      chainId: 10096,
      gasPrice: 2000000000,
      accounts: [privKey]
    },

For the accounts, we stored our private key to a variable and named it privKey. You can also put your private key there. This private key should belong to the account of the one who deploys the contract, so make sure it has some MNV tokens.

6. Open the Terminal in your VSCode so you can enter a deployment command like the following:

npx hardhat run --network metanovaverse scripts/deploy.js 

We named the network metanovaverse in the hardhat.config.js file, which is why we used metanovaverse after the –-network flag.

7. You should now see an output like this:

That’s it, you’ve successfully deployed your token using Hardhat on the Metanovaverse Network!

Hardhat
https://hardhat.org/hardhat-runner/docs/guides/project-setup