🟢Build on Truffle

Example Deployment Script (Using Truffle)

const AveToken = artifacts.require("AveToken");

module.exports = function (deployer) {
  deployer.deploy(AveToken);
};

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.

Last updated