On this page

latest contributor to this doc

Last Edit:

@smk762

balance_enable

Using this method, you can enable balance events streaming for a specific coin, to a specific client. For ETH-like coins and tokens, you can also specify the streaming interval in seconds (to avoid excessive polling leading to upstream API rate limts)

ParameterTypeDescription
coinstringTicker of the coin to activate streaming for. The coin must be activated first.
client_idintegerOptional. In the case of a single client, this defaults to 0. This ID can be used to access data via http://localhost:7783/event-stream?id=1
configobjectOptional, EVM only. A standard StreamingFeeConfig object.

The client defines its own id when opening a connection to the stream, and each client_id can only be viewed by a single client (i.e. the ?id= url param won't work in more than one browser tab). The selected coin must be enabled prior to enabling streaming.

ParameterTypeDescription
streamer_idstringAn identifier for the data stream. This can be used later to disable streaming for the event with stream::disable.

POST
balance_enable
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "stream::balance::enable",
  "mmrpc": "2.0",
  "params": {
    "coin": "MATIC",
    "config": {
      "stream_interval_seconds": 15
    },
    "client_id": 1
  }
}

Here is an example of the stream data you should be able to see in http://localhost:7783/event-stream?id=1 once a balance change is detected:

data: {"_type":"BALANCE:MATIC","message":[{"ticker":"MATIC","address":"0xc11b6070c84a1e6fc62b2a2acf70831545d5edd4","balance":{"spendable":"2.00000001","unspendable":"0"}}]}