@morph-l2/sdk • Docs
@morph-l2/sdk
The @morph-l2/sdk
package provides a set of tools for interacting with Morph.
Installation
npm install @morph-l2/sdk@latest
Docs
You can find auto-generated API documentation over at docs.morphl2.io.
Using the SDK
CrossChainMessenger
The CrossChainMessenger
class simplifies the process of moving assets and data between Ethereum and Morph.
You can use this class to, for example, initiate a withdrawal of ERC20 tokens from Morph back to Ethereum, accurately track when the withdrawal is ready to be finalized on Ethereum, and execute the finalization transaction after the challenge period has elapsed.
The CrossChainMessenger
can handle deposits and withdrawals of ETH and any ERC20-compatible token.
The CrossChainMessenger
automatically connects to all relevant contracts so complex configuration is not necessary.
L2Provider and related utilities
The Morph SDK includes various utilities for handling Morph's transaction fee model.
For instance, estimateTotalGasCost
will estimate the total cost (in wei) to send at transaction on Morph including both the L2 execution cost and the L1 data cost.
You can also use the asL2Provider
function to wrap an ethers Provider object into an L2Provider
which will have all of these helper functions attached.
Other utilities
The SDK contains other useful helper functions and constants. For a complete list, refer to the auto-generated SDK documentation
Documents
Enumerations
Classes
Interfaces
- BridgeAdapterData
- BridgeAdapters
- CoreCrossChainMessage
- CrossChainMessage
- CrossChainMessageRequest
- IActionOptions
- IBridgeAdapter
- L2Block
- L2BlockWithTransactions
- L2Transaction
- MessageReceipt
- OEContracts
- OEContractsLike
- OEL1Contracts
- OEL2Contracts
- ProvenWithdrawal
- StateRoot
- StateRootBatch
- StateRootBatchHeader
- TokenBridgeMessage
- WithdrawMessageProof
- WithdrawalEntry
Type Aliases
- AddressLike
- DeepPartial
- L1Provider
- L2Provider
- LowLevelMessage
- MessageLike
- MessageRequestLike
- NumberLike
- OEL1ContractsLike
- OEL2ContractsLike
- ProviderLike
- SignerLike
- SignerOrProviderLike
- TransactionLike
Variables
- BRIDGE_ADAPTER_DATA
- CHAIN_BLOCK_TIMES
- CONTRACT_ADDRESSES
- DEFAULT_L1_CONTRACT_ADDRESSES
- DEFAULT_L2_CONTRACT_ADDRESSES
- DEPOSIT_CONFIRMATION_BLOCKS
- l1BridgeName
- l1CrossDomainMessengerName
- l2BridgeName
- l2CrossDomainMessengerName
Functions
- asL2Provider
- estimateL1Gas
- estimateL1GasCost
- estimateL2GasCost
- estimateTotalGasCost
- getAllOEContracts
- getBridgeAdapters
- getL1GasPrice
- getOEContract
- hashLowLevelMessageV2
- hashMessageHash
- isL2Provider
- migratedWithdrawalGasLimit
- omit
- toAddress
- toBigNumber
- toNumber
- toProvider
- toSignerOrProvider
- toTransactionHash