# update_balances_if_needed · FT4 Rell API · Chromia Docs (concept)

> function update_ balances_ if_ needed(sender: account , recipient: account , asset: asset , amount: big_ integer) For a transfer going from an account to a

Source: https://docs.chromia.com/pages/ft4-rell/-f-t4-library/lib.ft4.core.crosschain.Unsafe/update_balances_if_needed/

FUNCTION

# update\_balances\_if\_needed

```signature
function update_balances_if_needed(sender: account, recipient: account, asset: asset, amount: big_integer)
```

[Source](https://gitlab.com/chromaway/ft4-lib/-/blob/development/rell/src/lib/ft4/core/crosschain/transfer.rell#lines-198)

For a transfer going from an account to another, this function checks whether any
balances need to be updated, then does so.
This function should only be used in the context of crosschain transfers.

A balance does **not** need to be updated if it pertains to a blockchain that is
marked as `asset_origin` for the asset being transferred. This is because the asset
origin chain's balance does not need to be tracked.

Can only be called from an operation.

Throws `"SELF TRANSFER"` if sender and recipient are the same account

Throws `"INVALID BLOCKCHAIN SENDER"` if sender is a blockchain account with this
blockchain's RID

Throws `"INVALID BLOCKCHAIN RECIPIENT"` if recipient is a blockchain account with this
blockchain's RID

Throws if the required assets cannot be transferred. Common cases include:

* the amount to transfer is not in the accepted range (0, 2^256) (exclusive)
* the sender account's balance is lower than `amount`

**Parameters**

* **sender** — the account the assets are coming from
* **recipient** — the account the assets are going to
* **asset** — the asset being transferred
* **amount** — the amount being transferred

**See Also**

* `asset_origin` — for more information on asset origin chains and balance tracking

[View this page on docs.chromia.com](https://docs.chromia.com/pages/ft4-rell/-f-t4%20-library/lib.ft4.core.crosschain.Unsafe/update_balances_if_needed.html)Generated API reference, mirrored from the live docs
