Address Contract Verified
Address
0x28be3d3ea9deb58f492C76d2cB4cB4Ab3C573C7B
Balance
0 ETH
Nonce
2
Code Size
7220 bytes
Creator
0xCA90D843...c7cB at tx 0x55577e20...705d08
Indexed Transactions
0
Contract Bytecode
7220 bytes
0x6080604052600436101562000012575f80fd5b5f803560e01c90816351d11c20146200004d575080635cc1926214620000475763c45a01551462000041575f80fd5b6200026e565b620001d8565b346200011d576200005e3662000155565b6001600160a01b03989790959194929392917f000000000000000000000000149bd5c2fc1ea9241e4e90548eb5c8cc3d1549e68a1633036200010c57620000b0620000b992620000c0993691620002eb565b923691620002eb565b9062000398565b60208151910184f591823b1562000103575b50811615620000f1576040516001600160a01b03919091168152602090f35b604051633011642560e01b8152600490fd5b915082620000d2565b631966391b60e11b60805260046080fd5b80fd5b9181601f84011215620001515782359167ffffffffffffffff83116200015157602083818601950101116200015157565b5f80fd5b9060e060031983011262000151576004359167ffffffffffffffff916024358381116200015157826200018b9160040162000120565b939093926044359182116200015157620001a89160040162000120565b90916064356001600160a01b03811681036200015157906084359060a4359060c43560ff81168103620001515790565b346200015157620000b062000208620000b9620001f53662000155565b98939492959a919690979a3691620002eb565b6020815191012060405190602082019260ff60f81b84523060601b60218401526035830152605582015260558152608081019080821067ffffffffffffffff83111762000268576040829052519091206001600160a01b03168152602090f35b620002b4565b3462000151575f36600319011262000151576040517f000000000000000000000000149bd5c2fc1ea9241e4e90548eb5c8cc3d1549e66001600160a01b03168152602090f35b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176200026857604052565b92919267ffffffffffffffff821162000268576040519162000318601f8201601f191660200184620002c8565b82948184528183011162000151578281602093845f960137010152565b5f5b838110620003475750505f910152565b818101518382015260200162000337565b90602091620003738151809281855285808601910162000335565b601f01601f1916010190565b90620003946020928281519485920162000335565b0190565b6200045e620003f4916200047693959460ff6200046f9962000483996117789860405199620003cb602082018c620002c8565b808b526200048760208c01396200040860405198899760e060208a015261010089019062000358565b601f199c8d8983030160408a015262000358565b6001600160a01b0395861660608801527f000000000000000000000000149bd5c2fc1ea9241e4e90548eb5c8cc3d1549e6909516608087015260a086015260c08501521660e083015203858101835282620002c8565b60405195869360208501906200037f565b906200037f565b03908101835282620002c8565b9056fe608060405234620004965762001778803803806200001d816200049a565b92833981019060e081830312620004965780516001600160401b0381116200049657826200004d918301620004c0565b602082015190926001600160401b038211620004965762000070918301620004c0565b916200007f6040830162000530565b916200008e6060820162000530565b60808201519360c060a08401519301519360ff85168503620004965760015f558051906001600160401b038211620003725760045490600182811c921680156200048b575b6020831014620003535781601f8493116200041b575b50602090601f831160011462000392575f9262000386575b50508160011b915f199060031b1c1916176004555b85516001600160401b03811162000372576005908154600181811c9116801562000367575b60208210146200035357601f81116200030b575b506020601f8211600114620002a057819060ff98995f9262000294575b50508160011b915f199060031b1c19161790555b75c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000062010000600160b01b0319600d541617600d5560018060a01b031991739a27cb5ae0b2cee0bb71f9a85c0d60f3920757b483600e541617600e5560018060a01b0380921683600654161760065516906007541617600755836008556009551660ff19600a541617600a5530156200027c576003548181018091116200026857600355305f52600160205260405f208181540190556040519081525f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203093a36040516112329081620005468239f35b634e487b7160e01b5f52601160045260245ffd5b60405163ec442f0560e01b81525f6004820152602490fd5b015190505f806200016c565b601f19821698835f5260205f20995f5b818110620002f257509160ff999a91846001959410620002d9575b505050811b01905562000180565b01515f1960f88460031b161c191690555f8080620002cb565b838301518c556001909b019a60209384019301620002b0565b825f5260205f20601f8301841c8101916020841062000348575b601f01841c01905b8181106200033c57506200014f565b5f81556001016200032d565b909150819062000325565b634e487b7160e01b5f52602260045260245ffd5b90607f16906200013b565b634e487b7160e01b5f52604160045260245ffd5b015190505f8062000101565b60045f9081527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b9350601f198516905b818110620004025750908460019594939210620003e9575b505050811b0160045562000116565b01515f1960f88460031b161c191690555f8080620003da565b92936020600181928786015181550195019301620003c2565b60045f529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f840160051c81016020851062000483575b90849392915b601f830160051c8201811062000474575050620000e9565b5f81558594506001016200045c565b508062000456565b91607f1691620000d3565b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176200037257604052565b919080601f84011215620004965782516001600160401b0381116200037257602090620004f6601f8201601f191683016200049a565b9281845282828701011162000496575f5b8181106200051c5750825f9394955001015290565b858101830151848201840152820162000507565b51906001600160a01b0382168203620004965756fe6080604090808252600480361015610021575b505050361561001f575f80fd5b005b5f91823560e01c90816302d05d3f14610e595750806306fdde0314610d64578063095ea7b314610d3a57806318160ddd14610d1b578063181aa1fd14610b8f578063200d2ed214610b6b57806323b872dd14610a7a5780632c5b5ae214610a515780632d30f07a14610a2f578063313ce56714610a135780634f0e0ef3146109e6578063518ab2a8146109c75780635d3dcc74146108ab57806370a082311461087357806375298734146107695780637e1c0c091461074a5780638091f3bf146107235780638296791f1461047e57806382cb55e71461045557806395d89b4114610353578063a9059cbb14610322578063c5c4744c14610303578063c7c049fc146102e4578063dd62ed3e146102975763df8de3e7036100125734610293576020908160031936011261028f57610157610ec5565b9060018060a01b0361016e816007541633146110a5565b610176611168565b60ff600d5460081c1615610258576007548651632675e5cd60e01b8152308482019081526001600160a01b038616602082015290959283928792839003604001918391165afa93841561024e57859461021b575b5083156101e457846101dd858530610f3b565b6001815580f35b855162461bcd60e51b81529182015260126024820152714e6f20746f6b656e7320746f20636c61696d60701b604482015260649150fd5b9080945081813d8311610247575b6102338183610f19565b810103126102435751925f6101ca565b5f80fd5b503d610229565b86513d87823e3d90fd5b855162461bcd60e51b8152808301859052601160248201527014d85b19481b9bdd081b185d5b98da1959607a1b6044820152606490fd5b8280fd5b5080fd5b8284346102935780600319360112610293576020916102b4610ec5565b826102bd610edb565b6001600160a01b03928316845260028652922091165f908152908352819020549051908152f35b8284346102935781600319360112610293576020906009549051908152f35b828434610293578160031936011261029357602090600b549051908152f35b82843461029357806003193601126102935760209061034c610342610ec5565b6024359033610f3b565b5160018152f35b50823461028f578260031936011261028f57805191836005549060019082821c92828116801561044b575b6020958686108214610438575084885290811561041657506001146103bd575b6103b986866103af828b0383610f19565b5191829182610e7e565b0390f35b929550600583527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b82841061040357505050826103b9946103af92820101948661039e565b80548685018801529286019281016103e6565b60ff191687860152505050151560051b83010192506103af826103b98661039e565b634e487b7160e01b845260229052602483fd5b93607f169361037e565b82843461029357816003193601126102935760075490516001600160a01b039091168152602090f35b5091346102935760c036600319011261029357610499610ec5565b9260249081359060ff908183168093036102435760443592828416809403610243576064928335918183168093036102435760843592828416809403610243576001600160a01b0360a4358181169891959089900361024357610501866007541633146110a5565b610509611168565b600d549361051c868660081c16156110e0565b600b549461052e600954871015611124565b868116156106f3576101009061ff00191617600d556008549d8e6005810290808204600514901517156106e1578a9b9c9d9e9f610578999a9b61057d9204998a91600c54906111bc565b6111bc565b9680600a54168c038181116106cd57168681029681880414901517156106bb5790888f9796959493926105b1888230611018565b1690896006541695823b156106b7578f968f96948d958f9497610124988d9b519c8d9b8c9a637f0dfdd360e11b8c5230908c01528a01528b60448a01528b878a0152608489015260a488015260c487015260e486015261010485015204905af180156106ad57610695575b505061062c916006541630610f3b565b479384156106565750505083808093819382f11561064c57506001815580f35b51903d90823e3d90fd5b601c90602087519362461bcd60e51b85528401528201527f4e6f2062616c616e636520666f722063726561746f72207368617265000000006044820152fd5b61069e90610ef1565b6106a957875f61061c565b8780fd5b89513d84823e3d90fd5b8880fd5b8c60118b634e487b7160e01b5f52525ffd5b5050634e487b7160e01b8f5260118a528c8ffd5b634e487b7160e01b8f5260118a528c8ffd5b50508a5162461bcd60e51b8152602081890152600a818c0152691b9bdd08189bdb99195960b21b60448201528890fd5b82843461029357816003193601126102935760209060ff600d5460081c1690519015158152f35b8284346102935781600319360112610293576020906008549051908152f35b509134610293578160031936011261029357600e54600d54825163e6a4390560e01b8152308682019081526001600160a01b0360109390931c8316602080830191909152969293919291879184918616908290819060400103915afa9182156108695790869291869261083a575b5084516361047d3360e01b81529384928391165afa92831561082f5792610800575b5051908152f35b9091508281813d8311610828575b6108188183610f19565b810103126102435751905f6107f9565b503d61080e565b8251903d90823e3d90fd5b61085b919250833d8511610862575b6108538183610f19565b8101906111dd565b905f6107d7565b503d610849565b84513d87823e3d90fd5b8284346102935760203660031901126102935760209181906001600160a01b0361089b610ec5565b1681526001845220549051908152f35b5082600319360112610293576024356108cf60018060a01b036007541633146110a5565b6108d7611168565b600d54916108eb60ff8460081c16156110e0565b60ff831661099357610901600954831015611124565b81471061095d578134036109295735600c55600b5560ff19166001908117600d558155905080f35b606490602086519162461bcd60e51b8352820152600e60248201526d0acc2d8eaca40dad2e6dac2e8c6d60931b6044820152fd5b606490602086519162461bcd60e51b8352820152601060248201526f08ceadcc8d2dcce40dad2e6dac2e8c6d60831b6044820152fd5b606490602086519162461bcd60e51b8352820152600e60248201526d105b1c9958591e48189bdb99195960921b6044820152fd5b828434610293578160031936011261029357602090600c549051908152f35b828434610293578160031936011261029357600d54905160109190911c6001600160a01b03168152602090f35b8284346102935781600319360112610293576020905160128152f35b82843461029357816003193601126102935760209060ff600a54169051908152f35b828434610293578160031936011261029357600e5490516001600160a01b039091168152602090f35b503461029357606036600319011261029357610a94610ec5565b610a9c610edb565b91604435938560018060a01b03841691828152600260205220335f52602052855f2054915f198310610ad7575b60208761034c888888610f3b565b858310610b3f578115610b29573315610b1357505f9081526002602090815286822033835281529086902091859003909155829061034c610ac9565b6024905f885191634a1406b160e11b8352820152fd5b6024905f88519163e602df0560e01b8352820152fd5b8651637dc7a0d960e11b8152339181019182526020820193909352604081018690528291506060010390fd5b82843461029357816003193601126102935760209060ff600d541690519015158152f35b5082903461028f578260031936011261028f576007546001600160a01b0390610bbb90821633146110a5565b610bc3611168565b600e54600d54845163e6a4390560e01b81523085820190815260109290921c84166001600160a01b03166020808401919091529092909183918516908290819060400103915afa908115610869578591610cfd575b50168015610cc9578084913b156102935781908385518094819363666da64f60e01b83525af18015610cbc57610ca9575b5047908115610c7c57508280808093734c5fbf8d815379379b3695ba77b5d3f898c1230b82f11561064c57506001815580f35b606490602084519162461bcd60e51b835282015260076024820152664e6f206665657360c81b6044820152fd5b610cb590939193610ef1565b9183610c49565b50505051903d90823e3d90fd5b506020606492519162461bcd60e51b8352820152600e60248201526d14185a5c881b9bdd08199bdd5b9960921b6044820152fd5b610d15915060203d8111610862576108538183610f19565b85610c18565b8284346102935781600319360112610293576020906003549051908152f35b82843461029357806003193601126102935760209061034c610d5a610ec5565b6024359033611018565b509134610293578160031936011261029357805191809380549160019083821c92828516948515610e4f575b6020958686108114610e3c57858952908115610e185750600114610dc0575b6103b987876103af828c0383610f19565b81529295507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b828410610e0557505050826103b9946103af92820101945f80610daf565b8054868501880152928601928101610de7565b60ff19168887015250505050151560051b83010192506103af826103b95f80610daf565b634e487b7160e01b845260228352602484fd5b93607f1693610d90565b8390346102935781600319360112610293576006546001600160a01b03168152602090f35b602080825282518183018190529093925f5b828110610eb157505060409293505f838284010152601f8019910116010190565b818101860151848201604001528501610e90565b600435906001600160a01b038216820361024357565b602435906001600160a01b038216820361024357565b67ffffffffffffffff8111610f0557604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff821117610f0557604052565b916001600160a01b038084169283156110005716928315610fe8575f908382526001602052604082205490838210610fb6575091604082827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef95876020965260018652038282205586815220818154019055604051908152a3565b60405163391434e360e21b81526001600160a01b03919091166004820152602481019190915260448101839052606490fd5b60405163ec442f0560e01b81525f6004820152602490fd5b604051634b637e8f60e11b81525f6004820152602490fd5b6001600160a01b0390811691821561108d57169182156110755760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526002825260405f20855f5282528060405f2055604051908152a3565b604051634a1406b160e11b81525f6004820152602490fd5b60405163e602df0560e01b81525f6004820152602490fd5b156110ac57565b60405162461bcd60e51b815260206004820152600c60248201526b4f6e6c7920666163746f727960a01b6044820152606490fd5b156110e757565b60405162461bcd60e51b815260206004820152601560248201527414d85b1948185b1c9958591e481b185d5b98da1959605a1b6044820152606490fd5b1561112b57565b60405162461bcd60e51b815260206004820152601560248201527414d85b194819dbd85b081b9bdd081c995858da1959605a1b6044820152606490fd5b60025f54146111775760025f55565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b919082039182116111c957565b634e487b7160e01b5f52601160045260245ffd5b9081602091031261024357516001600160a01b0381168103610243579056fea26469706673582212201e0184b9b0712f8d42a038a3b9662d1b1a09e259991c755381db35e1af55c5a664736f6c63430008140033a26469706673582212204547e83d5257765f8b6518ad13bdd5b22acdce41e9ecfc864fc1db2735c53cfa64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: Yes (200 runs)
SaleDeployer.sol 71 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;
import "./SaleContract.sol";
contract EtherfunSaleDeployer {
error NotFactory();
error DeploymentFailed();
address public immutable factory;
constructor(address _factory) {
factory = _factory;
}
function _bytecode(
string memory name,
string memory symbol,
address creator,
uint256 totalTokens,
uint256 saleGoal,
uint8 creatorShare
) internal view returns (bytes memory) {
return abi.encodePacked(
type(EtherfunSale).creationCode,
abi.encode(
name,
symbol,
creator,
factory,
totalTokens,
saleGoal,
creatorShare
)
);
}
function predictAddress(
bytes32 salt,
string calldata name,
string calldata symbol,
address creator,
uint256 totalTokens,
uint256 saleGoal,
uint8 creatorShare
) external view returns (address) {
bytes memory bytecode = _bytecode(name, symbol, creator, totalTokens, saleGoal, creatorShare);
bytes32 initCodeHash = keccak256(bytecode);
return address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, initCodeHash)))));
}
function deploy(
bytes32 salt,
string calldata name,
string calldata symbol,
address creator,
uint256 totalTokens,
uint256 saleGoal,
uint8 creatorShare
) external returns (address deployed) {
if (msg.sender != factory) revert NotFactory();
bytes memory bytecode = _bytecode(name, symbol, creator, totalTokens, saleGoal, creatorShare);
assembly {
deployed := create2(0, add(bytecode, 32), mload(bytecode), salt)
if iszero(extcodesize(deployed)) { deployed := 0 }
}
if (deployed == address(0)) revert DeploymentFailed();
}
}
SaleContract.sol 173 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
interface IVistaFactory {
function getPair(address tokenA, address tokenB) external view returns (address);
}
interface IPair {
function claimShare() external;
function viewShare() external view returns (uint256 share);
}
interface ILaunchContract {
function launch(
address token,
uint256 amountTokenDesired,
uint256 amountETHMin,
uint256 amountTokenMin,
uint8 buyLpFee,
uint8 sellLpFee,
uint8 buyProtocolFee,
uint8 sellProtocolFee,
address protocolAddress
) external payable;
}
interface IEtherFunFactoryBalances {
function claimableBalance(address tokenAddress, address user) external view returns (uint256);
}
/// @notice Sale/token contract is deployed only once the sale is bonded, and is launched immediately after.
/// Pre-launch buy/sell & user accounting live in the factory.
/// This contract only needs: (1) initialize bonded state, (2) launch, (3) claim, (4) LP fee claiming.
contract EtherfunSale is ReentrancyGuard, ERC20 {
address public creator;
address public funfactory;
uint256 public totalTokens;
uint256 public saleGoal;
// Fee params kept for determinism / metadata compatibility
uint8 public initiatorShare;
// Bonded state (set once by the factory right after deployment)
uint256 public totalRaised;
uint256 public tokensSold;
bool public status; // bonded
bool public launched;
address public wethAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public vistaFactoryAddress = 0x9a27cb5ae0B2cEe0bb71f9A85C0D60f3920757B4;
modifier onlyFunFactory() {
require(msg.sender == funfactory, "Only factory");
_;
}
constructor(
string memory name,
string memory symbol,
address _creator,
address _factory,
uint256 _totalTokens,
uint256 _saleGoal,
uint8 _initiatorshare
) ERC20(name, symbol) {
creator = _creator;
funfactory = _factory;
totalTokens = _totalTokens;
saleGoal = _saleGoal;
initiatorShare = _initiatorshare;
// Mint full supply to this contract; unsold portion is used to seed LP on launch.
_mint(address(this), _totalTokens);
}
/// @notice Called by factory after funding this contract with `_totalRaised` ETH.
/// Sets the bonded state used by `launchSale` (and indirectly LP sizing).
function initializeBondedState(uint256 _tokensSold, uint256 _totalRaised) external payable onlyFunFactory nonReentrant
{
require(!launched, "Sale already launched");
require(!status, "Already bonded");
require(_totalRaised >= saleGoal, "Sale goal not reached");
require(address(this).balance >= _totalRaised, "Funding mismatch");
require(msg.value == _totalRaised, "Value mismatch");
tokensSold = _tokensSold;
totalRaised = _totalRaised;
status = true;
}
/// @notice Launches the sale: adds LP via launcher and distributes creator share
function launchSale(
address _launchContract,
uint8 buyLpFee,
uint8 sellLpFee,
uint8 buyProtocolFee,
uint8 sellProtocolFee,
address saleInitiator
) external onlyFunFactory nonReentrant {
require(!launched, "Sale already launched");
require(totalRaised >= saleGoal, "Sale goal not reached");
require(status, "not bonded");
launched = true;
//add as a constructor param ?
uint256 creatorTokens = (totalTokens * 5)/100;
uint256 tokenAmount = (totalTokens - tokensSold - creatorTokens); //give 5% for free to creator
uint256 ethAmount = totalRaised;
uint256 launchEthAmount = ((100 - initiatorShare) * ethAmount) / 100;
_approve(address(this), _launchContract, tokenAmount);
ILaunchContract(_launchContract).launch{value: launchEthAmount}(
address(this),
tokenAmount,
0,
0,
buyLpFee,
sellLpFee,
buyProtocolFee,
sellProtocolFee,
creator
);
_transfer(address(this), creator, creatorTokens);
uint256 initiatorShareAmount = address(this).balance;
require(initiatorShareAmount > 0, "No balance for creator share");
payable(saleInitiator).transfer(initiatorShareAmount); //transfer eth to cover gas for sale initiator
}
/// @notice Claims ERC20 tokens after launch. Amount is read from the factory's accounting.
function claimTokens(address user) external onlyFunFactory nonReentrant {
require(launched, "Sale not launched");
uint256 tokenAmount = IEtherFunFactoryBalances(funfactory).claimableBalance(address(this), user);
require(tokenAmount > 0, "No tokens to claim");
_transfer(address(this), user, tokenAmount);
}
function takeFee() external onlyFunFactory nonReentrant {
IVistaFactory vistaFactory = IVistaFactory(vistaFactoryAddress);
address pairAddress = vistaFactory.getPair(address(this), wethAddress);
require(pairAddress != address(0), "Pair not found");
IPair pair = IPair(pairAddress);
pair.claimShare();
uint256 balance = address(this).balance;
require(balance > 0, "No fees");
payable(0x4C5fbF8D815379379b3695ba77B5D3f898C1230b).transfer(balance);
}
function getShare() external view returns (uint256) {
IVistaFactory vistaFactory = IVistaFactory(vistaFactoryAddress);
address pairAddress = vistaFactory.getPair(address(this), wethAddress);
return IPair(pairAddress).viewShare();
}
receive() external payable {}
}
ERC20.sol 305 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
Read Contract
factory 0xc45a0155 → address
predictAddress 0x5cc19262 → address
Write Contract 1 functions
These functions modify contract state and require a wallet transaction to execute.
deploy 0x51d11c20
bytes32 salt
string name
string symbol
address creator
uint256 totalTokens
uint256 saleGoal
uint8 creatorShare
returns: address
Recent Transactions
No transactions found for this address