> ## 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.

# approve

> Grant an ERC-20 allowance before an investment or a dividend distribution.

Prepares unsigned transactions for approving a spender to use tokens on behalf of the signer. Use `POST /prepare-transactions` with `method=approve`.

## Fields

* `tokenSymbol` selects the **token being approved**, not the asset it relates to.
* `spenderAddress` is the address allowed to spend it. It is never derived — you must pass it.
* `tokenizerAddress` is additionally required when `tokenSymbol` is a shared payment token
  (`USDT`, `USDC`, `BKN`, `HAI`). Use `companyWalletAddress` from `GET /get-tokenizer-info`.
* `amount` is in **whole tokens**. Send `"100"` for 100 USDT; the API applies the token's decimals
  for you. Do not pre-multiply.

> [!WARNING]
>
> `spenderAddress` is validated as an EVM address, and a malformed value is rejected with a
> validation error naming that field. Two things trip it most often: an invalid EIP-55 checksum, and
> leading or trailing whitespace picked up from a copied value or an environment variable. Trim the
> value, or send the address in all lowercase, which always passes the checksum rule.
>
> Sending the field as `spender` instead of `spenderAddress` returns
> `Missing spender address parameter`.

## Choosing the spender

Allowances are **per spender**. An allowance granted to one contract gives nothing to another, so an
investor who has invested in one offering still has to approve the next offering's escrow separately.

| Purpose | `tokenSymbol` | `spenderAddress` |
| - | - | - |
| Investing in an offering | the offering's payment token | `escrowAddress` |
| Distributing dividends | the asset's payment token | `tokenAddress` (the STO token contract) |

Both addresses come from the same call:

```bash theme={null}
curl --request GET \
  --url 'https://api.sandbox.brickken.com/get-tokenizer-info?tokenSymbol=EXMPL' \
  --header 'x-api-key: YOUR_API_KEY'
```

## Approving payment tokens for dividend distributions

Before calling `dividendDistribution`, approve the tokenized asset's configured payment token and set `spenderAddress` to the **STO token contract address**.

Use the response fields as follows:

* `tokenAddress` → `spenderAddress` in the `approve` request
* `paymentTokenAddress` → the ERC-20 contract being approved; use its configured symbol, such as `USDT`, as `tokenSymbol`
* `companyWalletAddress` → `tokenizerAddress` when approving a shared payment token
* `escrowAddress` → **do not use this as the spender for `dividendDistribution`**

> [!WARNING]
>
> Approving the payment token to `escrowAddress` does not satisfy the dividend allowance check. The allowance must be from `signerAddress` to the STO `tokenAddress`.

For example, if `get-tokenizer-info` returns the STO address `0x2222222222222222222222222222222222222222` and the configured payment token is USDT:

```json theme={null}
{
  "method": "approve",
  "signerAddress": "0x1111111111111111111111111111111111111111",
  "chainId": "aa36a7",
  "tokenSymbol": "USDT",
  "spenderAddress": "0x2222222222222222222222222222222222222222",
  "amount": "100",
  "tokenizerAddress": "0x1111111111111111111111111111111111111111"
}
```

Sign and submit the prepared approval, then wait for its on-chain confirmation before preparing `dividendDistribution`.

## Replacing an existing allowance

Some payment tokens refuse to change a non-zero allowance directly. When the signer already has a
non-zero allowance for that spender, the response therefore contains **two** transactions — a reset
to `0` followed by the new amount — and `txId` is an array rather than a single value.

```json theme={null}
{
  "transactions": [ { "…reset to 0…" }, { "…new amount…" } ],
  "txId": ["0xaaa…", "0xbbb…"]
}
```

Iterate the array rather than assuming a single entry, and broadcast the transactions **in order**,
waiting for the reset to confirm before sending the second.

> [!WARNING]
>
> Both transactions are gas-estimated at prepare time, while the reset is still unmined. On a token
> that strictly forbids a non-zero to non-zero change, that estimate can fail and the whole prepare
> call returns a revert with empty data (`"data": "0x"`).
>
> If it does: check the current allowance with `GET /get-allowance`. If it already covers the amount
> you need, skip the approval entirely. Otherwise prepare and send `amount: "0"` on its own first,
> wait for it to confirm, then prepare the new amount.

## Next step

Preparing does not touch the chain. The response gives you `txId` and an array of unsigned `transactions` — you still have to sign and submit them.

**1. Sign every returned transaction**

Sign each entry locally with the wallet that sends the transaction — `signerAddress`, or `investorAddress` for `newInvest` and `claimTokens`. It must be whitelisted by Brickken, and it needs native gas on the target chain.

**2. Submit the signed payloads**

`POST` them to [`/send-transactions`](https://docs.brickken.com/api-reference/endpoint/send) as `{ txId, signedTransactions }` and Brickken broadcasts for you.

If you would rather broadcast yourself, prepare with `executionMode: "client-broadcast"` and confirm afterwards with `{ txId, txHash }` instead.

**3. Poll until it confirms**

Call [`GET /get-transaction-status`](https://docs.brickken.com/api-reference/endpoint/get-transaction-status) with the `txId`. A `pending` status means it is broadcast but not yet mined — do not resubmit.

Full walkthrough: [Tokenize an asset and run an STO](https://docs.brickken.com/api-reference/guides/tokenize-and-run-an-sto.md).


## OpenAPI

````yaml api-reference/prepare/approve.json POST /prepare-transactions
openapi: 3.1.0
info:
  title: Brickken API V2 - prepare approve
  description: >-
    Method-scoped view of `POST /prepare-transactions` for `method=approve`. For
    a payment-token approval used by `dividendDistribution`, retrieve the asset
    with `GET /get-tokenizer-info` and use its `tokenAddress` as
    `spenderAddress`; do not use `escrowAddress`. The full endpoint, with every
    supported method and the common request body parameters, is documented in
    `api-reference/openapi.json`.
  version: 2.0.0
servers:
  - url: https://api.sandbox.brickken.com
    description: Sandbox Environment
  - url: https://api.brickken.com
    description: Production Environment
security: []
paths:
  /prepare-transactions:
    post:
      summary: Prepare a token approval
      description: >-
        Prepares the unsigned transaction that approves a spender to move tokens
        on behalf of the owner. For `dividendDistribution`, the spender must be
        the STO contract returned as `tokenAddress` by `GET
        /get-tokenizer-info`, not the returned `escrowAddress`.
      operationId: prepare_approve
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - method
                - chainId
                - signerAddress
                - tokenSymbol
                - spenderAddress
                - amount
              properties:
                method:
                  type: string
                  example: approve
                  enum:
                    - approve
                  description: >-
                    Required. Operation to prepare. Must be `approve` for this
                    endpoint.
                  default: approve
                chainId:
                  type: string
                  description: >-
                    Required. Blockchain network identifier. Hex format is
                    recommended, for example Sepolia `aa36a7`.
                  example: aa36a7
                signerAddress:
                  type: string
                  description: Required. Wallet that signs the approval.
                  example: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
                tokenSymbol:
                  type: string
                  description: >-
                    Required. Symbol of the token to approve. Accepts a
                    tokenized asset symbol or a payment token symbol such as
                    `USDT`, `USDC`, `BKN` or `HAI`.
                  example: EXMPL
                spenderAddress:
                  type: string
                  description: >-
                    Required. Address allowed to spend the approved amount.
                    Allowances are per spender, so each offering's escrow must
                    be approved separately. For an investment, use that
                    offering's `escrowAddress`. For a payment-token approval
                    before `dividendDistribution`, use the STO `tokenAddress`
                    returned by `GET /get-tokenizer-info`; never use
                    `escrowAddress` for that allowance. A malformed value is
                    rejected with a validation error naming this field;
                    whitespace and a bad EIP-55 checksum are the usual causes.
                  example: '0x2222222222222222222222222222222222222222'
                  pattern: ^0x[a-fA-F0-9]{40}$
                amount:
                  type: string
                  description: >-
                    Required. Amount the spender is allowed to spend, in whole
                    tokens. The API applies the token's decimals, so send `100`
                    for 100 USDT rather than the raw six-decimal value.
                  example: '100'
                investorAddress:
                  type: string
                  description: >-
                    Optional. Token owner address when approving on behalf of an
                    investor. If omitted, `signerAddress` is used as the owner.
                  example: '0x1111111111111111111111111111111111111111'
                  pattern: ^0x[a-fA-F0-9]{40}$
                tokenizerEmail:
                  type: string
                  description: >-
                    Optional. Tokenizer email used as a fallback when the
                    tokenizer cannot be resolved from the token.
                  example: tokenizer@example.com
                  format: email
                tokenizerAddress:
                  type: string
                  description: >-
                    Optional. Required when `tokenSymbol` is a payment token
                    (`HAI`, `BKN`, `USDC`, `USDT`). Tokenizer wallet the
                    approval is scoped to; use `companyWalletAddress` from `GET
                    /get-tokenizer-info` for the related tokenized asset.
                  example: '0x1111111111111111111111111111111111111111'
                  pattern: ^0x[a-fA-F0-9]{40}$
              example:
                method: approve
                chainId: aa36a7
                signerAddress: '0x1111111111111111111111111111111111111111'
                tokenSymbol: USDT
                spenderAddress: '0x2222222222222222222222222222222222222222'
                amount: '100'
                tokenizerAddress: '0x1111111111111111111111111111111111111111'
            example:
              method: approve
              chainId: aa36a7
              signerAddress: '0x1111111111111111111111111111111111111111'
              tokenSymbol: USDT
              spenderAddress: '0x2222222222222222222222222222222222222222'
              amount: '100'
              tokenizerAddress: '0x1111111111111111111111111111111111111111'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  transactions:
                    type: array
                    description: Array of unsigned transaction objects ready for signing
                    items:
                      type: object
                      properties:
                        from:
                          type: string
                          description: Sender address
                          example: '0x1234567890abcdef1234567890abcdef12345678'
                        to:
                          type: string
                          description: Recipient address
                          example: '0xabcdef1234567890abcdef1234567890abcdef12'
                        value:
                          type: string
                          description: Transaction value in hex
                          example: '0x00'
                        nonce:
                          type: integer
                          description: Transaction nonce
                          example: 3792
                        chainId:
                          type: integer
                          description: Blockchain network chain ID
                          example: 11155111
                        data:
                          type: string
                          description: Transaction data payload
                          example: >-
                            0xd362e8a70000000000000000000000000000000000000000000000000000000000000040...
                        type:
                          type: integer
                          description: Transaction type (EIP-1559)
                          example: 2
                        maxPriorityFeePerGas:
                          type: string
                          description: Maximum priority fee per gas
                          example: '1150000'
                        maxFeePerGas:
                          type: string
                          description: Maximum fee per gas
                          example: '1156037'
                        gasLimit:
                          type: string
                          description: Gas limit in hex
                          example: '0xccef'
                  info:
                    type: object
                    description: Metadata about the operation
                    properties:
                      tokenizerEmail:
                        type: string
                        description: Email of the tokenizer
                        example: tokenizer@example.com
                      tokenSymbol:
                        type: string
                        description: Symbol of the token
                        example: EXMPL
                      investorEmail:
                        type: string
                        description: Email of the investor (when applicable)
                        example: investor@example.com
                  txId:
                    type: string
                    description: >-
                      Unique identifier for this transaction batch (required for
                      /send-transactions). This is NOT a blockchain transaction
                      hash.
                    example: >-
                      0x46adea7bdf49c576a760102e0d6bc9ecd650b3998588cd3d7f576a7973426aad
                required:
                  - transactions
                  - txId
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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