Multi chain

The Moromoro SDK supports multiple blockchain networks. This guide shows how to use the SDK across different chains.

Supported Networks

Network
Chain ID
Native Token
Example RPC

HyperEVM

-

HYPE

https://rpc.hyperliquid.xyz/evm

BSC

56

BNB

https://bsc-dataseed.binance.org

Ethereum

1

ETH

Your RPC URL

Polygon

137

MATIC

https://polygon-rpc.com

Arbitrum

42161

ETH

https://arb1.arbitrum.io/rpc

Avalanche

43114

AVAX

https://api.avax.network/ext/bc/C/rpc

Optimism

10

ETH

https://mainnet.optimism.io

HyperEVM Example

const { MoroBestRate } = require('@moromoro/moro-sdk')
const { ethers } = require('ethers')

async function swapOnHyperEVM() {
  const provider = new ethers.providers.JsonRpcProvider(
    'https://rpc.hyperliquid.xyz/evm'
  )
  const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider)
  const moroClient = new MoroBestRate(provider, 'hyperevm')

  const HYPE = '0x5555555555555555555555555555555555555555'
  const USDT = '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb'
  const amountIn = ethers.utils.parseUnits('10', 18)
  const gasPrice = ethers.BigNumber.from('5000000000') // 5 gwei

  const quote = await moroClient.getQuote(HYPE, USDT, amountIn, gasPrice)
  const minOut = ethers.BigNumber.from(quote.amountOut).mul(99).div(100)

  const tx = await moroClient.swap(signer, HYPE, USDT, amountIn, minOut, quote)
  await tx.wait()

  console.log('✓ Swapped on HyperEVM')
}

swapOnHyperEVM()

BSC Example

Polygon Example

Arbitrum Example (L2)

For L2 chains like Arbitrum and Optimism, you need to provide L2 gas price.

Optimism Example (L2)

Avalanche Example

Multi-Chain Manager

Utility class to manage swaps across multiple chains.

Getting Network Gas Prices

Network-Specific Configurations

Best Practices

1

Always check network before transactions

Verify you're connected to the intended network (RPC URL / chain) before signing or sending transactions.

2

Use appropriate gas prices for each network

Set gas prices according to network conditions. For L2s, provide both L1 and L2 gas pricing when required.

3

For L2 chains, always provide gasPriceL2 option

L2 chains like Arbitrum and Optimism require an L2 gas price for accurate quoting and execution.

4

Test with small amounts first on new networks

Validate flow and permissions with minimal amounts before committing larger sums.

5

Keep separate private keys per network for security

Using different keys per environment or network reduces risk if a key is compromised.

See Also