> ## Documentation Index
> Fetch the complete documentation index at: https://vowena-dependabot-github-actions-actions-checkout-7.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# initialize

> One-time contract initialization that sets the admin address and starts plan and subscription ID counters. Rejects subsequent calls.

```rust theme={null}
fn initialize(env: Env, admin: Address)
```

Sets the admin address and initializes the auto-incrementing counters (`NextPlanId = 1`, `NextSubId = 1`). This function can only be called once - subsequent calls will fail with `AlreadyInitialized`.

<Warning>
  This is a one-time setup function. Once called, it cannot be called again.
  Make sure the `admin` address is correct before deploying.
</Warning>

***

## Parameters

| Name    | Type      | Description                                                |
| ------- | --------- | ---------------------------------------------------------- |
| `admin` | `Address` | The admin address that will be stored in instance storage. |

***

## Authorization

None. This function has no `require_auth()` call - it relies on the fact that it can only succeed once. The first caller sets the admin.

***

## Return value

None (`void`).

***

## Events emitted

None.

***

## Error cases

| Code | Name                 | Description                                |
| ---- | -------------------- | ------------------------------------------ |
| 1    | `AlreadyInitialized` | The contract has already been initialized. |

***

## Examples

<Tabs>
  <Tab title="Soroban CLI">
    This is typically a one-time setup performed via the CLI immediately after contract deployment.

    ```bash theme={null}
    soroban contract invoke \
      --id CONTRACT_ID \
      --network testnet \
      --source DEPLOYER_SECRET \
      -- \
      initialize \
      --admin GADMIN...ADDR
    ```
  </Tab>

  <Tab title="SDK">
    While `initialize` is typically called via the CLI, the SDK does expose it:

    ```typescript theme={null}
    import { VowenaClient, NETWORKS } from "@vowena/sdk";

    const client = new VowenaClient({
      contractId: NETWORKS.testnet.contractId,
      rpcUrl: NETWORKS.testnet.rpcUrl,
      networkPassphrase: NETWORKS.testnet.networkPassphrase,
    });

    const tx = await client.buildInitialize({
      admin: "GADMIN...ADDR",
    });

    const signedXdr = await signTransaction(tx);
    await client.submitTransaction(signedXdr);
    ```
  </Tab>
</Tabs>

<Note>
  After initialization, the admin address is stored in instance storage and
  shares the contract's TTL. The counters start at 1, so the first plan created
  will have `plan_id = 1` and the first subscription will have `sub_id = 1`.
</Note>
