-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenLabsTokenFactory.sol
More file actions
38 lines (23 loc) · 1.69 KB
/
TokenLabsTokenFactory.sol
File metadata and controls
38 lines (23 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "./ERCToken.sol";
contract TokenLabsTokenFactory is Ownable(msg.sender) {
struct TokenInfo {string name; string symbol; address creator; uint256 creationDate; uint256 initialSupply; string imageUrl;}
mapping(address => TokenInfo) public tokenInfo;
mapping(address => address[]) public tokensCreatedBy;
uint256 public creationFee = 0.0001 ether;
event TokenCreated(address indexed tokenAddress, string name, string symbol, address creator, uint256 creationDate, uint256 initialSupply, string imageUrl);
function setCreationFee(uint256 _fee) public onlyOwner { creationFee = _fee; }
function createToken(string memory name, string memory symbol, uint256 initialSupply, string memory imageUrl) public payable returns (address newTokenAddress){
require(msg.value >= creationFee, "Creation fee is not met");
ERCToken newToken = new ERCToken(name, symbol, msg.sender, initialSupply); // Ajustar el constructor de ERCToken
tokenInfo[address(newToken)] = TokenInfo(name,symbol,msg.sender,block.timestamp,initialSupply,imageUrl);
tokensCreatedBy[msg.sender].push(address(newToken));
emit TokenCreated(address(newToken),name,symbol,msg.sender,block.timestamp,initialSupply,imageUrl);
payable(owner()).transfer(creationFee);
if (msg.value > creationFee) { payable(msg.sender).transfer(msg.value - creationFee); }
return address(newToken);
}
function getCreatedTokens(address creator) public view returns (address[] memory) { return tokensCreatedBy[creator]; }
function withdraw() public onlyOwner { payable(owner()).transfer(address(this).balance); }
}