Task: Account Balance
If you have enabled a coin with task managed activation and are using HD Mode, your funds may be spread across a range of addresses under a specified account index. The methods below will return the combined balance of your account, detailing the balance for each active account address.
task::account_balance::init
Use the task::account_balance::init method to initialise an account balance request.
Arguments
| Parameter | Type | Description |
|---|---|---|
| coin | string | Ticker of activated coin you want to see addresses and balance for |
| account_index | string | For GUIs, this will be zero. In CLI you can use other values if you know what you are doing |
Response
| Parameter | Type | Description |
|---|---|---|
| task_id | integer | An identifying number which is used to query task status. |
📌 Examples
Command
POST task::account_balance::init
{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::init",
"params": {
"coin": "COIN_NAME",
"account_index": 0
}
} curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::init",
"params": {
"coin": "COIN_NAME",
"account_index": 0
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::init",
"params": {
"coin": "COIN_NAME",
"account_index": 0
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::init",
"params": {
"coin": "COIN_NAME",
"account_index": 0
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::init",
"params": {
"coin": "COIN_NAME",
"account_index": 0
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"task::account_balance::init","params":{"coin":"COIN_NAME","account_index":0}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::init",
"params": {
"coin": "COIN_NAME",
"account_index": 0
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Response
Response (ready, successful)
{
"mmrpc": "2.0",
"result": {
"task_id": 6
},
"id": null
} task::account_balance::status
Use the task::account_balance::status method to view the status / response of an account balance request.
Arguments
| Parameter | Type | Description |
|---|---|---|
| task_id | integer | The identifying number returned when initiating the task. |
| forget_if_finished | boolean | If false, will return final response for completed tasks. Optional, defaults to true. |
Response
| Parameter | Type | Description |
|---|---|---|
| current_block | integer | Block height of the coin being activated |
| ticker | string | Ticker of the coin being activated. |
| wallet_balance | object | A standard WalletBalanceInfo object. Note: the structure may vary based on the get_balances parameter value in the activation request. |
📌 Examples
Command
POST task::account_balance::status
{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::status",
"params": {
"task_id": 3,
"forget_if_finished": false
}
} curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::status",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::status",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::status",
"params": {
"task_id": 3,
"forget_if_finished": false
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::status",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"task::account_balance::status","params":{"task_id":3,"forget_if_finished":false}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::status",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Response
Response (ready, successful)
{
"mmrpc": "2.0",
"result": {
"status": "Ok",
"details": {
"account_index": 0,
"derivation_path": "m/44'/20'/0'",
"total_balance": {
"KMD": {
"spendable": "99.999",
"unspendable": "0"
}
},
"addresses": [
{
"address": "DJdsr4Mhqm1afkbxwBJfwH6236xNh5kJZU",
"derivation_path": "m/44'/20'/0'/0/0",
"chain": "External",
"balance": {
"KMD": {
"spendable": "49.999",
"unspendable": "0"
}
}
},
{
"address": "DJdsr4Mhqm1afkbxwBJfwH6236xNh5kJZU",
"derivation_path": "m/44'/20'/0'/0/1",
"chain": "External",
"balance": {
"KMD": {
"spendable": "50",
"unspendable": "0"
}
}
},
{
"address": "DJdsr4Mhqm1afkbxwBJfwH6236xNh5kJZU",
"derivation_path": "m/44'/20'/0'/0/2",
"chain": "External",
"balance": {
"KMD": {
"spendable": "0",
"unspendable": "0"
}
}
}
]
}
},
"id": null
} task::account_balance::cancel
Use the task::account_balance::cancel method to cancel an account balance request.
Arguments
| Parameter | Type | Description |
|---|---|---|
| task_id | integer | The identifying number returned when initiating the task. |
Response
| Parameter | Type | Description |
|---|---|---|
| result | string | Returns with value success when successful, otherwise returns the error values below |
| error | string | Description of the error |
| error_path | string | Used for debugging. A reference to the function in code base which returned the error |
| error_trace | string | Used for debugging. A trace of lines of code which led to the returned error |
| error_type | string | An enumerated error identifier to indicate the category of error |
| error_data | string | Additonal context for the error type |
📌 Examples
Command
POST task::account_balance::cancel
{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::cancel",
"params": {
"task_id": 3,
"forget_if_finished": false
}
} curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::cancel",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::cancel",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::cancel",
"params": {
"task_id": 3,
"forget_if_finished": false
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::cancel",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"task::account_balance::cancel","params":{"task_id":3,"forget_if_finished":false}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::account_balance::cancel",
"params": {
"task_id": 3,
"forget_if_finished": false
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Response
Response (ready, successful)
{
"mmrpc": "2.0",
"result": "success",
"id": null
}Response (error, task already finished)
{
"mmrpc": "2.0",
"error": "Task is finished already",
"error_path": "init_account_balance.manager",
"error_trace": "init_account_balance:113] manager:104]",
"error_type": "TaskFinished",
"error_data": 2,
"id": null
}