Contract
Key Improvements in the Contract
Gas Optimization
Our Contract
/* SPDX-License-Identifier: MIT
Shenlong: An ERC20 memecoin the Avalanche C-Chain, designed for community engagement and cultural celebration.
Shenlong meme token project inspired by the Shenlong dragon from Chinese mythology, symbolizing prosperity and renewal.
Intended for entertainment and educational purposes only.
Ticker: SHEN
Twitter/X: https://twitter.com/shenlongavax
Telegram: https://t.me/shenlongavax
Website: https://shenlong.gitbook.io
*/
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Shenlong is ERC20, Ownable(msg.sender) {
// Launch Control Flag: Controls the anti-whale mechanism in the initial phase after launch.
bool public launchControl = true;
address public liquidityPool;
address private treasury;
uint256 private maxWalletAllowance;
// Constants for tokenomics
uint256 private constant TOKEN_DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 1_000_000_000_000 * (10 ** TOKEN_DECIMALS); // 1 trillion tokens
// Constructor: Mints the initial supply of Shenlong tokens to the deployer's address.
constructor() ERC20("Shenlong", "SHEN") {
// Minting 1 trillion SHEN tokens (with 18 decimals) to the deployer's address.
_mint(msg.sender, TOTAL_SUPPLY);
}
// Set LaunchControl State: Allows the owner to toggle the launch control mechanism on or off.
function setLaunchControl(bool _state) external onlyOwner {
launchControl = _state;
}
// Set Liquidity Pool Address: Define the address for the liquidity pool to enable trading.
function setLiquidityPool(address _liquidityPool) external onlyOwner {
liquidityPool = _liquidityPool;
}
// Set Treasury Address: Define the address for the treasury for fund management.
function setTreasury(address _treasury) external onlyOwner {
treasury = _treasury;
}
// Get max amount per wallet value
function showMaxWalletAllowance() external view returns (uint256) {
return maxWalletAllowance;
}
// UUID: 6d68e868-8e07-4f15-8603-0d2340cdc7c4. This identifier is for version tracking.
// Adjusts the anti-sniping threshold. The `antiSnipeThreshold` (e.g., 1000 for 1%) sets the max tokens
// a wallet can hold as a percentage of total supply, preventing large initial accumulations.
function setSniperControl(uint32 antiSnipeThreshold) external onlyOwner {
maxWalletAllowance = (totalSupply() * antiSnipeThreshold) / (1000 * 100);
}
// Override _update Function: Includes the logic for the launch control phase and sniper protection.
function _update(
address from,
address to,
uint256 amount
) internal virtual override {
super._update(from, to, amount);
// Early exit if launch control is not active, allowing normal ERC20 transfer behavior.
if (!launchControl) {
return;
}
// Check if liquidityPool is not set (address(0)). If so, restrict token transfers to
// the owner only, typically used during initial setup or pre-launch phase.
if(liquidityPool == address(0)) {
require(from == owner() || to == owner(), "Trading is currently disabled. Please wait for the official launch.");
return;
}
// Special transfer allowances during launch control phase:
// - Owner is allowed to send and receive tokens without restrictions.
// - Liquidity pool can receive tokens to facilitate selling tokens into the LP.
// These exemptions are necessary to set up and manage the token's initial distribution and liquidity.
bool isOwnerSending = from == owner();
bool isLiquidityPoolReceiving = to == liquidityPool;
bool isLiquidityPoolSending = from == liquidityPool;
bool isTreasuryReceiving = to == treasury;
if (!isOwnerSending && !isLiquidityPoolReceiving && (!isLiquidityPoolSending || !isTreasuryReceiving)) {
require(balanceOf(to) <= maxWalletAllowance, "Wallet balance exceeds sniper protection limits. Please reduce the token amount.");
}
}
// Renounce Token Ownership: Permanently transfer ownership to the zero address, locking the contract.
function renounceTokenOwnership() public onlyOwner {
renounceOwnership();
}
}
/*
DISCLAIMER:
Shenlong ($SHEN) is a meme coin with no intrinsic value or expectation of financial return.
It is created for entertainment and educational purposes only.
It is not intended to represent or imply any intrinsic value, financial return, or investment opportunity.
Holders and potential users should understand that memecoins are highly speculative and volatile in nature.
They should exercise caution and perform their own due diligence.
The creators and developers of Shenlong assume no responsibility for any loss or damages incurred as a result of using, holding, or trading $SHEN.
Participation in the Shenlong ecosystem is at your own risk, and it is crucial to be aware of the regulatory environment of your jurisdiction before engaging with this or any similar digital asset.
*/Last updated