Tatum
Search…
How to block amounts in a virtual account
Most blockchains do not allow the blocking or freezing of assets at blockchain addresses. But in real life, many applications must block blockchain assets before the actual transaction. It is the same as with a debit card and a real bank account. First, funds are blocked, and then the transaction is processed a couple of days later.
When you work with Tatum Virtual Accounts, there are two types of balances:
  • account balance - a sum of all funds that are present in the account
  • available balance - a sum of all funds that are available for spending
The available balance can even be negative when there are blockages in the account. When the balance is below zero, transactions cannot be performed, but new blockages can be made.
Blockages affect the available balance of the account. Every new blockage has its unique identifier and details, like its type or custom description.

Blocking funds in a virtual account

​To block funds in an account, the account ID, amount, and type are required parameters.
JavaScript
cURL
1
import {blockAmount} from '@tatumio/tatum';
2
/**
3
* Blocks an amount in an account.
4
* Any number of distinct amounts can be blocked in one account.
5
* @param id - ledger account ID
6
* @param body - request body with blocked amount - https://apidoc.tatum.io/tag/Account/#operation/blockAmount
7
*/
8
const body = {
9
"amount": "5",
10
"type": "DEBIT_CARD_OP",
11
"description": "Card payment in the shop."
12
}
13
const txId = blockAmount("5fbaca3001421166273b3779", body);
Copied!
1
curl --location --request POST 'https://api-eu1.tatum.io/v3/ledger/account/block/5fbaca3001421166273b3779' \
2
--header 'x-api-key: YOUR_API_KEY' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{
5
"amount": "5",
6
"type": "DEBIT_CARD_OP",
7
"description": "Card payment in the shop."
8
}'
Copied!
The response is the identifier of the blockage.
Response
1
{
2
"id": "5fbe2b9b99166cb792cba6f2"
3
}
Copied!

Getting an account's details

You can now get details about the account where we made the blockage to see what has happened with the balance.
JavaScript
cURL
1
import {getAccountById} from '@tatumio/tatum';
2
/**
3
* Gets active account by ID.
4
* Displays all information regarding the given account - https://apidoc.tatum.io/tag/Account/#operation/getAccountByAccountId
5
* @param id - ledger account ID
6
*/
7
const account = getAccountById("5fbaca3001421166273b3779");
Copied!
1
curl --location --request GET 'https://api-eu1.tatum.io/v3/ledger/account/5fbaca3001421166273b3779' \
2
--header 'x-api-key: YOUR_API_KEY'
Copied!
The response will contain the details of the virtual account associated with the specified account ID.
Response
1
{
2
"currency": "BTC",
3
"active": true,
4
"balance": {
5
"accountBalance": "0.000001",
6
"availableBalance": "-4.999999"
7
},
8
"accountCode": null,
9
"accountNumber": null,
10
"frozen": false,
11
"xpub": "tpubDF1sYuDKCJr6mGietaVzqGmF2dqdKVBa1DtLJGBX8HXhtHZPv5UBz3WNWU22tiVAYSjqfvfFxMnDs3vM11iQrKej6dq33UCevhiPW9EQAS2",
12
"accountingCurrency": "EUR",
13
"id": "5fbaca3001421166273b3779"
14
}
Copied!

Getting all blockages in the account

As you can see, there were 5 bitcoins blocked in the account, so the available balance is negative. Now you can get all blockages in the specific account.​
JavaScript
cURL
1
import { getBlockedAmountsByAccountId } from '@tatumio/tatum';
2
/**
3
* Gets blocked amounts for an account.
4
* @param id - account ID
5
* @param pageSize - max number of items per page is 50
6
* @param offset - optional Offset to obtain next page of the data
7
* @returns - detail of blocked amounts - https://apidoc.tatum.io/tag/Account/#operation/getBlockAmount
8
*/
9
10
const amounts = getBlockedAmountsByAccountId("5fbaca3001421166273b3779?pageSize=50");
Copied!
1
curl --location --request GET 'https://api-eu1.tatum.io/v3/ledger/account/block/5fbaca3001421166273b3779?pageSize=50' \
2
--header 'x-api-key: YOUR_API_KEY'
Copied!
The response will contain a list of all current blockages for the account ID.
Response
1
[
2
{
3
"amount": "5",
4
"type": "DEBIT_CARD_OP",
5
"description": "Card payment in the shop.",
6
"accountId": "5fbaca3001421166273b3779",
7
"id": "5fbe2b9b99166cb792cba6f2"
8
}
9
]
Copied!
When you want to unblock an amount from the account, you have several options:
  • unblock a specific blockage - this will unblock the whole amount, and the account's available balance will be increased.
  • unblock a blockage and perform a virtual account transaction - this will unblock the amount from the account and perform a transaction to a different account.
  • unblock all blocked amounts in the account - this will unblock all blockages in the account.

Unblocking an amount in the account

Let's unblock a blockage without a transaction. You'll need to pass the ID of the specific blockage you want to unblock.
JavaScript
cURL
1
import {deleteBlockedAmount} from '@tatumio/tatum';
2
/**
3
* Unblocks a previously blocked amount in an account.
4
* Increases the available balance in the account where the amount was blocked.
5
* @param id - transaction ID of blocked amount
6
*/
7
const account = deleteBlockedAmount ("5fbe2b9b99166cb792cba6f2");
Copied!
1
curl --location --request DELETE 'https://api-eu1.tatum.io/v3/ledger/account/block/5fbe2b9b99166cb792cba6f2' \
2
--header 'x-api-key: YOUR_API_KEY'
Copied!
There will be an empty response if the request is successful. Now, when you check the details of the account, you will see the availableBalance is the same as the accountBalance.
JavaScript
cURL
1
import {getAccountById} from '@tatumio/tatum';
2
/**
3
* Gets active account by ID.
4
* Displays all information regarding the given account - https://apidoc.tatum.io/tag/Account/#operation/getAccountByAccountId
5
* @param id - ledger account ID
6
*/
7
const account = getAccountById("5fbaca3001421166273b3779");
Copied!
1
curl --location --request GET 'https://api-eu1.tatum.io/v3/ledger/account/5fbaca3001421166273b3779' \
2
--header 'x-api-key: YOUR_API_KEY'
Copied!
Response
1
{
2
"currency": "BTC",
3
"active": true,
4
"balance": {
5
"accountBalance": "0.000001",
6
"availableBalance": "0.000001"
7
},
8
"accountCode": null,
9
"accountNumber": null,
10
"frozen": false,
11
"xpub": "tpubDF1sYuDKCJr6mGietaVzqGmF2dqdKVBa1DtLJGBX8HXhtHZPv5UBz3WNWU22tiVAYSjqfvfFxMnDs3vM11iQrKej6dq33UCevhiPW9EQAS2",
12
"accountingCurrency": "EUR",
13
"id": "5fbaca3001421166273b3779"
14
}
Copied!
You can test other unblocking methods or read more about the specific endpoints in the API Reference.