> ## Documentation Index
> Fetch the complete documentation index at: https://mantrachain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs & Libraries

> Software development kits and libraries for building on MANTRA Chain

## Overview

MANTRA Chain supports both EVM and Cosmos SDK development. This page covers the available SDKs and libraries for each ecosystem.

## EVM Libraries

These libraries work with MANTRA Chain's EVM module for Solidity smart contract development.

### Ethers.js (Recommended)

Ethers.js is a complete and compact library for interacting with the Ethereum blockchain. It's the most popular choice for modern dApp development.

**Installation:**

```bash theme={null}
npm install ethers
```

**Basic Usage:**

```javascript theme={null}
import { ethers } from 'ethers';

// Connect to MANTRA Chain
const provider = new ethers.JsonRpcProvider('https://evm.mantrachain.io');

// Create wallet instance
const wallet = new ethers.Wallet(privateKey, provider);

// Get balance
const balance = await provider.getBalance(wallet.address);
console.log('Balance:', ethers.formatEther(balance), 'MANTRA');

// Send transaction
const tx = await wallet.sendTransaction({
  to: recipientAddress,
  value: ethers.parseEther('1.0')
});
await tx.wait();
```

**Resources:**

* [Ethers.js v6 Documentation](https://docs.ethers.org/v6/)
* [GitHub Repository](https://github.com/ethers-io/ethers.js)

### Viem

Viem is a modern, lightweight alternative to ethers.js with better TypeScript support and modular architecture.

**Installation:**

```bash theme={null}
npm install viem
```

**Basic Usage:**

```typescript theme={null}
import { createPublicClient, createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';

// Define MANTRA Chain
const mantraChain = {
  id: 5888,
  name: 'MANTRA Chain',
  nativeCurrency: { name: 'MANTRA', symbol: 'MANTRA', decimals: 18 },
  rpcUrls: {
    default: { http: ['https://evm.mantrachain.io'] },
  },
  blockExplorers: {
    default: { name: 'Blockscout', url: 'https://blockscout.mantrascan.io' },
  },
};

// Create clients
const publicClient = createPublicClient({
  chain: mantraChain,
  transport: http(),
});

const account = privateKeyToAccount(privateKey);
const walletClient = createWalletClient({
  account,
  chain: mantraChain,
  transport: http(),
});

// Get balance
const balance = await publicClient.getBalance({ address: account.address });
```

**Resources:**

* [Viem Documentation](https://viem.sh/)
* [GitHub Repository](https://github.com/wevm/viem)

### Web3.js

Web3.js is a collection of libraries for interacting with Ethereum nodes. It's widely used but heavier than alternatives.

**Installation:**

```bash theme={null}
npm install web3
```

**Basic Usage:**

```javascript theme={null}
import Web3 from 'web3';

const web3 = new Web3('https://evm.mantrachain.io');

// Get balance
const balance = await web3.eth.getBalance(address);
console.log('Balance:', web3.utils.fromWei(balance, 'ether'), 'MANTRA');

// Send transaction
const tx = await web3.eth.sendTransaction({
  from: senderAddress,
  to: recipientAddress,
  value: web3.utils.toWei('1', 'ether'),
});
```

**Resources:**

* [Web3.js Documentation](https://docs.web3js.org/)
* [GitHub Repository](https://github.com/web3/web3.js)

***

## Cosmos SDK Libraries

These libraries interact with MANTRA Chain's native Cosmos SDK modules.

### CosmJS

CosmJS is the official JavaScript library for Cosmos SDK chains. Use it for native token transfers, staking, governance, and IBC operations.

**Installation:**

```bash theme={null}
npm install @cosmjs/stargate @cosmjs/proto-signing
```

**Basic Usage:**

```javascript theme={null}
import { SigningStargateClient, StargateClient } from '@cosmjs/stargate';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';

// Connect (read-only)
const client = await StargateClient.connect('https://rpc.mantrachain.io');

// Get balance
const balance = await client.getBalance('mantra1...', 'amantra');
console.log('Balance:', balance);

// Create signing client
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
  prefix: 'mantra',
});
const signingClient = await SigningStargateClient.connectWithSigner(
  'https://rpc.mantrachain.io',
  wallet
);

// Send tokens
const result = await signingClient.sendTokens(
  senderAddress,
  recipientAddress,
  [{ denom: 'amantra', amount: '1000000000000000000' }],
  'auto'
);
```

**Resources:**

* [CosmJS Documentation](https://cosmos.github.io/cosmjs/)
* [GitHub Repository](https://github.com/cosmos/cosmjs)

### Keplr Wallet Integration

Integrate with Keplr wallet for user authentication and transaction signing.

**Installation:**

```bash theme={null}
npm install @keplr-wallet/types
```

**Basic Usage:**

```javascript theme={null}
// Suggest MANTRA Chain to Keplr
await window.keplr.experimentalSuggestChain({
  chainId: 'mantra-1',
  chainName: 'MANTRA Chain',
  rpc: 'https://rpc.mantrachain.io',
  rest: 'https://api.mantrachain.io',
  bip44: { coinType: 118 },
  bech32Config: {
    bech32PrefixAccAddr: 'mantra',
    bech32PrefixAccPub: 'mantrapub',
    bech32PrefixValAddr: 'mantravaloper',
    bech32PrefixValPub: 'mantravaloperpub',
    bech32PrefixConsAddr: 'mantravalcons',
    bech32PrefixConsPub: 'mantravalconspub',
  },
  currencies: [{ coinDenom: 'MANTRA', coinMinimalDenom: 'amantra', coinDecimals: 18 }],
  feeCurrencies: [{ coinDenom: 'MANTRA', coinMinimalDenom: 'amantra', coinDecimals: 18 }],
  stakeCurrency: { coinDenom: 'MANTRA', coinMinimalDenom: 'amantra', coinDecimals: 18 },
});

// Enable chain
await window.keplr.enable('mantra-1');

// Get signer
const offlineSigner = window.keplr.getOfflineSigner('mantra-1');
```

**Resources:**

* [Keplr Documentation](https://docs.keplr.app/)
* [GitHub Repository](https://github.com/chainapsis/keplr-wallet)

***

## Go Libraries

### Cosmos SDK

For building custom modules or interacting with MANTRA Chain programmatically in Go.

```go theme={null}
import (
    "github.com/cosmos/cosmos-sdk/client"
    "github.com/cosmos/cosmos-sdk/types"
)
```

**Resources:**

* [Cosmos SDK Documentation](https://docs.cosmos.network/)
* [MANTRA Chain GitHub](https://github.com/MANTRA-Chain/mantrachain)

***

## Python Libraries

### Web3.py

Python library for EVM interactions.

**Installation:**

```bash theme={null}
pip install web3
```

**Basic Usage:**

```python theme={null}
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://evm.mantrachain.io'))

# Check connection
print(w3.is_connected())

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

**Resources:**

* [Web3.py Documentation](https://web3py.readthedocs.io/)

### CosmPy

Python library for Cosmos SDK chains.

**Installation:**

```bash theme={null}
pip install cosmpy
```

**Resources:**

* [CosmPy Documentation](https://docs.fetch.ai/cosmpy/)
* [GitHub Repository](https://github.com/fetchai/cosmpy)

***

## Network Configuration Quick Reference

| Network | EVM RPC | Cosmos RPC | Chain ID (EVM) | Chain ID (Cosmos) |
| - | - | - | - | - |
| Mainnet | `https://evm.mantrachain.io` | `https://rpc.mantrachain.io` | `5888` | `mantra-1` |
| Testnet | `https://evm.dukong.mantrachain.io` | `https://rpc.dukong.mantrachain.io` | `5887` | `mantra-dukong-1` |

## Next Steps

* [Deploy a Smart Contract](https://mantrachain.mintlify.site/deploy-smart-contract.md) - Get started with EVM development
* [Network Details](https://mantrachain.mintlify.site/resources/network-details.md) - Full endpoint reference
* [EVM Getting Started](https://mantrachain.mintlify.site/developers/evm/getting-started.md) - Complete EVM development guide


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.