> For the complete documentation index, see [llms.txt](https://docs.baas.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.baas.sh/baas-console/contracts/units/automatic-units.md).

# Automatic units

The units BaaS sets up on its own for ERC-20, ERC-4626, and ERC-6909 tokens.

BaaS recognizes three token standards, ERC-20, ERC-4626, and ERC-6909, and sets up their units when you register a contract. In our example, `MyToken` is an ERC-20, and it declares `decimals()`, so its amounts arrive with the `token` unit already in place. A contract that implements none of them starts with no unit, ready for a [template of your own](/baas-console/contracts/units/custom-units.md).

## How detection works

BaaS looks at the functions your ABI declares. Every standard it finds contributes, so a vault that is also a token keeps both sets.

A unit exists only when its decimals can be read. ERC-20 leaves `decimals()` optional, and a token that omits it gets no unit at all.

## ERC-20

One unit, `token`, read from `decimals()` on the contract itself. It covers every amount of the core interface:

* the amounts you read: `totalSupply`, `balanceOf`, and `allowance`
* the amounts you send: `transfer`, `transferFrom`, and `approve`
* the amounts that events carry: `Transfer` and `Approval`

So reading `balanceOf` shows a formatted figure, and the amount field of `transfer` [takes a decimal amount](/baas-console/contracts/read-and-write.md#smart-unit-amounts).

Detected when the ABI declares these six functions and `decimals()`.

A mint or a burn outside the standard stays uncovered, and a template of your own can cover it.

## ERC-4626

The vault standard adds two units:

* `shares`, the vault's own token, read from `decimals()`
* `asset`, the underlying, read from `decimals()` on the contract that `asset()` returns

Each amount gets the right one:

* `deposit` and `withdraw` take an `asset` amount and return `shares`
* `mint` and `redeem` take `shares` and return an `asset` amount
* `totalAssets` reads in `asset`
* the `convertTo`, `max`, and `preview` functions measure assets in `asset` and shares in `shares`
* the `Deposit` and `Withdraw` events carry one amount of each unit

Detected when the ABI declares `asset()`, `decimals()`, and `deposit`, `mint`, `withdraw` and `redeem`; the other functions are covered when present.

A vault that is also a token keeps its `token` unit as well, so `token`, `shares`, and `asset` all apply together.

## ERC-6909

One unit, `multiToken`, read from `decimals(uint256)`: every token id carries its own decimals. Each amount uses the id from the same call or event, so `balanceOf(owner, id)` formats with the decimals of that id.

An ABI that implements both standards keeps both units, `token` and `multiToken`.

Detected when the ABI declares `balanceOf`, `allowance`, `transfer`, `transferFrom`, `approve` and `decimals(uint256)`. Its decimals are [known as ids appear](/baas-console/contracts/units.md#when-decimals-are-read).

## What stays undetected

ERC-721 and ERC-1155 declare no decimals of their own, so BaaS leaves their amounts raw. The same goes for anything a standard does not cover, such as a custom `mint`.

A template of your own can give any of them a unit. It replaces the detected set, so carry over what you want to keep.

{% hint style="info" %}
**No decimals, no unit.** BaaS never assumes a scale. A value it cannot scale reaches you exactly as the chain returned it.
{% endhint %}

## Next

* [Custom units](/baas-console/contracts/units/custom-units.md): the set you declare yourself.
* [Automatic mappings](/baas-console/contracts/mappings/automatic-mappings.md): the values BaaS keeps on its own.
* [Units](/baas-console/contracts/units.md): where units appear, and when decimals are read.
