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

# Confirm Deploy

> Register a deployed lending market after the factory transaction is mined

Records a market that has been deployed on-chain. Call this once the transaction from [Deploy Market](/endpoints/stock-lending/deploy-market) is mined.

The factory call is verified before anything is written: the receipt must target the factory, call `deployMarket`, and name the same stock token you pass here. The market is then read back from the factory, stored against your instance, and returned with its configuration checklist.

## Body Parameters

<ParamField body="stockTokenAddress" type="string" required>
  ERC-20 stock token the market collateralises. Must match the token in the deployment transaction.
</ParamField>

<ParamField body="txHash" type="string" required>
  Hash of the mined factory deployment transaction.
</ParamField>

<ParamField body="issuerAddress" type="string" required>
  Issuer wallet holding `ISSUER_ROLE`. Used to build the configuration steps.
</ParamField>

<ParamField body="adminAddress" type="string" required>
  Admin wallet holding `DEFAULT_ADMIN_ROLE`. Used to build the configuration steps.
</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="market" type="object">The stored market record, including `id`, `marketAddress`, `oracleAddress`, `insuranceFundAddress`, and the borrow asset.</ResponseField>
    <ResponseField name="txHash" type="string">The deployment transaction hash.</ResponseField>
    <ResponseField name="signedBy" type="string">Address that signed the deployment, read from the receipt.</ResponseField>
    <ResponseField name="signerAddress" type="string">Registered wallet for this instance. Oracle signer and role checks are evaluated against it.</ResponseField>
    <ResponseField name="liquidationRouterAddress" type="string">Liquidation router serving this market.</ResponseField>
    <ResponseField name="configurationStatus" type="object">On-chain wiring state read back from the market contract.</ResponseField>
    <ResponseField name="stockTokenAuthStatus" type="object">Whether the market and router are authorised contracts on the stock token.</ResponseField>
    <ResponseField name="configurationSteps" type="array">Remaining setup steps, each with the role required to execute it.</ResponseField>
    <ResponseField name="configurationCalldata" type="object">Ready-to-sign calldata keyed by step, for the steps not yet complete.</ResponseField>
    <ResponseField name="alreadyRecorded" type="boolean">Present and `true` when the market was already registered. The call is idempotent and returns `200` instead of `201`.</ResponseField>
  </Expandable>
</ResponseField>

<Warning>
  The market is not usable until the stock token issuer authorises both the market and the liquidation router on the token via `addAuthorizedContract`. Those steps come back in `configurationSteps` with calldata in `configurationCalldata`.
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-stocks/api/markets/confirm-deploy" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "stockTokenAddress": "0xabc...def",
      "txHash": "0x9f2c...a41b",
      "issuerAddress": "0x111...222",
      "adminAddress": "0x333...444"
    }'
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    'https://api.trusset.org/lending-stocks/api/markets/confirm-deploy',
    {
      method: 'POST',
      headers: {
        'X-API-Key': 'trusset_your_key_here',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        stockTokenAddress: '0xabc...def',
        txHash: tx.hash,
        issuerAddress: '0x111...222',
        adminAddress: '0x333...444'
      })
    }
  );
  const { data } = await res.json();

  for (const [step, calldata] of Object.entries(data.configurationCalldata)) {
    console.log(step, calldata.description);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "market": {
        "id": "clx_market_002",
        "marketAddress": "0x70a0...9c2d",
        "oracleAddress": "0x8b2e...4a7c",
        "stockTokenSymbol": "ACME",
        "borrowAssetSymbol": "USDC"
      },
      "txHash": "0x9f2c...a41b",
      "signedBy": "0x123...456",
      "signerAddress": "0x123...456",
      "liquidationRouterAddress": "0x4c1f...8e3b",
      "configurationSteps": [
        { "step": "authorizeMarketOnStockToken", "requiredRole": "ISSUER_ROLE", "done": false },
        { "step": "authorizeRouterOnStockToken", "requiredRole": "ISSUER_ROLE", "done": false }
      ],
      "configurationCalldata": {
        "authorizeMarketOnStockToken": {
          "to": "0xabc...def",
          "data": "0x1e4f8a20...",
          "description": "Authorize the lending market on the stock token (requires ISSUER_ROLE)"
        }
      }
    }
  }
  ```

  ```json Error - Wrong Token theme={null}
  {
    "success": false,
    "error": {
      "code": "TX_WRONG_ARGS",
      "message": "Transaction deploys a market for a different stock token"
    }
  }
  ```
</ResponseExample>

## Errors

| Code                | HTTP  | Cause                                                           |
| ------------------- | ----- | --------------------------------------------------------------- |
| `VALIDATION_ERROR`  | `400` | A required field is missing or malformed                        |
| `TX_WRONG_TARGET`   | `400` | The transaction was not sent to the market factory              |
| `TX_WRONG_FUNCTION` | `400` | The transaction did not call `deployMarket`                     |
| `TX_WRONG_ARGS`     | `400` | The transaction deploys a market for a different stock token    |
| `TX_REVERTED`       | `400` | The deployment reverted on-chain                                |
| `TX_NOT_FOUND`      | `404` | No receipt yet. The deployment is unmined or on another network |
