This helps in getting the wallet balance with this method.
Creates a new wallet under the given instance.
200: OK Success 417: Expectation Failed incorrect chain id
Copy {
"Status" : "SUCCESS" ,
"Message" : "" ,
"Data" : {
"address" : "xxxxxxxxxxxxxxxxx" ,
"balance" : 190909345505164350
}
}
Copy {
"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 Node.js (Fetch) Python Golang
Copy curl -X POST http://localhost:8889/wallet/getBalance \
-H "Content-Type: application/json" \
-d '{
"walletId": "xxxxxxxxxxx",
"chainId": "xxxxxxxxxxx"
}'
Copy 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);
});
Copy 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)
Copy 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))
}