# Mantle - Modular L2 Documentation

## Mantle RPC plans and rate limits

- **Free plan:** 20 responses per second, up to 100,000 responses a day.
- **Plans:** $49/mo, $299/mo, $999/mo with 25M, 150M, and 500M included responses. Overages billed at $5/$3/$2 per million responses respectively.
- **Paid rate limits:** 100 to 5,000 responses per second (bursts from 500 to 10,000), no daily limit.
- **Billing:** 1 response = 1 API credit on every shared plan, over HTTPS or WebSocket (WSS) where Mantle supports it.

Details: [Pricing](https://www.dwellir.com/docs/getting-started/pricing) · [Rate limits](https://www.dwellir.com/docs/getting-started/rate-limits) · [Authentication](https://www.dwellir.com/docs/getting-started/authentication) · [Archive nodes](https://www.dwellir.com/docs/getting-started/archive-nodes)

## Why Build on Mantle?

Mantle Network is the first modular Layer 2 solution, pioneering the use of EigenDA for data availability. Built on the OP Stack with innovative architectural designs, Mantle offers:

### **Modular Performance**

- **Sub-second block times** - Fast finality with optimistic rollup
- **Up to 500x lower costs** than Ethereum mainnet
- **20,000+ TPS capacity** - High throughput for demanding applications

### **Advanced Security**

- **EigenDA integration** - First L2 with decentralized data availability
- **Optimistic rollup security** - Fraud proof protection with 7-day challenge period
- **Ethereum inheritance** - Full L1 security guarantees

### **Developer Excellence**

- **Full EVM compatibility** - Deploy existing contracts without changes
- **MNT gas token** - Native token for gas and governance
- **OP Stack foundation** - Battle-tested infrastructure

## Quick Start with Mantle

Connect to Mantle in seconds with Dwellir's optimized endpoints:

### Installation & Setup

Ethers.js
Web3.js
Python

```javascript
import { JsonRpcProvider } from 'ethers';

// Connect to Mantle mainnet
const provider = new JsonRpcProvider(
  'https://api-mantle-mainnet.n.dwellir.com/YOUR_API_KEY'
);

// Get network info
const network = await provider.getNetwork();
console.log('Connected to Mantle:', network.chainId); // 5000

// Query blockchain data
const blockNumber = await provider.getBlockNumber();
const balance = await provider.getBalance('0x...');
const gas = await provider.getFeeData();
```

```javascript
import Web3 from 'web3';

// Connect to Mantle
const web3 = new Web3(
  'https://api-mantle-mainnet.n.dwellir.com/YOUR_API_KEY'
);

// Get chain ID
const chainId = await web3.eth.getChainId();
console.log('Chain ID:', chainId); // 5000n

// Query blockchain
const block = await web3.eth.getBlock('latest');
const balance = await web3.eth.getBalance('0x...');
const gasPrice = await web3.eth.getGasPrice();
```

```python
from web3 import Web3

# Connect to Mantle mainnet
w3 = Web3(Web3.HTTPProvider(
    'https://api-mantle-mainnet.n.dwellir.com/YOUR_API_KEY'
))

# Verify connection
if w3.is_connected():
    print(f"Connected to Mantle")
    print(f"Chain ID: {w3.eth.chain_id}")  # 5000
    print(f"Latest block: {w3.eth.block_number}")

    # Get MNT balance
    address = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
    balance = w3.eth.get_balance(address)
    print(f"Balance: {w3.from_wei(balance, 'ether')} MNT")
```

## Network Information

### Mainnet Configuration

| Parameter      | Value                                          | Details |
| -------------- | ---------------------------------------------- | ------- |
| Network Name   | Mantle Network                                 |         |
| Chain ID       | `5000` (0x1388)                                |         |
| Currency       | MNT                                            |         |
| Block Explorer | [Mantle Explorer](https://explorer.mantle.xyz) |         |
| Bridge         | [Mantle Bridge](https://bridge.mantle.xyz)     |         |

### Testnet Configuration (Sepolia)

| Parameter      | Value                                                          | Details |
| -------------- | -------------------------------------------------------------- | ------- |
| Network Name   | Mantle Sepolia                                                 |         |
| Chain ID       | `5003` (0x138B)                                                |         |
| Currency       | MNT (Testnet)                                                  |         |
| Block Explorer | [Mantle Sepolia Explorer](https://explorer.testnet.mantle.xyz) |         |
| Faucet         | [Mantle Sepolia Faucet](https://faucet.testnet.mantle.xyz)     |         |

## Available RPC Methods

Mantle supports all standard Ethereum JSON-RPC methods plus L2-specific extensions:

### Core Methods

- **Transaction Management** - Send, sign, and track transactions
- **State Queries** - Get balances, code, storage
- **Block Information** - Query blocks and receipts
- **Event Logs** - Filter and retrieve events
- **Gas Estimation** - Estimate fees including L1 costs

### L2-Specific Methods

- `eth_estimateL1Fee` - Calculate L1 data posting costs
- `rollup_gasPrices` - Get current L1/L2 gas prices
- `rollup_getInfo` - Query rollup configuration

### Debug & Trace Methods

- `debug_traceTransaction` - Detailed transaction execution traces
- `debug_traceBlock` - Trace all transactions in a block
- `debug_traceCall` - Simulate and trace calls

## Architecture Overview

### Modular Design

Mantle's modular architecture separates core blockchain functions for optimal performance:

1. **Execution Layer** - Processes transactions using the EVM
2. **Settlement Layer** - Posts state commitments to Ethereum
3. **Data Availability Layer** - Uses EigenDA for efficient data storage
4. **Consensus Layer** - Inherits security from Ethereum L1

### EigenDA Integration

As the first L2 to integrate EigenDA, Mantle benefits from:

- **Lower costs** - Reduced data storage expenses
- **Higher throughput** - More efficient data availability
- **Decentralization** - Distributed DA layer
- **ETH restaking** - Additional security through EigenLayer

### Transaction Lifecycle

1. **Submission** - Users submit transactions to Mantle sequencer
2. **Execution** - Transactions processed in batches
3. **Data Posting** - Transaction data posted to EigenDA
4. **Settlement** - State root submitted to Ethereum L1
5. **Finality** - After 7-day challenge period

## Development Resources

### Smart Contract Deployment

Deploy your contracts to Mantle without modifications:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract MantleApp {
    mapping(address => uint256) public balances;

    function deposit() public payable {
        balances[msg.sender] += msg.value;
    }

    function withdraw(uint256 amount) public {
        require(balances[msg.sender] >= amount, "Insufficient balance");
        balances[msg.sender] -= amount;
        payable(msg.sender).transfer(amount);
    }
}
```

### Using MNT Token

MNT is used for gas payments on Mantle:

```javascript
// Send MNT
const tx = await signer.sendTransaction({
  to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
  value: ethers.parseEther('1.0') // 1 MNT
});

// Estimate gas in MNT
const gasEstimate = await provider.estimateGas(tx);
const gasPrice = await provider.getFeeData();
const gasCost = gasEstimate * gasPrice.gasPrice; // Cost in MNT
```

### Bridging Assets

Bridge assets between Ethereum and Mantle:

```javascript
// Bridge configuration
const BRIDGE_ADDRESS = '0x...'; // Mantle Bridge contract
const L1_TOKEN = '0x...'; // Token on Ethereum
const L2_TOKEN = '0x...'; // Token on Mantle

// Deposit from L1 to L2
async function depositToMantle(amount) {
  const bridge = new Contract(BRIDGE_ADDRESS, BRIDGE_ABI, l1Signer);
  const tx = await bridge.depositERC20(
    L1_TOKEN,
    L2_TOKEN,
    amount,
    { value: bridgeFee }
  );
  await tx.wait();
}
```

## Gas Optimization

### Understanding Mantle Fees

Mantle fees consist of two components:

1. **L2 Execution Fee** - Cost to run transaction on Mantle
2. **L1 Data Fee** - Cost to post data to Ethereum (via EigenDA)

```javascript
// Calculate total fee
const l2GasPrice = await provider.getGasPrice();
const l2GasUsed = await provider.estimateGas(tx);
const l1Fee = await provider.send('eth_estimateL1Fee', [tx]);

const totalFee = (l2GasPrice * l2GasUsed) + BigInt(l1Fee);
console.log('Total fee:', ethers.formatEther(totalFee), 'MNT');
```

### Optimization Tips

1. **Batch Operations** - Combine multiple operations in one transaction
2. **Use Events** - Cheaper than storage for data that doesn't need to be on-chain
3. **Optimize Calldata** - Minimize transaction input data
4. **Storage Packing** - Pack multiple values into single storage slots

## Common Use Cases

### DeFi Protocols

- Lower fees enable more frequent rebalancing and smaller trades
- High throughput supports order book DEXs
- Fast finality improves user experience

### Gaming & NFTs

- Affordable minting and trading
- High-frequency game actions
- Complex on-chain game logic

### DAOs & Governance

- Cost-effective voting
- More frequent proposal submissions
- On-chain treasury management

## Best Practices

### Error Handling

```javascript
try {
  const tx = await contract.someMethod();
  const receipt = await tx.wait();

  if (receipt.status === 0) {
    throw new Error('Transaction reverted');
  }
} catch (error) {
  if (error.code === 'CALL_EXCEPTION') {
    console.error('Contract reverted:', error.reason);
  } else if (error.code === 'INSUFFICIENT_FUNDS') {
    console.error('Not enough MNT for gas');
  }
}
```

### Rate Limiting

```javascript
// Implement exponential backoff
async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;

      const delay = Math.pow(2, i) * 1000;
      await new Promise(resolve => setTimeout(resolve, delay));
    }
  }
}
```

## Support & Resources

### Official Resources

- **Documentation**: [docs.mantle.xyz](https://docs.mantle.xyz)
- **GitHub**: [github.com/mantlenetworkio](https://github.com/mantlenetworkio)
- **Discord**: [discord.gg/mantle](https://discord.gg/mantle)
- **Twitter**: [@0xMantle](https://twitter.com/0xMantle)

### Dwellir Support

- **Dashboard**: [dashboard.dwellir.com](https://dashboard.dwellir.com)
- **Status Page**: [status.dwellir.com](https://status.dwellir.com)
- **Support**: <support@dwellir.com>

## Start Building

Ready to build on Mantle? Get your free API key and start developing:

Launch Your Mantle dApp Today
Get instant access to Mantle's modular L2 with our high-performance RPC endpoints

Get Your Free API Key

***

*Need help? Check our [API reference](https://www.dwellir.com/docs/mantle/eth_blockNumber) or [contact support](mailto:support@dwellir.com).*
