Verified contractExactMIT
PupedFactory
Address0xcb63092a77637e97eb67f115fc98c0ddcf85da17
- Balance
0 ETH
- Transactions
5
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- shanghai
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,004,815
- Creation transaction
- 0x56ea414b7f…d06610fe3c
contracts/pupedfactoryerc20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// ============================================================
// VanityFactory + VanityToken 🎯
// Every token this factory deploys gets a contract address that
// ENDS IN 000 (last 3 hex chars are zero, e.g. 0x....abc000).
//
// How: CREATE2 with an on-chain mined salt. deployToken loops the
// salt, predicts the CREATE2 address, and stops at the first one
// ending in 000, then deploys there. Expected ~4096 tries (cheap).
//
// deployToken(name, symbol, supply, to) keeps the SAME 4-arg shape
// as the plain factory, so it drops into the launchpad unchanged.
//
// VanityToken is a CLEAN ERC-20: no tax, no owner, no mint, no freeze.
// ============================================================
contract PupedToken {
string public name;
string public symbol;
uint8 public constant decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(string memory _name, string memory _symbol, uint256 _supply, address _to) {
name = _name; symbol = _symbol; totalSupply = _supply;
balanceOf[_to] = _supply; emit Transfer(address(0), _to, _supply);
}
function transfer(address to, uint256 v) external returns (bool) { _t(msg.sender, to, v); return true; }
function approve(address sp, uint256 v) external returns (bool) { allowance[msg.sender][sp] = v; emit Approval(msg.sender, sp, v); return true; }
function transferFrom(address f, address to, uint256 v) external returns (bool) {
uint256 a = allowance[f][msg.sender];
if (a != type(uint256).max) { require(a >= v, "allow"); allowance[f][msg.sender] = a - v; }
_t(f, to, v); return true;
}
function _t(address f, address to, uint256 v) internal {
require(to != address(0), "zero"); uint256 b = balanceOf[f]; require(b >= v, "bal");
unchecked { balanceOf[f] = b - v; balanceOf[to] += v; } emit Transfer(f, to, v);
}
}
contract PupedFactory {
event TokenCreated(address indexed token, address indexed creator, string name, string symbol, uint256 supply, uint256 salt);
address[] public allTokens;
// set how many trailing hex zeros you want (3 = ends in 000). Cap kept small so gas stays sane.
uint256 public constant TRAILING = 0xfff; // 0xfff = last 3 hex chars must be 0
uint256 public constant MAX_TRIES = 300000; // safety bound (avg needed ~4096)
function deployToken(
string calldata name,
string calldata symbol,
uint256 supply,
address to
) external returns (address token) {
require(supply > 0, "supply=0");
address recipient = to == address(0) ? msg.sender : to;
bytes memory initcode = abi.encodePacked(
type(PupedToken).creationCode,
abi.encode(name, symbol, supply, recipient)
);
bytes32 ih = keccak256(initcode);
// mine a salt whose CREATE2 address ends in 000
uint256 salt = 0;
address predicted;
while (true) {
predicted = _predict(bytes32(salt), ih);
if (uint256(uint160(predicted)) & TRAILING == 0) break;
unchecked { salt++; }
require(salt < MAX_TRIES, "no vanity");
}
assembly {
token := create2(0, add(initcode, 0x20), mload(initcode), salt)
}
require(token != address(0) && token == predicted, "create2 failed");
allTokens.push(token);
emit TokenCreated(token, msg.sender, name, symbol, supply, salt);
}
function _predict(bytes32 salt, bytes32 initCodeHash) internal view returns (address) {
return address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, initCodeHash)))));
}
// helper: preview the address a given salt+params would produce (off-chain use)
function computeAddress(bytes32 salt, string calldata name, string calldata symbol, uint256 supply, address to) external view returns (address) {
address recipient = to == address(0) ? msg.sender : to;
bytes32 ih = keccak256(abi.encodePacked(type(PupedToken).creationCode, abi.encode(name, symbol, supply, recipient)));
return _predict(salt, ih);
}
function totalTokens() external view returns (uint256) { return allTokens.length; }
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "shanghai",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.