🟢Build on Truffle
Example Deployment Script (Using Truffle)
Explanation
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.
Contract Definition:
AveToken
: The main contract that inherits functionalities fromERC20
andOwnable
.
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.
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.
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:
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.
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.
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.
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