LibTransaction
Last updated
Last updated
The LibTransaction
library provides functions for encoding and decoding a Transaction
struct into a byte array.
Field | Type | Description |
---|---|---|
The encode
function takes a Transaction
struct and converts it into a byte array.
Input
Output
The decode
function takes a byte array and converts it back into a Transaction
struct.
Input
Output
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
Field | Type | Description |
---|---|---|
DataTransferType
has two named values: Wormhole
and LayerZero
.
Each named value is assigned an implicit integer value, starting at 0 for the first value and incrementing by 1 for each subsequent value. In this case, Wormhole
is assigned the value 0, and LayerZero
is assigned the value 1.
BridgeType
has two named values: Wormhole
and Stargate
.
Each named value is assigned an implicit integer value, starting at 0 for the first value and incrementing by 1 for each subsequent value. In this case, Wormhole
is assigned the value 0, and Stargate
is assigned the value 1.
the network id of the recipient chain.
the address of the source asset address that will get swapped. Example: 0x0000000000000000000000007b155e039f60ad89b3b3761a513238dfeebd8ab1
the address of the destination asset address that will be received after swapping.
Example:
0x0000000000000000000000003b981e413aedcd075d96a8f28d2aaff9b15f4f01
the address of the recipient.
Example: 0x000000000000000000000000EE2249f8E5c4E84882eBA16DC991F3Fd4404C955
the address of the aggregator at the destionation address.
the minimum swapped amount that is acceptable by the user. Example: 100000000000000000
the gas fee that the user can pay for the swapping.
Example: 100000
the sequence we receive while transferring the tokens over the bridge.
This field is of type bytes32
and represents the address of the asset being transferred from. The address is typically encoded as a 32-byte value.
This field is of type bytes32
and represents the address of the asset being transferred to. Similar to fromAssetAddress
, it is encoded as a 32-byte value.
This field is of type bytes32
and represents the destination address of the transfer. It is also encoded as a 32-byte value.
This field is of type uint256
and represents the minimum amount of the transferred asset that should be received. It defines a threshold for the expected output amount.
This field is of type uint256
and represents the gas fee associated with the swap or transfer operation. It specifies the amount of gas required for completing the transaction.
the transaction struct to perform the encoding.
returns the encoded data in the form of bytes.
the payload in bytes that needs to be decoded
returns the Transaction struct after the decoding is completed.