EVM Development
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:
npm install ethersBasic 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), 'MANTRA');
// 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 viemBasic Usage:
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:
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 web3Basic 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'), 'MANTRA');
// 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-signingBasic 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...', '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:
Keplr Wallet Integration
Integrate with Keplr wallet for user authentication and transaction signing.
Installation:
npm install @keplr-wallet/typesBasic 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: '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:
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 web3Basic 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")} MANTRA')Resources:
CosmPy
Python library for Cosmos SDK chains.
Installation:
pip install cosmpyResources:
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 - Get started with EVM development
- Network Details - Full endpoint reference
- EVM Getting Started - Complete EVM development guide