Compute fee in token value with an amount and a fee index
@param {Number} feeIndex - Fee selected among 0 - 255
@param {Number} amount - The amount of the transaction as a Scalar
@returns {BigInt} Resulting fee in token value
Generates the L1 Transaction Id based on the spec
TxID (32 bytes) for L1Tx is the Keccak256 (ethereum) hash of:
bytes: | 1 byte | 32 bytes |
SHA256( 8 bytes | 2 bytes )
content: | type | SHA256(ToForgeL1TxsNum | Position )
where type for L1UserTx is 0
@param {Number} toForgeL1TxsNum
@param {Number} currentPosition
Generates the Transaction Id based on the spec
TxID (33 bytes) for L2Tx is:
bytes: | 1 byte | 32 bytes |
SHA256( 6 bytes | 4 bytes | 2 bytes| 5 bytes | 1 byte )
content: | type | SHA256(FromIdx | TokenID | Amount | Nonce | Fee )
where type for L2Tx is '2'
@param {Number} fromIdx - The account index that sends the transaction
@param {Number} tokenId - The tokenId being transacted
@param {Number} amount - The amount being transacted
@param {Number} nonce - Nonce of the transaction
@param {Number} fee - The fee of the transaction
@returns {String} Transaction Id
Calculates the appropriate nonce based on the current token account nonce and existing transactions in the Pool.
It needs to find the lowest nonce available as transactions in the pool may fail and the Coordinator only forges
transactions in the order set by nonces.
Gets the transaction type depending on the information in the transaction object
If an account index is used, it will be 'Transfer'
If a Hermez address is used, it will be 'TransferToEthAddr'
If a BabyJubJub is used, it will be 'TransferToBjj'