Meta Yield NFT
  • Meta Yield
    • Welcome to Meta Yield
  • White Paper
    • Welcome to Meta Yield
    • Meta Yield Introduction
      • What is Meta Yield?
      • Why Meta Yield
  • Meta Yield Protocol
    • Inside Meta Yield
    • Gas Fees
    • Fraud Proofs
  • Tokenomics
  • $MY Token Utility
  • Roadmap
  • Referral Commission Mechanism— Meta Yield (MY)
  • Backers and ECO Partners
  • Ecosystem
    • Airdrop
  • Brick touch game
  • Meta Yield Pools
    • Token Flow Diagram
    • ROI Projection Table
    • Dashboard UX Mockup Idea
  • BOX Meta Yield
  • Blind box + NFT
  • developer
    • Deploy contract on Meta Yield mainnet
      • Foundry
      • Hardhat
      • Remix
  • Deploy contract on Hal Testnet
    • Foundry
    • Hardhat
    • Remix
  • support
    • Official Links
Powered by GitBook
On this page
  • What is Hardhat?
  • Creating a Hardhat Project
  • Creating Your Smart Contract
  • Creating Your Configuration File
  • Deploying Your Smart Contract
  1. Deploy contract on Hal Testnet

Hardhat

What is Hardhat?

Hardhat is a development environment for Ethereum that helps developers manage and automate the common tasks involved in building smart contracts and decentralized applications. It can directly interact with Caldera's Ethereum API, allowing for the deployment of smart contracts into the Caldera network.Additionally, Hardhat is a comprehensive set of tools for creating Ethereum-based software, which includes various components that aid in editing, compiling, debugging, and deploying smart contracts and decentralized applications. All of these components work together to create a complete development environment.

Creating a Hardhat Project

  1. Create a directory for your project:

Copy

mkdir hardhat && cd hardhat
  1. Initialize the project, which will create a package.json file

Copy

npm init -y
  1. Install Hardhat

Copy

npm install hardhat
  1. Create a project

Copy

npx hardhat
  1. Create an empty hardhat.config.js and install the Ethers plugin to use the Ethers.js library to interact with the network.

Copy

npm install @nomiclabs/hardhat-ethers ethers

Creating Your Smart Contract

  1. Create a contracts directory

Copy

mkdir contracts && cd contracts
  1. Create your_contract.sol file in contracts directory

Copy

touch your_contract.sol

Creating Your Configuration File

Modify the Hardhat configuration file and create a secure file to store your private key in.

  1. Create a secrets.json file to store your private key

Copy

touch secrets.json
  1. Add your private key to secrets.json

Copy

{    "privateKey": "YOUR-PRIVATE-KEY-HERE"}
  1. Add the file to your project's .gitignore, and never reveal your private key.

  2. Modify the hardhat.config.js file

  • Import the Ethers.js plugin

  • Import the secrets.json file

  • Inside the module.exports add the Caldera network configuration

Copy

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]    },    Hal: {        url: "https://hal.rpc.caldera.xyz/http",  // RPC URL Here        chainId: 10241025 , // ChainID Here    }},}

Deploying Your Smart Contract

  1. Compile the contract

Copy

npx hardhat compilejs
  1. Create a new directory for the script and name it scripts and add a new file to it called deploy.js

Copy

mkdir scripts && cd scriptstouch deploy.js
  1. Create a deployment script, like the one below

Copy

async function main() {// 1. Get the contract to deployconst Your_Contract = await ethers.getContractFactory('your_contract');console.log('Deploying Your_Contract...'); // 2. Instantiating a new smart contractconst your_contract = await Your_Contract.deploy(); // 3. Waiting for the deployment to resolveawait your_contract.deployed(); // 4. Use the contract instance to get the contract addressconsole.log('Your_Contract deployed to:', your_contract.address);} main().then(() => process.exit(0)).catch((error) => {    console.error(error);    process.exit(1);});
  1. Deploy your_contract.sol using the command below

Copy

npx hardhat run scripts/deploy.js --network Hal
PreviousFoundryNextRemix

Last updated 1 month ago