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