> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brickken.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Protocol V2

> New tokens are created on Protocol V2. What changes for your integration, method by method, and what is not available yet.

Brickken uses Protocol V2 for new tokenizations on networks with a V2 factory. Operations on an
existing token use the protocol version of that token. The same `POST /prepare-transactions` endpoint
and sign-and-send flow apply to both versions.

## Which version a token uses

* **New tokens are V2.** `newTokenization` creates a V2 token on every network where Protocol V2 is
  active. You do not choose: there is no version field to send, and Brickken picks the factory for the
  requested network.
* **Existing tokens keep their version.** A token created on Protocol V1 stays on V1, and its
  operations keep following the V1 flow. Every later call branches on the token's own version, so
  you never send a version either.
* **Networks are enabled one by one.** In Sandbox, Ethereum Sepolia runs Protocol V2. Check
  [`get-network-info`](https://docs.brickken.com/api-reference/endpoint/get-network-info) for any other network:
  `universalEscrowAddress` and `paymentHandlerAddress` are set where Protocol V2 is active and `null`
  where it is not. A network with no tokenization factory answers `newTokenization` with
  `Tokenization is not available on the requested chain`.

V2 ERC-7943 contracts check sender and recipient whitelists on chain. Privileged actions require an
on-chain role on the signing wallet. Stablecoins use an ERC-20 contract.

| Business `tokenType` you send to `newTokenization` | V2 contract | Decimals |
| - | - | - |
| `EQUITY`, `EQUITY_ERIR`, `STO_ERIR`, `FUND`, `RWA_TOKEN`, `PROFIT_SHARING` | `STO7943` (4) | Always 18 |
| `DEBT`, `BILL_FACTORING` | `DTO7943` (5) | Always 18 |
| `ICO` | `ERC7943` (1) | Always 18 |
| `STABLECOIN` | `ERC20` (0) | As requested |

Send `tokenType: "FUND"` to create a fund. The asset keeps `FUND` as its business type and the factory
uses contract type `4` (`STO7943`). `REVENUE_SHARE`, numeric contract types, and unknown business
types return **400** on V2 `newTokenization`.

## Every prepare is simulated

Before returning unsigned transactions, the API simulates them against the chain. A transaction that
would revert is rejected at prepare time with the decoded reason, for example
`v2Tokenization simulation failed: <reason>`, instead of failing after you sign and pay gas.

## Method by method

### newTokenization

[`newTokenization`](https://docs.brickken.com/api-reference/endpoint/prepare-newTokenization) keeps its fields, with these
differences on V2:

* `transactions` in the response is a **single transaction object**, not an array.
* `info` carries `factoryAddress`, plus `feeToken` and `feeAmount`: the token-creation fee, paid by
  the signer. The signer needs an allowance to `factoryAddress` for at least `feeAmount` of `feeToken`
  before you send, or the simulation fails.
* `preMints` and `initialHolders` are rejected. Create the token first, then
  [`mintToken`](https://docs.brickken.com/api-reference/endpoint/prepare-mintToken) to the holders.
* `initialTokenSupply` and `shareholders` are ignored: a V2 token starts with zero supply.
* `DEBT` and `BILL_FACTORING` require a positive `supplyCap` and an explicit `debtInterestRate`.
  Enter the rate as a percentage from 0 to 100, with up to two decimal places. Zero is valid.

### whitelist

A V2 whitelist is one `multicall` on the token that enables both sending and receiving for each
address. The signer needs the token's `WHITELIST_ROLE`, otherwise the prepare fails with
`Signer <address> does not have WHITELIST_ROLE on token <address>`.
[`get-whitelist-status`](https://docs.brickken.com/api-reference/endpoint/get-whitelist-status) reports an address as whitelisted
only when it can both send and receive.

### mintToken

Mints are grouped in one `multicall` on the token. When some recipients still need whitelisting, the
response holds two transactions, the whitelist first and the mint second. Sign and send them in order.

### approve, transferFrom, transferTo

Unchanged: standard ERC-20 calldata. The token still enforces its whitelists when the transfer executes.

### burnToken

> [!WARNING]
>
> Burning a V2 token through the API is **not available yet**. A V2 token only lets a wallet that holds
> `BURNER_ROLE` burn, and issuer wallets do not hold that role, so
> [`burnToken`](https://docs.brickken.com/api-reference/endpoint/prepare-burnToken) on a V2 token answers **403**
> `V2 burnToken requires BURNER_ROLE on the signer wallet` before estimating any gas. V1 tokens are not
> affected.

### newSto

[`newSto`](https://docs.brickken.com/api-reference/endpoint/prepare-newSto) validates the offering terms before preparing a
transaction. Publish both the Subscription Agreement and the By-laws. New start dates require five
minutes of lead time, and offerings can last up to one year. See the [V2 offering rules](https://docs.brickken.com/api-reference/endpoint/prepare-newSto.md#protocol-v2-offering-rules)
for cap, ticket, price, and supply validation.

An offering can require several calls while Brickken configures the token and the Universal Escrow.

* When `nextAction` is `"wait-and-retry"`, including **202** responses, wait and repeat
  `newSto` with the same body. Any returned transaction ID refers to a transaction already tracked by
  Brickken.
* If the response calls for signing, sign and send the returned transaction. After a confirmed
  `tokenSetup`, repeat `newSto` with the same body. The issuance transaction creates the offering.
* If the offering terms change, the API can replace an unsigned issuance prepared with older terms.
  An issuance already broadcast must settle first.
* A failed fee configuration returns **409**. Contact Brickken if it fails.

### newInvest

On V2 the investor buys from the network's `UniversalEscrow`:

* The investor must approve the payment token to the escrow first. Without that allowance the prepare
  fails with `Insufficient payment token allowance. Prepare and confirm the approval before investing.`
* The minimum ticket applies, except when the amount left in the offering is smaller than it.
* An investment larger than what is left is accepted, and the escrow takes only the remaining amount.

### closeOffer

Finalizes the issuance on the escrow and withdraws the raised funds to the signer. An offering that is
already closed answers **409** `Cannot finalize issuance: IssuanceNotActive`. If you already sent a
close transaction, track its hash instead of preparing a new one.

### claimTokens

One claim per investor, prepared and sent like any other transaction.

### dividendDistribution

[`dividendDistribution`](https://docs.brickken.com/api-reference/endpoint/prepare-dividendDistribution) on V2 supports
`STO7943` assets, including `FUND`. The signer needs the payment distributor role for the asset.
Approve the payment token to the network's `paymentHandlerAddress` from
[`get-network-info`](https://docs.brickken.com/api-reference/endpoint/get-network-info) before preparing the distribution.

### Debt and Bill Factoring repayments

V2 `DEBT` and `BILL_FACTORING` assets use the same `DTO7943` repayment flow. In the Brickken
dashboard, **Send Dividends** prepares capital and interest repayments and shows confirmed repayments
in the asset's repayment history.

Repayments use the payment token from the first confirmed offering. Keep that payment token for
subsequent offerings on the same asset. The dashboard can resume an active repayment while its
required steps confirm.

The public API's `dividendDistribution` method is limited to `STO7943` on V2. Initiate DTO7943
repayments from the dashboard.

## Changes for every token, V1 included

This release also changes behaviour that does not depend on the token's version.

> [accordion] Signer and identity fields come from your API key
>
> For `newSto`, `whitelist`, `dividendDistribution` and `closeOffer`, the API sets `tokenizerEmail`
> and `signerAddress` from your API key, and the token must belong to your own company. Otherwise the
> call fails with **403** `API key does not own token symbol "<SYMBOL>" (or it does not exist).`
>
> For `newInvest` and `claimTokens`, `investorEmail` is required. The API signs with the investor's
> registered wallet, and the investor must already be related to one of your tokens: holding it,
> whitelisted on it, or invited to it.

> [accordion] get-allowance returns owner-to-spender allowances
>
> [`get-allowance`](https://docs.brickken.com/api-reference/endpoint/get-allowance) now reads `allowance(ownerAddress, spenderAddress)`.
> Before this release the two addresses were swapped. The value is formatted with the payment token's
> own decimals instead of 18, and missing data answers **404**. Re-check any code that compensated for
> the old behaviour.

> [accordion] A batch where every transaction fails returns an error status
>
> When every transaction in a `send-transactions` batch fails, the response now carries the error's
> HTTP status (or 502) instead of 200 with `success: false`. Check the status code before the body.

> [accordion] Another key's transaction is not found
>
> `get-transaction-status` for a transaction that belongs to a different API key answers **400**
> `Transaction not found`.

> [accordion] Read endpoints
>
> * [`get-network-info`](https://docs.brickken.com/api-reference/endpoint/get-network-info) adds `paymentHandlerAddress` and
>   `universalEscrowAddress`.
> * A missing offering answers **404** `Sto not found`.
> * [`get-stos`](https://docs.brickken.com/api-reference/endpoint/get-stos), [`get-sto-by-id`](https://docs.brickken.com/api-reference/endpoint/get-sto-by-id),
>   and [`get-sto-balance`](https://docs.brickken.com/api-reference/endpoint/get-sto-balance) report an offering as
>   `SCHEDULED` before its start date. It still occupies the token's active offering slot.
> * `maxTokenSupply` in [`get-token-info`](https://docs.brickken.com/api-reference/endpoint/get-token-info) is a decimal
>   serialized as a string.

## Not available through the API yet

* Burning a V2 token, as described above.
* Freezing balances, forced transfers, and granting or inspecting on-chain roles.
* Initiating capital and interest repayments for `DEBT` and `BILL_FACTORING` assets.

These actions remain in the Brickken dashboard. Contact [tech@brickken.com](mailto:tech@brickken.com)
if your integration needs one of them.

> [card] [Tokenize an asset and run an STO](https://docs.brickken.com/api-reference/guides/tokenize-and-run-an-sto.md)
>
> The full lifecycle, end to end.

> [card] [Troubleshooting](https://docs.brickken.com/api-reference/guides/troubleshooting.md)
>
> Decode a failed call, from validation errors to raw revert data.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.