Contract Name:
PicklesToken
Contract Source Code:
File 1 of 1 : PicklesToken
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract PicklesToken {
string public name = "Pickles";
string public symbol = "PICKLES";
uint8 public decimals = 18;
uint256 public totalSupply = 500_000_000 * 10**18;
address public owner;
// Distribution
uint256 public presaleSupply = (totalSupply * 40) / 100; // 40% for presale
uint256 public teamSupply = (totalSupply * 20) / 100; // 20% for team
uint256 public unlockedTeamSupply = 0; // Initially locked
uint256 public remainingSupply = totalSupply; // Remaining supply
// Token holders
mapping(address => uint256) public balanceOf;
// Team token release
uint256 public unlock90Days;
uint256 public unlock180Days;
uint256 public unlock270Days;
uint256 public unlock365Days;
mapping(uint256 => bool) public teamStageReleased;
// Presale
uint256 public tokenPrice = 0.025 ether; // Token price during presale
bool public presaleActive = true;
uint256 public tokensSold;
uint256 public minPurchase = 10 ether; // Minimum purchase
uint256 public maxPurchase = 5000 ether; // Maximum purchase
// Events
event Transfer(address indexed from, address indexed to, uint256 value);
event TokensPurchased(address indexed buyer, uint256 amount);
event TeamTokensReleased(uint256 stage, uint256 amount);
constructor() {
owner = msg.sender;
// Allocate presale tokens
balanceOf[address(this)] = presaleSupply;
remainingSupply -= presaleSupply;
// Set team tokens locked
remainingSupply -= teamSupply;
// Set team unlock times
unlock90Days = block.timestamp + 90 days;
unlock180Days = block.timestamp + 180 days;
unlock270Days = block.timestamp + 270 days;
unlock365Days = block.timestamp + 365 days;
emit Transfer(address(0), address(this), presaleSupply);
}
modifier onlyOwner() {
require(msg.sender == owner, "Not the contract owner");
_;
}
// Transfer tokens
function transfer(address to, uint256 value) external returns (bool) {
require(to != address(0), "Cannot transfer to zero address");
require(balanceOf[msg.sender] >= value, "Insufficient balance");
balanceOf[msg.sender] -= value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return true;
}
// Buy tokens during presale
function buyTokens() external payable {
require(presaleActive, "Presale is not active");
require(msg.value >= minPurchase, "Minimum purchase not met");
require(msg.value <= maxPurchase, "Maximum purchase exceeded");
uint256 tokensToBuy = (msg.value * 10**decimals) / tokenPrice;
require(tokensToBuy <= balanceOf[address(this)], "Not enough tokens available");
balanceOf[address(this)] -= tokensToBuy;
balanceOf[msg.sender] += tokensToBuy;
tokensSold += tokensToBuy;
emit TokensPurchased(msg.sender, tokensToBuy);
}
// End presale
function endPresale() external onlyOwner {
presaleActive = false;
uint256 unsoldTokens = balanceOf[address(this)];
balanceOf[address(this)] = 0;
balanceOf[owner] += unsoldTokens;
emit Transfer(address(this), owner, unsoldTokens);
}
// Release team tokens in stages
function releaseTeamTokens(uint256 stage) external onlyOwner {
require(stage >= 1 && stage <= 4, "Invalid stage");
require(!teamStageReleased[stage], "Stage already released");
uint256 amount = teamSupply / 4; // 5% of total supply in each stage
if (stage == 1) {
require(block.timestamp >= unlock90Days, "90 days not passed");
} else if (stage == 2) {
require(block.timestamp >= unlock180Days, "180 days not passed");
} else if (stage == 3) {
require(block.timestamp >= unlock270Days, "270 days not passed");
} else if (stage == 4) {
require(block.timestamp >= unlock365Days, "365 days not passed");
}
teamStageReleased[stage] = true;
unlockedTeamSupply += amount;
balanceOf[owner] += amount;
emit TeamTokensReleased(stage, amount);
emit Transfer(address(0), owner, amount);
}
}