-
Notifications
You must be signed in to change notification settings - Fork 1
/
3_tranferFT2Contract_msg_this.sol
40 lines (29 loc) · 1.21 KB
/
3_tranferFT2Contract_msg_this.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
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
pragma experimental ABIEncoderV2;
import "./hip-206/HederaTokenService.sol";
import "./hip-206/HederaResponseCodes.sol";
contract test is HederaTokenService {
address tokenAddress;
constructor(address _tokenAddress) public {
tokenAddress = _tokenAddress;
}
function mintFungibleToken(uint64 _amount) external {
(int response, uint64 newTotalSupply, int64[] memory serialNumbers) = HederaTokenService.mintToken(tokenAddress, _amount, new bytes[](0));
if (response != HederaResponseCodes.SUCCESS) {
revert ("Mint Failed");
}
}
function tokenAssociate() external {
int response = HederaTokenService.associateToken(address(this), tokenAddress);
if (response != HederaResponseCodes.SUCCESS) {
revert ("Associate Failed");
}
}
function tokenTransfer(int64 _amount) external {
int response = HederaTokenService.transferToken(tokenAddress, msg.sender, address(this), _amount);
if (response != HederaResponseCodes.SUCCESS) {
revert ("Transfer Failed");
}
}
}