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.
- 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.
To use or modify this contract, follow these steps:
git clone https://github.com/your-repo/protocoin.git
cd protocoin
- Ensure you have Node.js and npm installed, then run:
npm install
To deploy and interact with the ProtoCoin contract:
npx hardhat compile
- 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); });
- Run the deployment script:
npx hardhat run scripts/deploy.js --network <network-name>
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
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.
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.
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.
solidity modifier restricted() { require(msg.sender == _owner, "Restricted to owner"); _; }
This modifier restricts certain functions to be called only by the contract owner.
This project is licensed under the MIT License.
Frontend project: https://github.com/FranciscoCosta/Faucet-Protocoin
Backend project: https://github.com/FranciscoCosta/Backend-ProtoCoin