arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
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	// Exit represents L2->L1 token transfer.  A leaf for this account appears in the exit tree of the block
31	Exit TxType = "Exit"
32	// Withdrawn represents the balance that was moved from L2->L1 has been widthrawn from the smart contract
33	Withdrawn TxType = "Withdrawn"
34	// Transfer represents L2->L2 token transfer
35	Transfer TxType = "Transfer"
36	// Deposit represents L1->L2 transfer
37	Deposit TxType = "Deposit"
38	// CreateAccountDeposit represents creation of a new leaf in the state tree (newAcconut) + L1->L2 transfer
39	CreateAccountDeposit TxType = "CreateAccountDeposit"
40	// CreateAccountDepositTransfer represents L1->L2 transfer + L2->L2 transfer
41	CreateAccountDepositTransfer TxType = "CreateAccountDepositTransfer"
42)