0%

thlm | 转换合约

新转换合约代码。

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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

interface IERC20 {
function balanceOf(address account) external view returns (uint256);

function transferFrom(address from, address to, uint256 value) external returns (bool);

function transfer(address to, uint256 value) external returns (bool);

function burn(uint256 value) external;
}

contract THLM2GAME is Ownable {

event Exchange(address indexed from, uint256 value);

address public THLM = 0x4b94c8567763654101F690Cf4d54957206383b75;
address public GAME = 0x4b94c8567763654101F690Cf4d54957206383b75;

constructor(address initialOwner) Ownable(initialOwner) {
}

function exchange() external {
uint256 balance = IERC20(THLM).balanceOf(msg.sender);
IERC20(THLM).transferFrom(msg.sender, address(this), balance);
IERC20(GAME).transfer(msg.sender, balance);

emit Exchange(msg.sender, balance);
}

function burn(bool flag) external onlyOwner(){
address erc20 = flag ? GAME : THLM;
uint256 balance = IERC20(erc20).balanceOf(address(this));
IERC20(erc20).burn(balance);
}
}
请我喝杯咖啡吧~