Get Wallet balance
This helps in getting the wallet balance with this method.
API Specification
Get Wallet balance
POST http://localhost:8889/wallet/getBalance
Creates a new wallet under the given instance.
Request Body
Name
Type
Description
walletId*
String
wallet id
chainId*
String
chainId
{
  "Status": "SUCCESS",
  "Message": "",
  "Data": {
    "address": "xxxxxxxxxxxxxxxxx",
    "balance": 190909345505164350
  }
}{
    "Status": "FAILURE",
    "Message": "mongo: no documents in result",
    "Data": null
}Take a look at how you might call this method using our official libraries, or via curl:
curl -X POST http://localhost:8889/wallet/getBalance \
-H "Content-Type: application/json" \
-d '{
  "walletId": "xxxxxxxxxxx",
  "chainId": "xxxxxxxxxxx"
}'const axios = require('axios');
const apiUrl = 'http://localhost:8889/wallet/getBalance';
const headers = {
  'Content-Type': 'application/json',
};
const requestData = {
  "walletId": "xxxxxxxxxxx",
  "chainId": "xxxxxxxxxxx"
};
axios.post(apiUrl, requestData, { headers })
  .then((response) => {
    console.log('Response:', response.data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });
import requests
url = 'http://localhost:8889/wallet/getBalance'
headers = {
    'Content-Type': 'application/json',
}
data = {
    "walletId": "xxxxxxxxxxx",
    "chainId": "xxxxxxxxxxx"
}
try:
    response = requests.post(url, json=data, headers=headers)
    response.raise_for_status()  # Raise an exception for 4xx or 5xx status codes
    print('Response:', response.json())
except requests.exceptions.RequestException as error:
    print('Error:', error)
package main
import (
	"fmt"
	"net/http"
	"strings"
	"io/ioutil"
)
func main() {
	url := "http://localhost:8889/wallet/getBalance"
	method := "POST"  // Change method to POST
	payload := strings.NewReader(`{
		"walletId": "xxxxxxxxxxxxxxxxx",
		"chainId": "xxxx"
	}`)
	client := &http.Client{}
	req, err := http.NewRequest(method, url, payload)
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}
	req.Header.Add("Content-Type", "application/json")
	res, err := client.Do(req)
	if err != nil {
		fmt.Println("Error making request:", err)
		return
	}
	defer res.Body.Close()
	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		fmt.Println("Error reading response:", err)
		return
	}
	fmt.Println("Response:", string(body))
}
Last updated
Was this helpful?