arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/common/tx.go
common/tx.goRaw
 1package common
 2
 3import (
 4	"math/big"
 5)
 6
 7// Tx is a struct that represents a Hermez network transaction
 8type Tx struct {
 9	TxID     TxID
10	FromIdx  uint32
11	ToIdx    uint32
12	TokenID  TokenID
13	Amount   *big.Int
14	Nonce    uint64 // effective 48 bits used
15	Fee      FeeSelector
16	Type     TxType   // optional, descrives which kind of tx it's
17	BatchNum BatchNum // batchNum in which this tx was forged. Presence indicates "forged" state.
18}
19
20// TxID is the identifier of a Hermez network transaction
21type TxID Hash // Hash is a guess
22
23// TxType is a string that represents the type of a Hermez network transaction
24type TxType string
25
26const (
27	// TxTypeExit represents L2->L1 token transfer.  A leaf for this account appears in the exit tree of the block
28	TxTypeExit TxType = "Exit"
29	// TxTypeWithdrawn represents the balance that was moved from L2->L1 has been widthrawn from the smart contract
30	TxTypeWithdrawn TxType = "Withdrawn"
31	// TxTypeTransfer represents L2->L2 token transfer
32	TxTypeTransfer TxType = "Transfer"
33	// TxTypeDeposit represents L1->L2 transfer
34	TxTypeDeposit TxType = "Deposit"
35	// TxTypeCreateAccountDeposit represents creation of a new leaf in the state tree (newAcconut) + L1->L2 transfer
36	TxTypeCreateAccountDeposit TxType = "CreateAccountDeposit"
37	// TxTypeCreateAccountDepositAndTransfer represents L1->L2 transfer + L2->L2 transfer
38	TxTypeCreateAccountDepositAndTransfer TxType = "CreateAccountDepositAndTransfer"
39	// TxTypeDepositAndTransfer TBD
40	TxTypeDepositAndTransfer TxType = "TxTypeDepositAndTransfer"
41	// TxTypeForceTransfer TBD
42	TxTypeForceTransfer TxType = "TxTypeForceTransfer"
43	// TxTypeForceExit TBD
44	TxTypeForceExit TxType = "TxTypeForceExit"
45	// TxTypeTransferToEthAddr TBD
46	TxTypeTransferToEthAddr TxType = "TxTypeTransferToEthAddr"
47	// TxTypeTransferToBJJ TBD
48	TxTypeTransferToBJJ TxType = "TxTypeTransferToBJJ"
49)