Skip to content

Commit 4279186

Browse files
document /account/:account/balance/asset/:asset API
1 parent 6090bfa commit 4279186

1 file changed

Lines changed: 52 additions & 26 deletions

File tree

Developers/API.md

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ METHOD| PATH | DESCRIPTION
4949
`GET` |`/chain/hashrate/:windows`| Show current hashrate based on latest `n` blocks
5050
`GET` |`/chain/hashrate/chart/:from/:to/:window`|
5151
`POST` |`/chain/append`| Append mined block
52-
`GET` |`/account/:account/balance`| Show balance of specific account
52+
`GET` |`/account/:account/balance/asset/:asset`| Show balance of specific account for an asset
5353
`GET` |`/account/:account/history/:beforeTxIndex`| Show transaction history of specific account
5454
`GET` |`/peers/ip_count`| Show peer IPs
5555
`GET` |`/peers/banned`| Show banned peers
@@ -374,36 +374,62 @@ Example output of `/chain/hashrate/100`
374374
Append mined block. Miners must POST mined block they received from `GET /chain/mine/:address`.
375375
TODO: Detailed description
376376
377-
### `GET /account/:account/balance`
377+
### `GET /account/:account/balance/asset/:asset`
378378
379-
Show balance of specific account. Example output:
379+
Show balance of an account for a specific asset. The `:account` parameter is the account address, and `:asset` is the asset identifier (e.g., `asset:0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c`).
380+
381+
#### Balance Types
382+
383+
The API returns three balance types:
384+
385+
| Type | Description |
386+
|------|-------------|
387+
| `total` | The total balance of the account |
388+
| `locked` | Balance locked in open orders |
389+
| `mempool` | Balance currently used by pending transactions in the mempool |
390+
391+
Spendable amount is `total - locked` and can be reused for new transactions. If `total - locked` is sufficient but `total - locked - mempool` is not, the system may evict lower-fee transactions from the mempool to make room for a higher-fee transaction.
392+
393+
Example output:
380394
381395
```json
382396
{
383-
"code": 0,
384-
"data": {
385-
"accountId": 198,
386-
"balance": "5027.00000000",
387-
"balanceE8": 502700000000
388-
}
389-
}
390-
{
391-
"code": 0,
392-
"data": {
393-
"blockReward": "3.00000000",
394-
"blockRewardE8": 300000000,
395-
"body": "000000000000000000000001e94f274f08cf64bd76688ffb34012269e045b737000000000000098d0000000011e1a300",
396-
"difficulty": 30866431555762.105,
397-
"header": "50eaaf1453c84cabef749af9064d73d881174a44d7f165122400604e71342f9d0b2479fd6ec2b44e00bed326c9116b2f85f9f72bdd2157cc521cf49d0cf360fad91b881e00000002660ab00400000000",
398-
"height": 1198924,
399-
"merklePrefix": "72aa3aa84afd92af788b750d28ed9fe247d8788956bbdddc5a92cbdcb5925e4fbe20dcff8dc31364a524061ff0235bd78c9786d6d29dd2a73b49efacb57966d6",
400-
"synced": true,
401-
"testnet": false,
402-
"totalTxFee": "0",
403-
"totalTxFeeE8": 0
397+
"code": 0,
398+
"data": {
399+
"account": {
400+
"accountId": 9,
401+
"address": "2de77d5e23dc63e4c4149d394c979361e9e8e966336c8cd4"
402+
},
403+
"balance": {
404+
"locked": {
405+
"precision": 4,
406+
"str": "12479.9990",
407+
"u64": 124799990
408+
},
409+
"mempool": {
410+
"precision": 4,
411+
"str": "100.0000",
412+
"u64": 1000000
413+
},
414+
"total": {
415+
"precision": 4,
416+
"str": "30899.9999",
417+
"u64": 308999999
418+
}
419+
},
420+
"lookupTrace": {
421+
"fails": [],
422+
"snapshotHeight": null
423+
},
424+
"token": {
425+
"id": 15,
426+
"name": "TOK2",
427+
"precision": 4,
428+
"spec": "asset:0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c"
429+
}
430+
}
404431
}
405-
}
406-
```
432+
```
407433
408434
### `GET /account/:account/history/:beforeTxIndex`
409435

0 commit comments

Comments
 (0)