Skip to main content

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 is a complete and compact library for interacting with the Ethereum blockchain. It’s the most popular choice for modern dApp development. Installation:
npm install ethers
Basic Usage:
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), 'OM');

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

Viem

Viem is a modern, lightweight alternative to ethers.js with better TypeScript support and modular architecture. Installation:
npm install viem
Basic Usage:
import { createPublicClient, createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';

// Define MANTRA Chain
const mantraChain = {
  id: 5888,
  name: 'MANTRA Chain',
  nativeCurrency: { name: 'OM', symbol: 'OM', 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:

Web3.js

Web3.js is a collection of libraries for interacting with Ethereum nodes. It’s widely used but heavier than alternatives. Installation:
npm install web3
Basic Usage:
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'), 'OM');

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

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:
npm install @cosmjs/stargate @cosmjs/proto-signing
Basic Usage:
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...', 'uom');
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: 'uom', amount: '1000000' }],
  'auto'
);
Resources:

Keplr Wallet Integration

Integrate with Keplr wallet for user authentication and transaction signing. Installation:
npm install @keplr-wallet/types
Basic Usage:
// 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: 'OM', coinMinimalDenom: 'uom', coinDecimals: 6 }],
  feeCurrencies: [{ coinDenom: 'OM', coinMinimalDenom: 'uom', coinDecimals: 6 }],
  stakeCurrency: { coinDenom: 'OM', coinMinimalDenom: 'uom', coinDecimals: 6 },
});

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

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

Go Libraries

Cosmos SDK

For building custom modules or interacting with MANTRA Chain programmatically in Go.
import (
    "github.com/cosmos/cosmos-sdk/client"
    "github.com/cosmos/cosmos-sdk/types"
)
Resources:

Python Libraries

Web3.py

Python library for EVM interactions. Installation:
pip install web3
Basic Usage:
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")} OM')
Resources:

CosmPy

Python library for Cosmos SDK chains. Installation:
pip install cosmpy
Resources:

Network Configuration Quick Reference

NetworkEVM RPCCosmos RPCChain ID (EVM)Chain ID (Cosmos)
Mainnethttps://evm.mantrachain.iohttps://rpc.mantrachain.io5888mantra-1
Testnethttps://evm.dukong.mantrachain.iohttps://rpc.dukong.mantrachain.io5887mantra-dukong-1

Next Steps