116 lines
3.5 KiB
Solidity
116 lines
3.5 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
import {Script} from "forge-std/Script.sol";
|
|
import {console} from "forge-std/console.sol";
|
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
import "@openzeppelin/contracts/security/Pausable.sol";
|
|
|
|
/**
|
|
* @title Governance Token
|
|
* @notice ERC20 token for DAO governance and protocol incentives
|
|
* @dev Supports minting for rewards and burning for deflation
|
|
*/
|
|
contract GovernanceToken is ERC20, Ownable, Pausable {
|
|
uint256 public constant MAX_SUPPLY = 1_000_000_000 * 10**18; // 1 billion tokens
|
|
uint256 public totalMinted;
|
|
|
|
constructor(
|
|
address initialOwner,
|
|
string memory name,
|
|
string memory symbol
|
|
) ERC20(name, symbol) {
|
|
_transferOwnership(initialOwner);
|
|
}
|
|
|
|
/**
|
|
* @notice Mint new tokens (only owner)
|
|
* @param to Address to mint to
|
|
* @param amount Amount to mint
|
|
*/
|
|
function mint(address to, uint256 amount) external onlyOwner {
|
|
require(totalMinted + amount <= MAX_SUPPLY, "GovernanceToken: exceeds max supply");
|
|
totalMinted += amount;
|
|
_mint(to, amount);
|
|
}
|
|
|
|
/**
|
|
* @notice Burn tokens from caller
|
|
* @param amount Amount to burn
|
|
*/
|
|
function burn(uint256 amount) external {
|
|
_burn(msg.sender, amount);
|
|
}
|
|
|
|
/**
|
|
* @notice Burn tokens from specified address (only owner)
|
|
* @param from Address to burn from
|
|
* @param amount Amount to burn
|
|
*/
|
|
function burnFrom(address from, uint256 amount) external onlyOwner {
|
|
_burn(from, amount);
|
|
}
|
|
|
|
/**
|
|
* @notice Pause token transfers (only owner)
|
|
*/
|
|
function pause() external onlyOwner {
|
|
_pause();
|
|
}
|
|
|
|
/**
|
|
* @notice Unpause token transfers (only owner)
|
|
*/
|
|
function unpause() external onlyOwner {
|
|
_unpause();
|
|
}
|
|
|
|
function _beforeTokenTransfer(
|
|
address from,
|
|
address to,
|
|
uint256 amount
|
|
) internal override whenNotPaused {
|
|
super._beforeTokenTransfer(from, to, amount);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title DeployGovernanceToken
|
|
* @notice Deployment script for governance token
|
|
*/
|
|
contract DeployGovernanceToken is Script {
|
|
function run() external {
|
|
address deployer = msg.sender;
|
|
address owner = vm.envOr("GOV_TOKEN_OWNER", deployer);
|
|
string memory name = vm.envOr("GOV_TOKEN_NAME", string("DBIS Token"));
|
|
string memory symbol = vm.envOr("GOV_TOKEN_SYMBOL", string("DBIS"));
|
|
uint256 initialSupply = vm.envOr("GOV_TOKEN_INITIAL_SUPPLY", uint256(0));
|
|
|
|
console.log("Deploying Governance Token...");
|
|
console.log("Deployer:", vm.toString(deployer));
|
|
console.log("Owner:", vm.toString(owner));
|
|
console.log("Name:", name);
|
|
console.log("Symbol:", symbol);
|
|
console.log("Initial Supply:", initialSupply);
|
|
|
|
vm.startBroadcast();
|
|
|
|
GovernanceToken token = new GovernanceToken(owner, name, symbol);
|
|
|
|
if (initialSupply > 0) {
|
|
token.mint(owner, initialSupply);
|
|
}
|
|
|
|
vm.stopBroadcast();
|
|
|
|
console.log("Governance Token deployed at:", vm.toString(address(token)));
|
|
console.log("Name:", token.name());
|
|
console.log("Symbol:", token.symbol());
|
|
console.log("Decimals:", token.decimals());
|
|
console.log("Total Supply:", token.totalSupply());
|
|
console.log("Max Supply:", token.MAX_SUPPLY());
|
|
}
|
|
}
|
|
|