-
Notifications
You must be signed in to change notification settings - Fork 111
/
Tron.proto
548 lines (490 loc) · 12.3 KB
/
Tron.proto
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
syntax = "proto3";
import "google/protobuf/any.proto";
import "core/Discover.proto";
package protocol;
option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file
option java_outer_classname = "Protocol"; //Specify the class name of the generated Java file
option go_package = "github.com/tronprotocol/grpc-gateway/core";
enum AccountType {
Normal = 0;
AssetIssue = 1;
Contract = 2;
}
// AccountId, (name, address) use name, (null, address) use address, (name, null) use name,
message AccountId {
bytes name = 1;
bytes address = 2;
}
// vote message
message Vote {
// the super rep address
bytes vote_address = 1;
// the vote num to this super rep.
int64 vote_count = 2;
}
// Proposal
message Proposal {
int64 proposal_id = 1;
bytes proposer_address = 2;
map<int64, int64> parameters = 3;
int64 expiration_time = 4;
int64 create_time = 5;
repeated bytes approvals = 6;
enum State {
PENDING = 0;
DISAPPROVED = 1;
APPROVED = 2;
CANCELED = 3;
}
State state = 7;
}
// Exchange
message Exchange {
int64 exchange_id = 1;
bytes creator_address = 2;
int64 create_time = 3;
bytes first_token_id = 6;
int64 first_token_balance = 7;
bytes second_token_id = 8;
int64 second_token_balance = 9;
}
message ChainParameters {
repeated ChainParameter chainParameter = 1;
message ChainParameter {
string key = 1;
int64 value = 2;
}
}
/* Account */
message Account {
/* frozen balance */
message Frozen {
int64 frozen_balance = 1; // the frozen trx balance
int64 expire_time = 2; // the expire time
}
// account nick name
bytes account_name = 1;
AccountType type = 2;
// the create address
bytes address = 3;
// the trx balance
int64 balance = 4;
// the votes
repeated Vote votes = 5;
// the other asset owned by this account
map<string, int64> asset = 6;
// the other asset owned by this account,key is assetId
map<string, int64> assetV2 = 56;
// the frozen balance for bandwidth
repeated Frozen frozen = 7;
// bandwidth, get from frozen
int64 net_usage = 8;
//Frozen balance provided by other accounts to this account
int64 acquired_delegated_frozen_balance_for_bandwidth = 41;
//Freeze and provide balances to other accounts
int64 delegated_frozen_balance_for_bandwidth = 42;
// this account create time
int64 create_time = 0x09;
// this last operation time, including transfer, voting and so on. //FIXME fix grammar
int64 latest_opration_time = 10;
// witness block producing allowance
int64 allowance = 0x0B;
// last withdraw time
int64 latest_withdraw_time = 0x0C;
// not used so far
bytes code = 13;
bool is_witness = 14;
bool is_committee = 15;
// frozen asset(for asset issuer)
repeated Frozen frozen_supply = 16;
// asset_issued_name
bytes asset_issued_name = 17;
bytes asset_issued_ID = 57;
map<string, int64> latest_asset_operation_time = 18;
map<string, int64> latest_asset_operation_timeV2 = 58;
int64 free_net_usage = 19;
map<string, int64> free_asset_net_usage = 20;
map<string, int64> free_asset_net_usageV2 = 59;
int64 latest_consume_time = 21;
int64 latest_consume_free_time = 22;
// the identity of this account, case insensitive
bytes account_id = 23;
message AccountResource {
// energy resource, get from frozen
int64 energy_usage = 1;
// the frozen balance for energy
Frozen frozen_balance_for_energy = 2;
int64 latest_consume_time_for_energy = 3;
//Frozen balance provided by other accounts to this account
int64 acquired_delegated_frozen_balance_for_energy = 4;
//Frozen balances provided to other accounts
int64 delegated_frozen_balance_for_energy = 5;
// storage resource, get from market
int64 storage_limit = 6;
int64 storage_usage = 7;
int64 latest_exchange_storage_time = 8;
}
AccountResource account_resource = 26;
bytes codeHash = 30;
}
message DelegatedResource {
bytes from = 1;
bytes to = 2;
int64 frozen_balance_for_bandwidth = 3;
int64 frozen_balance_for_energy = 4;
int64 expire_time_for_bandwidth = 5;
int64 expire_time_for_energy = 6;
}
message authority {
AccountId account = 1;
bytes permission_name = 2;
}
message permission {
AccountId account = 1;
}
// Witness
message Witness {
bytes address = 1;
int64 voteCount = 2;
bytes pubKey = 3;
string url = 4;
int64 totalProduced = 5;
int64 totalMissed = 6;
int64 latestBlockNum = 7;
int64 latestSlotNum = 8;
bool isJobs = 9;
}
// Vote Change
message Votes {
bytes address = 1;
repeated Vote old_votes = 2;
repeated Vote new_votes = 3;
}
// Transcation
message TXOutput {
int64 value = 1;
bytes pubKeyHash = 2;
}
message TXInput {
message raw {
bytes txID = 1;
int64 vout = 2;
bytes pubKey = 3;
}
raw raw_data = 1;
bytes signature = 4;
}
message TXOutputs {
repeated TXOutput outputs = 1;
}
message ResourceReceipt {
int64 energy_usage = 1;
int64 energy_fee = 2;
int64 origin_energy_usage = 3;
int64 energy_usage_total = 4;
int64 net_usage = 5;
int64 net_fee = 6;
Transaction.Result.contractResult result = 7;
}
message Transaction {
message Contract {
enum ContractType {
AccountCreateContract = 0;
TransferContract = 1;
TransferAssetContract = 2;
VoteAssetContract = 3;
VoteWitnessContract = 4;
WitnessCreateContract = 5;
AssetIssueContract = 6;
WitnessUpdateContract = 8;
ParticipateAssetIssueContract = 9;
AccountUpdateContract = 10;
FreezeBalanceContract = 11;
UnfreezeBalanceContract = 12;
WithdrawBalanceContract = 13;
UnfreezeAssetContract = 14;
UpdateAssetContract = 15;
ProposalCreateContract = 16;
ProposalApproveContract = 17;
ProposalDeleteContract = 18;
SetAccountIdContract = 19;
CustomContract = 20;
// BuyStorageContract = 21;
// BuyStorageBytesContract = 22;
// SellStorageContract = 23;
CreateSmartContract = 30;
TriggerSmartContract = 31;
GetContract = 32;
UpdateSettingContract = 33;
ExchangeCreateContract = 41;
ExchangeInjectContract = 42;
ExchangeWithdrawContract = 43;
ExchangeTransactionContract = 44;
UpdateEnergyLimitContract = 45;
}
ContractType type = 1;
google.protobuf.Any parameter = 2;
bytes provider = 3;
bytes ContractName = 4;
}
message Result {
enum code {
SUCESS = 0;
FAILED = 1;
}
enum contractResult {
DEFAULT = 0;
SUCCESS = 1;
REVERT = 2;
BAD_JUMP_DESTINATION = 3;
OUT_OF_MEMORY = 4;
PRECOMPILED_CONTRACT = 5;
STACK_TOO_SMALL = 6;
STACK_TOO_LARGE = 7;
ILLEGAL_OPERATION = 8;
STACK_OVERFLOW = 9;
OUT_OF_ENERGY = 10;
OUT_OF_TIME = 11;
JVM_STACK_OVER_FLOW = 12;
UNKNOWN = 13;
}
int64 fee = 1;
code ret = 2;
contractResult contractRet = 3;
string assetIssueID = 14;
int64 withdraw_amount = 15;
int64 unfreeze_amount = 16;
int64 exchange_received_amount = 18;
int64 exchange_inject_another_amount = 19;
int64 exchange_withdraw_another_amount = 20;
int64 exchange_id = 21;
}
message raw {
bytes ref_block_bytes = 1;
int64 ref_block_num = 3;
bytes ref_block_hash = 4;
int64 expiration = 8;
repeated authority auths = 9;
// data not used
bytes data = 10;
//only support size = 1, repeated list here for extension
repeated Contract contract = 11;
// scripts not used
bytes scripts = 12;
int64 timestamp = 14;
int64 fee_limit = 18;
}
raw raw_data = 1;
// only support size = 1, repeated list here for muti-sig extension
repeated bytes signature = 2;
repeated Result ret = 5;
}
message TransactionInfo {
enum code {
SUCESS = 0;
FAILED = 1;
}
message Log {
bytes address = 1;
repeated bytes topics = 2;
bytes data = 3;
}
bytes id = 1;
int64 fee = 2;
int64 blockNumber = 3;
int64 blockTimeStamp = 4;
repeated bytes contractResult = 5;
bytes contract_address = 6;
ResourceReceipt receipt = 7;
repeated Log log = 8;
code result = 9;
bytes resMessage = 10;
string assetIssueID = 14;
int64 withdraw_amount = 15;
int64 unfreeze_amount = 16;
repeated InternalTransaction internal_transactions = 17;
int64 exchange_received_amount = 18;
int64 exchange_inject_another_amount = 19;
int64 exchange_withdraw_another_amount = 20;
int64 exchange_id = 21;
}
message Transactions {
repeated Transaction transactions = 1;
}
message TransactionSign {
Transaction transaction = 1;
bytes privateKey = 2;
}
message BlockHeader {
message raw {
int64 timestamp = 1;
bytes txTrieRoot = 2;
bytes parentHash = 3;
//bytes nonce = 5;
//bytes difficulty = 6;
int64 number = 7;
int64 witness_id = 8;
bytes witness_address = 9;
int32 version = 10;
}
raw raw_data = 1;
bytes witness_signature = 2;
}
// block
message Block {
repeated Transaction transactions = 1;
BlockHeader block_header = 2;
}
message ChainInventory {
message BlockId {
bytes hash = 1;
int64 number = 2;
}
repeated BlockId ids = 1;
int64 remain_num = 2;
}
// Inventory
message BlockInventory {
enum Type {
SYNC = 0;
ADVTISE = 1;
FETCH = 2;
}
message BlockId {
bytes hash = 1;
int64 number = 2;
}
repeated BlockId ids = 1;
Type type = 2;
}
message Inventory {
enum InventoryType {
TRX = 0;
BLOCK = 1;
}
InventoryType type = 1;
repeated bytes ids = 2;
}
message Items {
enum ItemType {
ERR = 0;
TRX = 1;
BLOCK = 2;
BLOCKHEADER = 3;
}
ItemType type = 1;
repeated Block blocks = 2;
repeated BlockHeader block_headers = 3;
repeated Transaction transactions = 4;
}
// DynamicProperties
message DynamicProperties {
int64 last_solidity_block_num = 1;
}
enum ReasonCode {
REQUESTED = 0x00;
BAD_PROTOCOL = 0x02;
TOO_MANY_PEERS = 0x04;
DUPLICATE_PEER = 0x05;
INCOMPATIBLE_PROTOCOL = 0x06;
NULL_IDENTITY = 0x07;
PEER_QUITING = 0x08;
UNEXPECTED_IDENTITY = 0x09;
LOCAL_IDENTITY = 0x0A;
PING_TIMEOUT = 0x0B;
USER_REASON = 0x10;
RESET = 0x11;
SYNC_FAIL = 0x12;
FETCH_FAIL = 0x13;
BAD_TX = 0x14;
BAD_BLOCK = 0x15;
FORKED = 0x16;
UNLINKABLE = 0x17;
INCOMPATIBLE_VERSION = 0x18;
INCOMPATIBLE_CHAIN = 0x19;
TIME_OUT = 0x20;
CONNECT_FAIL = 0x21;
TOO_MANY_PEERS_WITH_SAME_IP = 0x22;
UNKNOWN = 0xFF;
}
message DisconnectMessage {
ReasonCode reason = 1;
}
message HelloMessage {
message BlockId {
bytes hash = 1;
int64 number = 2;
}
Endpoint from = 1;
int32 version = 2;
int64 timestamp = 3;
BlockId genesisBlockId = 4;
BlockId solidBlockId = 5;
BlockId headBlockId = 6;
}
message SmartContract {
message ABI {
message Entry {
enum EntryType {
UnknownEntryType = 0;
Constructor = 1;
Function = 2;
Event = 3;
Fallback = 4;
}
message Param {
bool indexed = 1;
string name = 2;
string type = 3;
// SolidityType type = 3;
}
enum StateMutabilityType {
UnknownMutabilityType = 0;
Pure = 1;
View = 2;
Nonpayable = 3;
Payable = 4;
}
bool anonymous = 1;
bool constant = 2;
string name = 3;
repeated Param inputs = 4;
repeated Param outputs = 5;
EntryType type = 6;
bool payable = 7;
StateMutabilityType stateMutability = 8;
}
repeated Entry entrys = 1;
}
bytes origin_address = 1;
bytes contract_address = 2;
ABI abi = 3;
bytes bytecode = 4;
int64 call_value = 5;
int64 consume_user_resource_percent = 6;
string name = 7;
int64 origin_energy_limit = 8;
}
message InternalTransaction {
// internalTransaction identity, the root InternalTransaction hash
// should equals to root transaction id.
bytes hash = 1;
// the one send trx (TBD: or token) via function
bytes caller_address = 2;
// the one recieve trx (TBD: or token) via function
bytes transferTo_address = 3;
message CallValueInfo {
// trx (TBD: or token) value
int64 callValue = 1;
// TBD: tokenName, trx should be empty
string tokenId = 2;
}
repeated CallValueInfo callValueInfo = 4;
bytes note = 5;
bool rejected = 6;
}
message DelegatedResourceAccountIndex {
bytes account = 1;
repeated bytes fromAccounts = 2;
repeated bytes toAccounts = 3;
}