forked from DaVinciGraph/DaVinciGraphBlackHole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IHederaTokenService.sol
331 lines (262 loc) · 14.8 KB
/
IHederaTokenService.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.4.9 <0.9.0;
pragma experimental ABIEncoderV2;
interface IHederaTokenService {
/// Transfers cryptocurrency among two or more accounts by making the desired adjustments to their
/// balances. Each transfer list can specify up to 10 adjustments. Each negative amount is withdrawn
/// from the corresponding account (a sender), and each positive one is added to the corresponding
/// account (a receiver). The amounts list must sum to zero. Each amount is a number of tinybars
/// (there are 100,000,000 tinybars in one hbar). If any sender account fails to have sufficient
/// hbars, then the entire transaction fails, and none of those transfers occur, though the
/// transaction fee is still charged. This transaction must be signed by the keys for all the sending
/// accounts, and for any receiving accounts that have receiverSigRequired == true. The signatures
/// are in the same order as the accounts, skipping those accounts that don't need a signature.
/// @custom:version 0.3.0 previous version did not include isApproval
struct AccountAmount {
// The Account ID, as a solidity address, that sends/receives cryptocurrency or tokens
address accountID;
// The amount of the lowest denomination of the given token that
// the account sends(negative) or receives(positive)
int64 amount;
// If true then the transfer is expected to be an approved allowance and the
// accountID is expected to be the owner. The default is false (omitted).
bool isApproval;
}
/// A sender account, a receiver account, and the serial number of an NFT of a Token with
/// NON_FUNGIBLE_UNIQUE type. When minting NFTs the sender will be the default AccountID instance
/// (0.0.0 aka 0x0) and when burning NFTs, the receiver will be the default AccountID instance.
/// @custom:version 0.3.0 previous version did not include isApproval
struct NftTransfer {
// The solidity address of the sender
address senderAccountID;
// The solidity address of the receiver
address receiverAccountID;
// The serial number of the NFT
int64 serialNumber;
// If true then the transfer is expected to be an approved allowance and the
// accountID is expected to be the owner. The default is false (omitted).
bool isApproval;
}
struct TokenTransferList {
// The ID of the token as a solidity address
address token;
// Applicable to tokens of type FUNGIBLE_COMMON. Multiple list of AccountAmounts, each of which
// has an account and amount.
AccountAmount[] transfers;
// Applicable to tokens of type NON_FUNGIBLE_UNIQUE. Multiple list of NftTransfers, each of
// which has a sender and receiver account, including the serial number of the NFT
NftTransfer[] nftTransfers;
}
struct TransferList {
// Multiple list of AccountAmounts, each of which has an account and amount.
// Used to transfer hbars between the accounts in the list.
AccountAmount[] transfers;
}
/// Expiry properties of a Hedera token - second, autoRenewAccount, autoRenewPeriod
struct Expiry {
// The epoch second at which the token should expire; if an auto-renew account and period are
// specified, this is coerced to the current epoch second plus the autoRenewPeriod
int64 second;
// ID of an account which will be automatically charged to renew the token's expiration, at
// autoRenewPeriod interval, expressed as a solidity address
address autoRenewAccount;
// The interval at which the auto-renew account will be charged to extend the token's expiry
int64 autoRenewPeriod;
}
/// A Key can be a public key from either the Ed25519 or ECDSA(secp256k1) signature schemes, where
/// in the ECDSA(secp256k1) case we require the 33-byte compressed form of the public key. We call
/// these public keys <b>primitive keys</b>.
/// A Key can also be the ID of a smart contract instance, which is then authorized to perform any
/// precompiled contract action that requires this key to sign.
/// Note that when a Key is a smart contract ID, it <i>doesn't</i> mean the contract with that ID
/// will actually create a cryptographic signature. It only means that when the contract calls a
/// precompiled contract, the resulting "child transaction" will be authorized to perform any action
/// controlled by the Key.
/// Exactly one of the possible values should be populated in order for the Key to be valid.
struct KeyValue {
// if set to true, the key of the calling Hedera account will be inherited as the token key
bool inheritAccountKey;
// smart contract instance that is authorized as if it had signed with a key
address contractId;
// Ed25519 public key bytes
bytes ed25519;
// Compressed ECDSA(secp256k1) public key bytes
bytes ECDSA_secp256k1;
// A smart contract that, if the recipient of the active message frame, should be treated
// as having signed. (Note this does not mean the <i>code being executed in the frame</i>
// will belong to the given contract, since it could be running another contract's code via
// <tt>delegatecall</tt>. So setting this key is a more permissive version of setting the
// contractID key, which also requires the code in the active message frame belong to the
// the contract with the given id.)
address delegatableContractId;
}
/// A list of token key types the key should be applied to and the value of the key
struct TokenKey {
// bit field representing the key type. Keys of all types that have corresponding bits set to 1
// will be created for the token.
// 0th bit: adminKey
// 1st bit: kycKey
// 2nd bit: freezeKey
// 3rd bit: wipeKey
// 4th bit: supplyKey
// 5th bit: feeScheduleKey
// 6th bit: pauseKey
// 7th bit: ignored
uint keyType;
// the value that will be set to the key type
KeyValue key;
}
/// Basic properties of a Hedera Token - name, symbol, memo, tokenSupplyType, maxSupply,
/// treasury, freezeDefault. These properties are related both to Fungible and NFT token types.
struct HederaToken {
// The publicly visible name of the token. The token name is specified as a Unicode string.
// Its UTF-8 encoding cannot exceed 100 bytes, and cannot contain the 0 byte (NUL).
string name;
// The publicly visible token symbol. The token symbol is specified as a Unicode string.
// Its UTF-8 encoding cannot exceed 100 bytes, and cannot contain the 0 byte (NUL).
string symbol;
// The ID of the account which will act as a treasury for the token as a solidity address.
// This account will receive the specified initial supply or the newly minted NFTs in
// the case for NON_FUNGIBLE_UNIQUE Type
address treasury;
// The memo associated with the token (UTF-8 encoding max 100 bytes)
string memo;
// IWA compatibility. Specified the token supply type. Defaults to INFINITE
bool tokenSupplyType;
// IWA Compatibility. Depends on TokenSupplyType. For tokens of type FUNGIBLE_COMMON - the
// maximum number of tokens that can be in circulation. For tokens of type NON_FUNGIBLE_UNIQUE -
// the maximum number of NFTs (serial numbers) that can be minted. This field can never be changed!
int64 maxSupply;
// The default Freeze status (frozen or unfrozen) of Hedera accounts relative to this token. If
// true, an account must be unfrozen before it can receive the token
bool freezeDefault;
// list of keys to set to the token
TokenKey[] tokenKeys;
// expiry properties of a Hedera token - second, autoRenewAccount, autoRenewPeriod
Expiry expiry;
}
/// Additional post creation fungible and non fungible properties of a Hedera Token.
struct TokenInfo {
/// Basic properties of a Hedera Token
HederaToken token;
/// The number of tokens (fungible) or serials (non-fungible) of the token
int64 totalSupply;
/// Specifies whether the token is deleted or not
bool deleted;
/// Specifies whether the token kyc was defaulted with KycNotApplicable (true) or Revoked (false)
bool defaultKycStatus;
/// Specifies whether the token is currently paused or not
bool pauseStatus;
/// The fixed fees collected when transferring the token
FixedFee[] fixedFees;
/// The fractional fees collected when transferring the token
FractionalFee[] fractionalFees;
/// The royalty fees collected when transferring the token
RoyaltyFee[] royaltyFees;
/// The ID of the network ledger
string ledgerId;
}
/// Additional fungible properties of a Hedera Token.
struct FungibleTokenInfo {
/// The shared hedera token info
TokenInfo tokenInfo;
/// The number of decimal places a token is divisible by
int32 decimals;
}
/// Additional non fungible properties of a Hedera Token.
struct NonFungibleTokenInfo {
/// The shared hedera token info
TokenInfo tokenInfo;
/// The serial number of the nft
int64 serialNumber;
/// The account id specifying the owner of the non fungible token
address ownerId;
/// The epoch second at which the token was created.
int64 creationTime;
/// The unique metadata of the NFT
bytes metadata;
/// The account id specifying an account that has been granted spending permissions on this nft
address spenderId;
}
/// A fixed number of units (hbar or token) to assess as a fee during a transfer of
/// units of the token to which this fixed fee is attached. The denomination of
/// the fee depends on the values of tokenId, useHbarsForPayment and
/// useCurrentTokenForPayment. Exactly one of the values should be set.
struct FixedFee {
int64 amount;
// Specifies ID of token that should be used for fixed fee denomination
address tokenId;
// Specifies this fixed fee should be denominated in Hbar
bool useHbarsForPayment;
// Specifies this fixed fee should be denominated in the Token currently being created
bool useCurrentTokenForPayment;
// The ID of the account to receive the custom fee, expressed as a solidity address
address feeCollector;
}
/// A fraction of the transferred units of a token to assess as a fee. The amount assessed will never
/// be less than the given minimumAmount, and never greater than the given maximumAmount. The
/// denomination is always units of the token to which this fractional fee is attached.
struct FractionalFee {
// A rational number's numerator, used to set the amount of a value transfer to collect as a custom fee
int64 numerator;
// A rational number's denominator, used to set the amount of a value transfer to collect as a custom fee
int64 denominator;
// The minimum amount to assess
int64 minimumAmount;
// The maximum amount to assess (zero implies no maximum)
int64 maximumAmount;
bool netOfTransfers;
// The ID of the account to receive the custom fee, expressed as a solidity address
address feeCollector;
}
/// A fee to assess during a transfer that changes ownership of an NFT. Defines the fraction of
/// the fungible value exchanged for an NFT that the ledger should collect as a royalty. ("Fungible
/// value" includes both ℏ and units of fungible HTS tokens.) When the NFT sender does not receive
/// any fungible value, the ledger will assess the fallback fee, if present, to the new NFT owner.
/// Royalty fees can only be added to tokens of type type NON_FUNGIBLE_UNIQUE.
struct RoyaltyFee {
// A fraction's numerator of fungible value exchanged for an NFT to collect as royalty
int64 numerator;
// A fraction's denominator of fungible value exchanged for an NFT to collect as royalty
int64 denominator;
// If present, the fee to assess to the NFT receiver when no fungible value
// is exchanged with the sender. Consists of:
// amount: the amount to charge for the fee
// tokenId: Specifies ID of token that should be used for fixed fee denomination
// useHbarsForPayment: Specifies this fee should be denominated in Hbar
int64 amount;
address tokenId;
bool useHbarsForPayment;
// The ID of the account to receive the custom fee, expressed as a solidity address
address feeCollector;
}
/**********************
* Direct HTS Calls *
**********************/
/// Single-token variant of associateTokens. Will be mapped to a single entry array call of associateTokens
/// @param account The account to be associated with the provided token
/// @param token The token to be associated with the provided account
function associateToken(address account, address token)
external
returns (int64 responseCode);
/// Transfers tokens where the calling account/contract is implicitly the first entry in the token transfer list,
/// where the amount is the value needed to zero balance the transfers. Regular signing rules apply for sending
/// (positive amount) or receiving (negative amount)
/// @param token The token to transfer to/from
/// @param sender The sender for the transaction
/// @param recipient The receiver of the transaction
/// @param amount Non-negative value to send. a negative value will result in a failure.
function transferToken(
address token,
address sender,
address recipient,
int64 amount
) external returns (int64 responseCode);
/// Query to return the token type for a given address
/// @param token The token address
/// @return responseCode The response code for the status of the request. SUCCESS is 22.
/// @return tokenType the token type. 0 is FUNGIBLE_COMMON, 1 is NON_FUNGIBLE_UNIQUE, -1 is UNRECOGNIZED
function getTokenType(address token)
external returns
(int64 responseCode, int32 tokenType);
}