-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoveToken.sol
66 lines (54 loc) · 2.6 KB
/
LoveToken.sol
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: CC-BY-4.0
pragma solidity ^0.6.4;
import "@openzeppelin/contracts/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20PausableUpgradeable.sol";
import "@openzeppelin/contracts/access/OwnableUpgradeable.sol";
contract LoveToken is Initializable, ERC20PausableUpgradeable, OwnableUpgradeable {
// ------------------------------------------------------------------------
// Gives Owner all tokens
// ------------------------------------------------------------------------
function initialize() public virtual initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__ERC20_init_unchained('? Love Token', '? Love');
__Pausable_init_unchained();
__ERC20Pausable_init_unchained();
_mint(_msgSender(), 1 ether); //one ?
transferOwnership(_msgSender());
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint amount) public onlyOwner returns (bool) {
_transfer(tokenAddress, owner(), amount);
return true;
}
// ------------------------------------------------------------------------
// Owner can pause all transfers
// ------------------------------------------------------------------------
function pause() public onlyOwner {
_pause();
}
// ------------------------------------------------------------------------
// Owner can unpause all transfers
// ------------------------------------------------------------------------
function unpause() public onlyOwner {
_unpause();
}
// ------------------------------------------------------------------------
// Claim one and share with others. Love is free!
// ------------------------------------------------------------------------
function claim() public {
_mint(msg.sender, 1 ether);
}
// ------------------------------------------------------------------------
// Get love tokens by sharing love
// ------------------------------------------------------------------------
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal virtual override
{
super._beforeTokenTransfer(from, to, amount); // Call parent hook
if (from!=address(0))
_mint(from, amount);
}
}