Home·Validation Tools·mantrachain
mantrachain logo
By LavenderFive

Learn how to interact with mantrachain nodes using different endpoint types.

#Available Endpoints

ServiceEndpoint
REST APIhttps://rest.lavenderfive.com:443/mantrachain
RPChttps://rpc.lavenderfive.com:443/mantrachain
gRPChttps://grpc.lavenderfive.com:443/mantrachain
WebSockethttp://rest.lavenderfive.com:443/mantrachain/ws
JSON-RPChttp://rest.lavenderfive.com:443/mantrachain/ws
WS-JSON-RPChttp://rest.lavenderfive.com:443/mantrachain/ws
    Some endpoints may require an API key for access. You can get one by signing up at https://lavenderfive.com.

#🌐 API Documentation

Interactive Swagger documentation for mantrachain endpoints is available at: https://rest.lavenderfive.com:443/mantrachain/swagger/

This documentation provides a comprehensive overview of all available endpoints, their parameters, and response formats. You can test API calls directly from the Swagger interface. It might however not be available for all networks due to how their RPC interface is coded.

#🌐 REST API Examples

#Cosmos SDK < v0.50

# Query Validators
curl -X GET "https://rest.lavenderfive.com:443/mantrachain/cosmos/staking/v1beta1/validators" \
  -H "x-api-key: your-api-key-uuid"

# Query Bank Balance
curl -X GET "https://rest.lavenderfive.com:443/mantrachain/cosmos/bank/v1beta1/balances/cosmos1..." \
  -H "x-api-key: your-api-key-uuid"

#Cosmos SDK >= v0.50

# Query Validators
curl -X GET "https://rest.lavenderfive.com:443/mantrachain/staking/validators" \
  -H "x-api-key: your-api-key-uuid"

# Query Delegations
curl -X GET "https://rest.lavenderfive.com:443/mantrachain/staking/validators/mantravaloper1.../delegations/mantra1..." \
  -H "x-api-key: your-api-key-uuid"
    Cosmos SDK v0.50+ removes the "v1beta1" prefix and "cosmos" namespace from endpoints for cleaner URLs. Both styles are shown above for compatibility.

#Query Account Balance (JavaScript)

const address = "cosmos1..."; // Your address
const endpoint = "https://rest.lavenderfive.com:443/mantrachain";

async function getBalance() {
  // For SDK &gt;= v0.50
  const path = `/bank/balances/${address}`;
  // For SDK &lt; v0.50
  // const path = `/cosmos/bank/v1beta1/balances/${address}`;
  
  const response = await fetch(
    `${endpoint}${path}`,
    {
      headers: {
        'x-api-key': 'your-api-key-uuid'
      }
    }
  );
  const data = await response.json();
  console.log(data);
}

#Query Validators (Python)

import requests

def get_validators():
    headers = {
        'x-api-key': 'your-api-key-uuid'
    }
    # For SDK &gt;= v0.50
    endpoint = f"{api}/staking/validators"
    # For SDK &lt; v0.50
    # endpoint = f"{api}/cosmos/staking/v1beta1/validators"
    
    response = requests.get(endpoint, headers=headers)
    return response.json()

#🔄 RPC Examples

#Get Network Status (curl)

curl -X GET "https://rpc.lavenderfive.com:443/mantrachain/status" \
  -H "x-api-key: your-api-key-uuid"

#Get Latest Block (JavaScript)

const endpoint = "https://rpc.lavenderfive.com:443/mantrachain";

async function getLatestBlock() {
  const response = await fetch(
    `${endpoint}/block`,
    {
      headers: {
        'x-api-key': 'your-api-key-uuid'
      }
    }
  );
  const data = await response.json();
  console.log(data.result);
}

#📡 gRPC Examples

#Query Validator Set (grpcurl)

# For SDK &gt;= v0.50
grpcurl -H "x-api-key: your-api-key-uuid" \
  https://grpc.lavenderfive.com:443/mantrachain \
  staking.Query/Validators

# For SDK &lt; v0.50
grpcurl -H "x-api-key: your-api-key-uuid" \
  https://grpc.lavenderfive.com:443/mantrachain \
  cosmos.staking.v1beta1.Query/Validators

#Query Bank Balance (Python with grpcio)

import grpc
# For SDK &gt;= v0.50
from staking import query_pb2, query_pb2_grpc
# For SDK &lt; v0.50
# from cosmos.bank.v1beta1 import query_pb2, query_pb2_grpc

def get_balance(address):
    credentials = grpc.metadata_call_credentials(
        lambda context, callback: callback([("x-api-key", "your-api-key-uuid")], None)
    )
    
    channel = grpc.secure_channel(
        "https://grpc.lavenderfive.com:443/mantrachain", 
        grpc.composite_channel_credentials(
            grpc.ssl_channel_credentials(),
            credentials
        )
    )
    
    stub = query_pb2_grpc.QueryStub(channel)
    request = query_pb2.QueryBalanceRequest(address=address)
    
    response = stub.Balance(request)
    return response
    Remember to replace `your-api-key-uuid` with your actual API key in the examples above.

#🔑 Common Response Codes

CodeDescription
200Successful request
400Bad request / Invalid parameters
401Unauthorized / Invalid API key
404Resource not found
429Too many requests
500Internal server error
    Rate limits may apply to endpoints. Please use for testing and get a trial API-key to try out a fully unlimited api for 14 days.

#⚡ JSON-RPC Examples

#Check Node Sync Status

curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: your-api-key-uuid" \
  --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' \
  http://rest.lavenderfive.com:443/mantrachain/ws

Expected response when node is synced:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": false
}
    A `false` result indicates the node is fully synced. If the node is still syncing, it will return an object with sync status details.

#Wagmi Configuration

import { http, fallback } from 'wagmi'
import { defineChain } from 'viem'

// Define your chain if not using a predefined one
const myChain = defineChain({
  id: 1,
  name: '{{ network_name }}', // Check WAGMI database if this network exists
  network: 'mantrachain',
  nativeCurrency: {
    decimals: 18,
    name: 'Native Token',
    symbol: 'TOKEN',
  },
  rpcUrls: {
    default: { http: ['http://rest.lavenderfive.com:443/mantrachain/ws'] },
  },
})

// Configure transport with API key
const transport = fallback([
  http('http://rest.lavenderfive.com:443/mantrachain/ws', {
    fetchOptions: { 
      headers: {
        'Content-Type': 'application/json',
        'X-Api-Key': 'your-api-key-uuid'
      }
    },
  }),
  // Add fallback RPC endpoints if available
  http('https://alternate-rpc-endpoint'),
])

// Use in your Wagmi config
const config = {
  chains: [myChain],
  transports: {
    [myChain.id]: transport,
  },
}
    This configuration can be used with both Wagmi and RainbowKit. For RainbowKit, you can integrate it into the `getDefaultConfig` as shown in the [RainbowKit documentation](https://www.rainbowkit.com/docs/custom-chains).
Chain ID:
mantra-1
Latest Version:
v1.0.2
Github:
MANTRA-Chain/mantrachain
Public endpoints
REST/LCD
rest.lavenderfive.com:443/mantrachain
RPC
rpc.lavenderfive.com:443/mantrachain
gRPC
grpc.lavenderfive.com:443/mantrachain
WebSocket
rest.lavenderfive.com:443/mantrachain/ws
Json-RPC
rest.lavenderfive.com:443/mantrachain/ws
Json-RPC (websocket)
rest.lavenderfive.com:443/mantrachain/ws
Lavender Five
© 2022 Lavender.Five Nodes. All rights reserved.
Terms of Service.Privacy policy.Cookies policy.