-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCreateToken.s.sol
More file actions
52 lines (41 loc) · 1.91 KB
/
CreateToken.s.sol
File metadata and controls
52 lines (41 loc) · 1.91 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import {Script, console} from "forge-std/Script.sol";
import {HTS_ADDRESS} from "hedera-forking/HtsSystemContract.sol";
import {IHederaTokenService} from "hedera-forking/IHederaTokenService.sol";
import {HederaResponseCodes} from "hedera-forking/HederaResponseCodes.sol";
import {Hsc} from "hedera-forking/Hsc.sol";
/**
* Given how Foundry script works, the flag `--skip-simulation` is necessary.
* For example
*
* forge script scripts/CreateToken.s.sol -vvv --rpc-url testnet --skip-simulation --broadcast
*/
contract CreateTokenScript is Script {
uint256 PRIVATE_KEY = vm.envUint("PRIVATE_KEY");
function run() external returns (int64 responseCode, address tokenAddress) {
Hsc.htsSetup();
address signer = vm.addr(PRIVATE_KEY);
console.log("Signer address %s", signer);
vm.startBroadcast(PRIVATE_KEY);
IHederaTokenService.KeyValue memory keyValue;
keyValue.inheritAccountKey = true;
IHederaTokenService.TokenKey[] memory keys = new IHederaTokenService.TokenKey[](1);
keys[0] = IHederaTokenService.TokenKey(1, keyValue);
IHederaTokenService.Expiry memory expiry;
expiry.second = 0;
expiry.autoRenewAccount = signer;
expiry.autoRenewPeriod = 8000000;
IHederaTokenService.HederaToken memory token;
token.name = "HTS Token Example Created with Foundry";
token.symbol = "FDRY";
token.treasury = signer;
token.memo = "This HTS Token was created using `forge script` together with HTS emulation";
token.tokenKeys = keys;
token.expiry = expiry;
(responseCode, tokenAddress) = IHederaTokenService(HTS_ADDRESS).createFungibleToken{value: 10 ether}(token, 10000, 4);
console.log("Response code %d", int(responseCode));
console.log("Token address %s", tokenAddress);
vm.stopBroadcast();
}
}