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

# RAMS EIP-712 Typed Data

> Fetch complete typed-data envelopes for signature-authorized RAMS lifecycle operations.

All four API-key authenticated routes return the same envelope shape:

| Operation    | Endpoint                              |
| ------------ | ------------------------------------- |
| Grant        | `GET /rams/typed-data/grant-mandate`  |
| Revoke       | `GET /rams/typed-data/revoke-mandate` |
| Extend       | `GET /rams/typed-data/extend-mandate` |
| Set operator | `GET /rams/typed-data/set-operator`   |

## Client flow

1. Fetch typed data with the exact operation parameters.
2. Sign the returned `typedData.domain`, `types`, and `message` locally with the principal wallet (`ethers._signTypedData` / `signTypedData`). The API's `types` intentionally omit `EIP712Domain`.
3. Prepare the matching RAMS write using the same parameters, the returned `deadline`, and the signature.
4. Client-sign the returned transaction, or request `executionMode: "brickken-relayed"`; then send and settle x402.

The domain is `RAMS` version `1`, and the verifying contract is the selected AgentMandate. The default deadline is one hour; caller-supplied deadlines cannot exceed 30 days.

<Warning>
  The nonce is read on-chain and is shared per principal across all four signed operations. Never default it to zero. Direct lifecycle calls do not consume it, but any successful signature-authorized call invalidates other envelopes using the old nonce.
</Warning>


## OpenAPI

````yaml GET /rams/typed-data/grant-mandate
openapi: 3.1.0
info:
  title: Brickken API V2
  description: >-
    Welcome to the Brickken API documentation. This API allows customers to
    create and manage tokenization processes, including creating new
    tokenizations, minting/burning/transferring tokens, whitelisting users,
    manage tokens approvals. This documentation provides detailed information on
    how to use the API, including the necessary endpoints, request formats, and
    expected
    responses.</details><details><summary>**Authentication**</summary>All API
    requests require an API key for authentication. Include your API key in the
    `x-api-key` header of each request:<pre><code>```
      x-api-key: YOUR_API_KEY
    ```</code></pre>Ensure that your API key is kept secure and not shared
    publicly. A common parameter for all requests is the `signerAddress`. Such
    address MUST be whitelisted in our factory. To whitelist an address and/or
    request an API key either for sandbox/production environment please contact
    with: tech@brickken.com. Once a `signerAddress` performs a `newTokenization`
    we refer to that address as the tokenizer. The tokenizer will be the only
    one allowed to mint such token, distribute dividends on such token and
    whitelist/blacklist investors of such token. Regarding actions like
    transferring tokens or burning tokens, the `signerAddress` can be any user
    and not only the tokenizer.</details><details><summary>**Supported Networks
    & Addresses**</summary><details><summary>Sepolia (sandbox environment
    only)</summary><pre><code>```
      Chain Id: "aa36a7"
      Factory Address: "0x933ABAA95a7Fd0Bc683bDe2adB89f4C5EA64897b"
      BKN Address: "0x97a13487f889dc770Ac925Be2d3b6c833FA7746a"
      USDT Address: "0x28d2B01854D0aBec267a3DDcad9163580E6E8604"
      USDC Address: "0xb10cE8e28aEb1ae27b968Fb3bfed2FD7dd52daCb"
    ```</code></pre></details><details><summary>Base Sepolia (sandbox /
    testing)</summary><pre><code>```
      Chain Id: "84532" (hex "14a34")
      x402 USDC (Circle, EIP-3009): "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
      ERC-8004 Identity Registry: "0x8004A818BFB912233c491871b3d84c89A494BD9e"
      ERC-8004 Reputation Registry: "0x8004B663056A597Dffe9eCcC1965A193B7388713"
    ```</code></pre></details><details><summary>Ethereum mainnet (production
    environment only)</summary><pre><code>```
      Chain Id: "1"
      Factory Address: "0x91af681C85Ca98Efc5D69C1B62E6F435030969Db"
      BKN Address: "0x0A638F07ACc6969abF392bB009f216D22aDEa36d"
      USDT Address: "0xdac17f958d2ee523a2206206994597c13d831ec7"
      USDC Address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
    ```</code></pre></details><details><summary>Base mainnet (production
    environment only)</summary><pre><code>```
      Chain Id: "2105"
      Factory Address: "0x278D7bdc2451B0Fa4087A68ce084a86cB91D4d83"
      BKN Address: "0xddB293BB5C5258F7484A94a0fBd5c8B2F6E4e376"
      USDT Address: N/A
      USDC Address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
    ```</code></pre></details><details><summary>BNB Smart Chain mainnet
    (production environment only)</summary><pre><code>```
      Chain Id: "38"
      Factory Address: "0xCe4529Fe88df480BD777d3e32dfD7032e6C685ff"
      BKN Address: "0x0e28bC9B03971E95acF9ae1326E51ecF9C55B498"
      USDT Address: "0x55d398326f99059fF775485246999027B3197955"
      USDC Address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"
    ```</code></pre></details><details><summary>Avalance C Chain mainnet
    (production environment only)</summary><pre><code>```
      Chain Id: "a86a"
      Factory Address: "0xc6c230FA8F40022dE997727436Fae01caAbcDe61"
      BKN Address: "0xd44E4Dc8bdF7C1c62CfDBb182022097BA42Ac6bC"
      USDT Address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"
      USDC Address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"
    ```</code></pre></details></details><details><summary>**Usage
    Workflow**</summary><details><summary>1. **Prepare
    Transactions:**</summary>- Use the `POST /prepare-transactions` endpoint
    with the desired method (e.g., `newTokenization`, `mintToken`, etc...) to
    prepare the transaction(s).

    - The response will include an array of unsigned transactions that needs to
    be signed.<details><summary>**Example Of An Endpoint
    Response:**</summary>```json
      {
        "transactions": [
          {
            "from": "0xSignerAddress",
            "to": "0xTargetAddress",
            "value": {
              "type": "BigNumber",
              "hex": "0x00"
            },
            "nonce": 1,
            "chainId": 11155111,
            "data": "0x...",
            "type": 2,
            "maxPriorityFeePerGas": {
              "type": "BigNumber",
              "hex": "0x..."
            },
            "maxFeePerGas": {
              "type": "BigNumber",
              "hex": "0x..."
            },
            "gasLimit": {
              "type": "BigNumber",
              "hex": "0x..."
            }
          }
        ]
      }
    ```</details></details><details><summary>2. **Sign the
    Transactions:**</summary>- Use your preferred method or wallet to sign the
    transaction data provided in the response.

    - Ensure that the signer address matches the `signerAddress` provided in the
    initial request.<details><summary>**Example Of signing a transaction with
    typescript and `ethers-js`:**</summary>```typescript
      const tx = {...} // One of the object in the array returned by the `/prepare-transactions` endpoint
      const privateKey = process.env.PRIVATE_KEY;
      const wallet = new ethers.Wallet(privateKey);
      const signedTx = await wallet.signTransaction(tx);
      console.log('Signed Transaction:', signedTx);
    ```</details>**NOTE:** Be sure to have enough funds in the signer wallet to
    cover for the transaction cost</details><details><summary>3. **Submit Signed
    Transactions:**</summary>- Use the `POST /send-transactions` endpoint to
    submit the signed transaction(s) along with the required parameters.

    - The API will process the transactions, send them to the blockchain, and
    update the Brickken database accordingly.</details><details><summary>4.
    **Check Transaction Status:**</summary>- Use the `GET
    /get-transaction-status` endpoint to check the status of your transaction.

    - Provide either the on-chain transaction hash (`hash`) or the internal
    transaction ID (`txId`) to retrieve the
    status.</details></details><details><summary>**Environments**</summary>The
    API is available in several environments for testing and production
    purposes:- Sandbox: `https://api.sandbox.brickken.com/`

    - Master (Production): `https://api.brickken.com/`</details>


    The API also exposes x402scan discovery facade endpoints under /x402/... The
    public discovery target is https://api.brickken.com, with /.well-known/x402
    returning resource URLs and /openapi.json returning the generated OpenAPI
    3.1 document.
  version: 2.0.0
servers:
  - url: https://api.sandbox.brickken.com
    description: Sandbox Environment
  - url: https://api.brickken.com
    description: Production Environment
security:
  - apiKeyAuth: []
paths:
  /rams/typed-data/grant-mandate:
    get:
      tags:
        - Endpoints
      summary: Get GrantMandate typed data
      description: >-
        Build the EIP-712 GrantMandate payload for a principal to sign off-chain
        (relayed grant flow). The response includes the full EIP-712 payload
        (domain RAMS/1, primaryType, types, message) with the principal's
        current on-chain nonce; types omits the EIP712Domain entry (ethers
        derives it; eth_signTypedData_v4 consumers must add it themselves). Sign
        with the PRINCIPAL's key, then submit the same parameters + signature +
        the same deadline to the matching prepare endpoint. Requires the
        x-api-key header.
      operationId: getRamsTypedDataGrantMandate
      parameters:
        - name: chainId
          in: query
          required: true
          schema:
            type: string
            default: '11155111'
          description: >-
            Target chain ID. RAMS is available on Ethereum Sepolia (11155111)
            only at launch. Decimal and 0x hex values are accepted.
        - name: agent
          in: query
          required: true
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{40}$
          description: Agent wallet receiving the mandate.
        - name: principal
          in: query
          required: true
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{40}$
          description: Principal delegating authority (the signer).
        - name: validUntil
          in: query
          required: true
          schema:
            oneOf:
              - type: integer
              - type: string
          description: Mandate expiry (Unix seconds, uint48).
        - name: validFrom
          in: query
          required: false
          schema:
            oneOf:
              - type: integer
              - type: string
          description: >-
            Mandate start (Unix seconds, uint48). Defaults to 0 (immediately
            valid).
        - name: complianceProvider
          in: query
          required: false
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{40}$
          description: >-
            Compliance provider contract. Defaults to the chain's configured
            RAMS ComplianceProvider address.
        - name: identityRef
          in: query
          required: true
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{64}$
          description: Compliance identity reference (bytes32).
        - name: asset
          in: query
          required: true
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{40}$
          description: Asset (token) the mandate is scoped to.
        - name: maxTransactionValue
          in: query
          required: true
          schema:
            type: string
          description: >-
            Per-transaction cap in raw base units. Alias "max" / "unlimited" =
            2^256-1.
        - name: maxCumulativeValue
          in: query
          required: true
          schema:
            type: string
          description: >-
            Cumulative cap in raw base units. Alias "max" / "unlimited" =
            2^256-1.
        - name: metadata
          in: query
          required: false
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{64}$
          description: Optional bytes32 metadata. Defaults to the zero value.
        - name: actions
          in: query
          required: true
          schema:
            type: string
          description: >-
            Comma-separated list of bytes32 actions and/or 4-byte selectors,
            minimum 1 (e.g. 0x23b872dd). Selectors are normalized to
            left-aligned bytes32 before signing.
        - name: deadline
          in: query
          required: false
          schema:
            type: string
          description: >-
            Optional signature deadline (Unix seconds). Must be greater than now
            and at most now + 30 days. Defaults to now + 3600 (1 hour). Submit
            the SAME deadline with the signature at prepare time.
        - name: agentMandateAddress
          in: query
          required: false
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{40}$
          description: Optional AgentMandate contract override.
      responses:
        '200':
          description: >-
            EIP-712 typed-data envelope ready for wallet._signTypedData(domain,
            types, message).
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      chainId:
                        type: string
                      verifyingContract:
                        type: string
                        description: >-
                          Resolved AgentMandate address (the EIP-712 verifying
                          contract).
                      signer:
                        type: string
                        description: 'Wallet that must sign: always the principal.'
                      nonce:
                        type: string
                        description: >-
                          Current on-chain EIP-712 nonce for the principal
                          (decimal string). Shared by all four signed
                          operations.
                      deadline:
                        type: string
                        description: >-
                          Signature deadline echoed into the message (Unix
                          seconds, decimal string).
                      typedDataId:
                        type: string
                        description: >-
                          EIP-712 struct hash (TypedDataEncoder.hash) of the
                          payload.
                      typedData:
                        type: object
                        additionalProperties: true
                        description: >-
                          Full EIP-712 payload: domain, primaryType, types,
                          message. types deliberately omits the EIP712Domain
                          entry — ethers derives it; eth_signTypedData_v4
                          consumers must add it themselves.
                        properties:
                          domain:
                            type: object
                            additionalProperties: true
                          primaryType:
                            type: string
                          types:
                            type: object
                            additionalProperties: true
                          message:
                            type: object
                            additionalProperties: true
              example:
                data:
                  chainId: '11155111'
                  verifyingContract: '0xD68E1bb972cA4EF7F5764FBf6d685a6DfC26778e'
                  signer: '0x2222222222222222222222222222222222222222'
                  nonce: '3'
                  deadline: '1752585600'
                  typedDataId: >-
                    0x0f4f8a2c000000000000000000000000000000000000000000000000000000000example0
                  typedData:
                    domain:
                      name: RAMS
                      version: '1'
                      chainId: '11155111'
                      verifyingContract: '0xD68E1bb972cA4EF7F5764FBf6d685a6DfC26778e'
                    primaryType: GrantMandate
                    types:
                      GrantMandate:
                        - name: agent
                          type: address
                        - name: validFrom
                          type: uint48
                        - name: validUntil
                          type: uint48
                        - name: principal
                          type: address
                        - name: complianceProvider
                          type: address
                        - name: identityRef
                          type: bytes32
                        - name: asset
                          type: address
                        - name: maxTransactionValue
                          type: uint256
                        - name: maxCumulativeValue
                          type: uint256
                        - name: metadata
                          type: bytes32
                        - name: actions
                          type: bytes32[]
                        - name: nonce
                          type: uint256
                        - name: deadline
                          type: uint256
                    message:
                      agent: '0x1111111111111111111111111111111111111111'
                      validFrom: 0
                      validUntil: 1789000000
                      principal: '0x2222222222222222222222222222222222222222'
                      complianceProvider: '0xa90D2503D5D9b80ECC27856Ff76F892B8C02f278'
                      identityRef: >-
                        0x1111111111111111111111111111111111111111111111111111111111111111
                      asset: '0x3333333333333333333333333333333333333333'
                      maxTransactionValue: '1000000'
                      maxCumulativeValue: '5000000'
                      metadata: >-
                        0x0000000000000000000000000000000000000000000000000000000000000000
                      actions:
                        - >-
                          0x23b872dd00000000000000000000000000000000000000000000000000000000
                      nonce: '3'
                      deadline: '1752585600'
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````