Virtual accounts

In this section, you will learn how virtual accounts works.

For information on what virtual accounts are and what you can do with them, refer to our overview.

How virtual accounts work

No blockchain fees for off-chain transfers

Because transactions between virtual accounts do not happen on the blockchain, they do not incur blockchain transaction fees and are happen instantly. This provides huge benefits for working with blockchains like Ethereum and Bitcoin, both of which have high transaction fees and slow transaction times.

Virtual accounts allow you to build solutions parallel to the blockchain and bypass the slow and often congested transaction mechanism of the blockchain itself. If your customers want to send their crypto outside of your application, they can withdraw it from their virtual account to their blockchain deposit addresses.

Deposit addresses and automatic balance updates

A virtual account has at least one real blockchain address associated with it. This blockchain address is called “deposit address”.

You can either connect an existing blockchain address (or addresses) to the virtual account or generate a new blockchain address and associate it with the account. In either case, the blockchain address becomes a deposit address for this virtual account.

Virtual accounts automatically scan associated deposit addresses for incoming transactions and update their own balances to reflect the assets received. Whenever any blockchain address connected to a virtual account receives an incoming transaction, the virtual account's balance will be updated to reflect the newly received funds.

Keep deposit addresses in full custody.

An accidental transfer/withdrawal of assets from a deposit address may break the balances. In the same way, you should never perform or allow transfers between two deposit addresses directly.

If you transfer assets from one virtual account to the other one, the total balance of all virtual accounts does not change.

Single currency per virtual account

Each virtual account is in a single currency. This can be either a cryptocurrency or a virtual fiat currency.

Virtual accounts can be connected to blockchain addresses or represent virtual currencies that can be pegged to a fiat currency. Virtual accounts can be in Bitcoin or Ethereum, Euro or U.S. dollar. Using virtual currencies, you can use fiat and cryptocurrencies in the same way with the same API calls.

Although each virtual account contains a single currency, it can be connected to multiple blockchain addresses for that currency.

Virtual accounts can only perform transactions with other virtual accounts of the same currency.

Grouping multiple virtual accounts

Multiple virtual accounts of different currencies can be grouped together using a customer ID. In this way, your customers can easily view the balances of all the currencies they hold with one API call, allowing you to build multi-currency wallets and various fintech applications.

Running in the background

When a customer transfers assets from their virtual account to a real blockchain address, they do not know where the assets are withdrawn from in the background.

Imagine that you have three customers with their custodial accounts: A, B, and C, and each of them has a virtual account connected to the customer’s blockchain address. The following scenario takes place:

  1. Customer A received 1 ETH.

  2. Customer A transfers this 1 ETH to Customer B.

  3. Customer B receives 1 ETH and transfers it to Customer C.

  4. Customer C receives 1 ETH and uses it to pay for something (in other words, transfers it to a blockchain address that is outside of your custodial application).

When Customer C transfers 1 ETH to a blockchain address that is outside of your custodial application:

  • On the virtual account level, the amount is deducted from Customer C's virtual account. -> This is what the customer sees.

  • On the blockchain level, the amount is deducted from Customer A's blockchain address because Customer A is the one who owned that 1 ETH in the beginning. -> This is what you see as the owner of the custodial application.

The virtual accounts take care of calculating the balance and tracking the assets.

Managing fees for blockchain transfers

When a customer transfers assets from their virtual account to a real blockchain address, they are charged a fee for the transaction and have to hold not only the assets being transferred but also the amount to cover the transaction fee.

Let's look at the scenario from the previous section again. When Customer C transfers 1 ETH to a blockchain address that is outside of your custodial application:

  • On the virtual account level, the fee is deducted from Customer C's virtual account. Therefore, the total amount deducted from Customer C's virtual account is going to be greater than 1 ETH (1 ETH plus the fee).

  • On the blockchain level, the fee is deducted from Customer A's blockchain address.

The virtual accounts take care of calculating the balance and tracking the assets.

In contrast to EVM-compatible blockchains such as Ethereum, which is used in the scenario in this article, transaction fees are managed differently on UTXO-based blockchains such as Bitcoin or Litecoin.

On a UTXO-based blockchain, when Customer C transfers some amount of the cryptocurrency to a blockchain address that is outside of your custodial application:

  • On the blockchain level, the fee is deducted from a suitable blockchain address (and it may be Customer A, B, or C) that will be chosen during execution under the current conditions.

  • On the virtual account level, the fee is deducted from Customer C's virtual account. Therefore, the total amount deducted from Customer C's virtual account is going to be greater than the transferred amount (the transferred amount plus the fee).

Setting up virtual accounts and withdrawing funds from them

Setting up virtual accounts is similar for all the supported blockchains. However, withdrawing funds from a virtual account works differently depending on what blockchain the virtual account is created for.

UTXO-based blockchains

On UTXO-based blockchains such as Bitcoin, Bitcoin Cash, Dogecoin, and Litecoin, withdrawing funds from virtual accounts is easier when the virtual accounts are associated with the same extended public key (xpub). This way, all the deposit addresses that you generate for those virtual accounts are associated with the same xpub, and you do not have to track all UTXO transactions. During the withdrawal, all the deposit addresses are automatically scanned for incoming deposits that are then used as a source of the withdrawal transaction.

To withdraw funds from the virtual accounts associated with the same xpub, use the API for sending the funds from a virtual account to the blockchain for your blockchain and request body schema for mnemonics (for example, use this API with the TransferBtcMnemonic schema for Bitcoin).

If your virtual accounts are associated with different xpubs, you need to manually specify the deposit addresses that will be used as a source of the withdrawal transaction.

To withdraw funds associated with different xpubs, use the API for sending the funds from a virtual account to the blockchain for your blockchain and request body schema for key pairs (for example, use this API with the TransferBtcKeyPair schema for Bitcoin).

For more information about setting up virtual account on the UTXO-based blockchains and withdrawing funds, see How to set up virtual accounts with BTC, LTC, DOGE, and BCH.

EVM-compatible blockchains

On EVM-compatible blockchains such as Ethereum, BNB Smart Chain, Celo and so on, you can choose from the following approaches to withdrawals:

  • Withdraw deposits from each deposit address separately.

  • Collect all deposits on a separate blockchain address and withdraw them from this address.

For more information about setting up virtual account on the EVM-compatible blockchains and withdrawing funds, see How to set up virtual accounts with ETH, TRON, CELO, MATIC, BSC, and ONE.

BNB Beacon Chain, Stellar, and XRPL

On BNB Beacon Chain, Stellar, and XRPL, one deposit address is used and customers are identified by blockchain-specific parameters such as memo, message, and DestinationTag, accordingly.

For more information about setting up virtual account on BNB Beacon Chain, Stellar, and XRPL, and withdrawing funds, see How to set up virtual accounts with XRP, BNB, and XLM.

Last updated