Skip to content

A project to create a token that follows protocol BEP-20

Notifications You must be signed in to change notification settings

FranciscoCosta/ProtoCoin

Repository files navigation

ProtoCoin (PRT)

Introduction

ProtoCoin is an ERC-20 token implemented in Solidity using the OpenZeppelin library. It includes minting functionality that allows the owner to mint tokens to specified addresses with a configurable delay between mint operations.

Features

  • ERC-20 Token: Implements the standard ERC-20 functionality using the OpenZeppelin library.
  • Initial Supply: The contract deployer is assigned an initial supply of 1,000,000 PRT tokens.
  • Minting: The contract owner can mint tokens to any address, with a configurable mint amount and delay between mint operations.

Installation

To use or modify this contract, follow these steps:

  1. git clone https://github.com/your-repo/protocoin.git
  2. cd protocoin
  3. Ensure you have Node.js and npm installed, then run: npm install

Usage

To deploy and interact with the ProtoCoin contract:

  1. npx hardhat compile
  2. Create a deployment script (e.g., scripts/deploy.js) and deploy the contract:
javascript async function main() { const [deployer] = await ethers.getSigners(); const ProtoCoin = await ethers.getContractFactory("ProtoCoin"); const protoCoin = await ProtoCoin.deploy(); await protoCoin.deployed(); console.log("ProtoCoin deployed to:", protoCoin.address); } main() .then(() => process.exit(0)) .catch((error) => { console.error(error); process.exit(1); }); 
  1. Run the deployment script: npx hardhat run scripts/deploy.js --network <network-name>

Interact with the Contract

Use a script or a frontend to interact with the deployed contract. Example of minting tokens:

javascript const protoCoin = await ethers.getContractAt("ProtoCoin", deployedAddress); await protoCoin.setMintAmount(100 * 10 ** 18); // Set mint amount await protoCoin.mint(recipientAddress); // Mint tokens 

Contract Details

Constructor

solidity constructor() ERC20("ProtoCoin", "PRT") { _owner = msg.sender; _mint(msg.sender, 1000000 * 10 ** decimals()); } 

The constructor initializes the token with the name "ProtoCoin" and the symbol "PRT". It also assigns an initial supply of 1,000,000 tokens to the deployer.

Minting

solidity function mint(address to) public restricted { require(_mintAmount > 0, "Mint amount is not enable"); require(block.timestamp >= nextMint[to], "Mint is not allowed yet"); _mint(to, _mintAmount); nextMint[to] = uint64(block.timestamp + _mintDelay); } 

The mint function allows the owner to mint tokens to a specified address. The mint amount and delay between mint operations can be configured by the owner.

Owner-Only Functions

solidity function setMintAmount(uint256 amount) public restricted { _mintAmount = amount; } function setMintDelay(uint64 delay) public restricted { _mintDelay = delay; } 

These functions allow the owner to set the mint amount and delay between mint operations.

Restricted Modifier

solidity modifier restricted() { require(msg.sender == _owner, "Restricted to owner"); _; } 

This modifier restricts certain functions to be called only by the contract owner.

License

This project is licensed under the MIT License.

References

Frontend project: https://github.com/FranciscoCosta/Faucet-Protocoin

Backend project: https://github.com/FranciscoCosta/Backend-ProtoCoin

About

A project to create a token that follows protocol BEP-20

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published