---
title: "Mantle API Quick Start Guide"
sidebar_position: 24
tags: [Mantle, EVM, JSON-RPC, blockchain, API]
keywords: [Mantle RPC, Mantle API, MNT, EVM, blockchain infrastructure, smart contracts, Web3]
description: "Mantle is an Ethereum Layer 2 scaling solution utilizing optimistic rollups and modular architecture, designed to provide low-cost, high-throughput tr"
last_updated: 2026-08-19
---

# Mantle API Quick Start Guide

bex.co provides high-performance, reliable Mantle infrastructure through our comprehensive JSON-RPC API. Connect to Ethereum mainnet, testnets, and layer 2 solutions with enterprise-grade reliability and developer-friendly tools.

## Overview

Our Mantle API supports:
- **Mantle Mainnet** and all major testnets (Sepolia, Holesky)
- **Layer 2 Solutions** (Polygon, Arbitrum, Optimism)
- **Full JSON-RPC Specification** with debug and trace methods
- **WebSocket Connections** for real-time data
- **Archive Node Access** for historical data
- **MEV Protection** and transaction simulation

## Quick Start

### Step 1: Get Your API Key

1. Visit [bex.co Dashboard](https://bex.co/dash/)
2. Sign up for a free account if you haven't already
3. Create a new API key for Mantle
4. Select your target network (Mainnet, Sepolia, etc.)

### Step 2: Make Your First Request

#### Using cURL

```bash
curl -X POST https://api.bex.co/mantle/${accessKey} \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_blockNumber",
    "params": [],
    "id": 1
  }'
```

#### Using JavaScript (Fetch)

```javascript
const response = await fetch('https://api.bex.co/mantle/${accessKey}', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'eth_blockNumber',
    params: [],
    id: 1
  })
});

const data = await response.json();
console.log('Current block number:', parseInt(data.result, 16));
```

#### Using Python

```python
import requests
import json

url = "https://api.bex.co/mantle/${accessKey}"
payload = {
    "jsonrpc": "2.0",
    "method": "eth_blockNumber",
    "params": [],
    "id": 1
}

response = requests.post(url, json=payload)
result = response.json()
print(f"Current block number: {int(result['result'], 16)}")
```

## Core RPC Methods

### Account Information

```javascript
// Get account balance
{
  "jsonrpc": "2.0",
  "method": "eth_getBalance",
  "params": ["0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4", "latest"],
  "id": 1
}

// Get transaction count (nonce)
{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionCount",
  "params": ["0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4", "latest"],
  "id": 1
}
```

### Block Information

```javascript
// Get latest block
{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByNumber",
  "params": ["latest", true],
  "id": 1
}

// Get block by hash
{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByHash",
  "params": ["0x1234...abcd", true],
  "id": 1
}
```

### Transaction Operations

```javascript
// Get transaction by hash
{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionByHash",
  "params": ["0x1234...abcd"],
  "id": 1
}

// Send raw transaction
{
  "jsonrpc": "2.0",
  "method": "eth_sendRawTransaction",
  "params": ["0x1234...abcd"],
  "id": 1
}
```

## Network Endpoints

### Mainnet
- **HTTP**: `https://api.bex.co/mantle/${accessKey}`
- **WebSocket**: `wss://api.bex.co/mantle/${accessKey}`

### Testnets
- **Sepolia**: `https://ethereum-sepolia.bex.co/<your-api-key>`
- **Holesky**: `https://ethereum-holesky.bex.co/<your-api-key>`

### Layer 2 Networks
- **Polygon**: `https://polygon-mainnet.bex.co/<your-api-key>`
- **Arbitrum**: `https://arbitrum-mainnet.bex.co/<your-api-key>`
- **Optimism**: `https://optimism-mainnet.bex.co/<your-api-key>`

## Authentication & Security

### API Key Authentication
All requests require your API key in the URL path. Keep your API key secure and never expose it in client-side code.

### Rate Limits
- **Free tier**: 100 requests per second
- **Pro tier**: 1,000 requests per second
- **Enterprise**: Custom limits

### Best Practices
1. **Use HTTPS** for all API calls
2. **Implement retry logic** with exponential backoff
3. **Cache responses** when appropriate
4. **Monitor your usage** in the dashboard
5. **Use batch requests** for multiple operations

## Common Use Cases

### Check Account Balance

```javascript
async function getBalance(address) {
  const response = await fetch('https://api.bex.co/mantle/${accessKey}', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'eth_getBalance',
      params: [address, 'latest'],
      id: 1
    })
  });
  
  const data = await response.json();
  const balanceWei = BigInt(data.result);
  const balanceEth = balanceWei / BigInt('1000000000000000000');
  return balanceEth.toString();
}
```

### Monitor New Blocks

```javascript
// Using WebSocket for real-time updates
const ws = new WebSocket('wss://api.bex.co/mantle/${accessKey}');

ws.on('open', () => {
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    method: 'eth_subscribe',
    params: ['newHeads'],
    id: 1
  }));
});

ws.on('message', (data) => {
  const result = JSON.parse(data);
  if (result.params) {
    console.log('New block:', result.params.result);
  }
});
```

### Smart Contract Interaction

```javascript
async function callContract(contractAddress, data) {
  const response = await fetch('https://api.bex.co/mantle/${accessKey}', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'eth_call',
      params: [
        {
          to: contractAddress,
          data: data
        },
        'latest'
      ],
      id: 1
    })
  });
  
  return await response.json();
}
```

## Error Handling

### Common Error Codes

```javascript
// Handle RPC errors properly
async function safeRpcCall(method, params) {
  try {
    const response = await fetch(endpoint, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        jsonrpc: '2.0',
        method,
        params,
        id: 1
      })
    });
    
    const data = await response.json();
    
    if (data.error) {
      throw new Error(`RPC Error ${data.error.code}: ${data.error.message}`);
    }
    
    return data.result;
  } catch (error) {
    console.error('RPC call failed:', error);
    throw error;
  }
}
```

### Retry Logic

```javascript
async function withRetry(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, i)));
    }
  }
}
```

## Next Steps

- Explore the [Mantle JSON-RPC API Reference]./mantle-json-rpc-api.md for complete method documentation
- Learn about [WebSocket Connections]./mantle-websockets.md for real-time data
- Follow our [Web3.js Integration Guide]./mantle-web3-integration.md for frontend development
- Check out our [Ethers.js Integration Guide]./mantle-ethers-integration.md for modern development patterns

## Resources

- [Mantle Official Documentation](https://ethereum.org/en/developers/docs/)
- [JSON-RPC Specification](https://ethereum.github.io/execution-apis/api-documentation/)
- [EIP Standards](https://eips.ethereum.org/)
- [bex.co Dashboard](https://bex.co/dash/)
- [Support & Community](https://discord.gg/eWZvE4RSBw)

## Need Help?

- 📧 **Email**: hello@bex.co
- 💬 **Discord**: [Join our community](https://discord.gg/eWZvE4RSBw)
- 🐦 **Twitter**: [@BlockEdenHQ](https://twitter.com/BlockEdenHQ)
- 📖 **Documentation**: [docs.bex.co](https://docs.bex.co)

---

**Cost**: 300 CUs / req
