Avenium Documents
  • 🟢Welcome to Avenium Documents
  • 🟢What is EVM in Avenium
  • 🟢About Proof of Authority
  • 🟢How Avenium Blockchain Works
  • 🟢About AVE Coin
    • 🔹Tokenomic Ave Coin
  • ⛓️How To Connect Ave Chain
  • 🟢Build on Ave Chain
    • 🟢Build on Truffle
    • 🟢Build on Hardhat
    • 🟢Verifying with Hardhat or Truffle
    • 🟢Verifying Using Remix Ethereum
  • 🔵Deploy At Avenium
  • 📑Smart Contract Tools
  • 🟢Blockchain Security Scheme
  • 🟢Avenium is Secure
  • Aveswap
    • 🅰️Aveswap Smart Contract
    • 🔰Terms of Service (TOS) for Aveswap
Powered by GitBook
On this page
  1. Build on Ave Chain

Build on Hardhat

Example Deployment Script (Using Hardhat)

Example Deployment Script (Using Hardhat)

async function main() {
  const AveToken = await ethers.getContractFactory("AveToken");
  const token = await AveToken.deploy();
  await token.deployed();
  console.log("AveToken deployed to:", token.address);
}

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

Explanation

  1. Import Statements:

    • ERC20.sol: This is the standard implementation of the ERC-20 token standard provided by OpenZeppelin, a library of reusable and secure smart contract components.

    • Ownable.sol: This module provides basic access control, where there is an account (an owner) that can be granted exclusive access to specific functions.

  2. Contract Definition:

    • AveToken: The main contract that inherits functionalities from ERC20 and Ownable.

  3. Constructor:

    • Initializes the token with a name ("Ave Token") and a symbol ("AVE").

    • Mints an initial supply of tokens (1,000,000 AVE) to the address that deploys the contract.

  4. Mint Function:

    • Allows the owner of the contract to create new tokens and assign them to a specified address.

    • The onlyOwner modifier ensures that only the contract owner can call this function.

  5. Burn Function:

    • Allows the owner to destroy a specified amount of tokens from a given address.

    • The onlyOwner modifier ensures that only the contract owner can call this function.

Deployment and Usage

To deploy and use this contract on the Avenium Blockchain, follow these steps:

  1. Set Up Your Development Environment:

    • Install Node.js and npm.

    • Install Truffle or Hardhat for contract deployment and testing.

    • Install MetaMask and configure it for Avenium Blockchain.

  2. Write and Compile the Contract:

    • Save the above contract code in a file named AveToken.sol.

    • Compile the contract using Truffle or Hardhat to ensure there are no syntax errors.

  3. Deploy the Contract:

    • Write a deployment script that deploys the AveToken contract.

    • Use your development environment to deploy the contract to the Avenium testnet or mainnet.

  4. Interact with the Contract:

    • Use MetaMask to interact with your deployed contract.

    • Test the minting and burning functions to ensure they work as expected.

PreviousBuild on TruffleNextVerifying with Hardhat or Truffle

Last updated 11 months ago

🟢
🟢