# Creating an Account and Depositing Funds

In SYMM, managing your trading capital starts with creating a dedicated sub‑account via the [MultiAccount](https://docs.symm.io/exchange-builder-documentation/frontend-builder-technical-guidance/multiaccount) contract. These sub‑accounts allow you to interact with the SYMM system by forwarding your calls through your deployed account contract.

### Step 1: Creating a Sub‑Account

1. **Navigate to the MultiAccount Contract:**
   * Use your preferred blockchain explorer or development tool to interact with the MultiAccount contract.
2. **Call `addAccount()`:**
   * Call `addAccount(string name)` function, passing a name for your sub‑account.
   * **Example Call:**

     ```solidity
     multiAccount.addAccount("TradingAccount");
     ```
3. **Check Transaction Logs:**
   * Once the transaction is mined, look for the `AddAccount` event in the transaction logs. An AddAccount event will be emitted:

     ```
     AddAccount(address owner, address account, string name)
     ```
4. **Query Your Accounts:**
   * You can also use the view function `getAccounts(address user, uint256 start, uint256 size)` on the MultiAccount contract to retrieve an array of your sub‑accounts.
   * **Parameters:**
     * `user`: Your wallet address.
     * `start`: The starting index (for pagination).
     * `size`: The number of accounts to return.
   * This returns a list of Account structs that include both the sub‑account addresses and their assigned names.

### Step 2: Depositing and Allocating Funds

After creating your sub‑account, the next step is to fund it. SYMM uses a two‑step process where you first deposit funds and then allocate those funds for trading.&#x20;

{% hint style="info" %}
Use the `depositAndAllocateForAccount()` function on the **MultiAccount** contract rather than the deposit/allocate functions on the Diamond contract to deposit and allocate to a sub-account.&#x20;
{% endhint %}

1. **Call** [**`depositAndAllocateForAccount`**](https://docs.symm.io/contract-documentation/symmio-perps-v0.8.4/helper-contracts/multiaccount#depositandallocateforaccount)**`()`:**
   * This function deposits collateral into your sub‑account and immediately allocates it for trading.
   * **Function Signature:**

     ```solidity
     function depositAndAllocateForAccount(address account, uint256 amount) external onlyOwner(account, msg.sender) whenNotPaused;
     ```
   * **Parameters:**
     * `account`: The address of your sub‑account.
     * `amount`: The amount of collateral you wish to deposit (in the token's native decimals).
2. **Process:**
   * The function retrieves the collateral token address from the Symmio platform.
   * It then transfers the specified amount from your wallet to the MultiAccount contract.
   * The contract approves the Symmio contract to spend the collateral.
   * It calls the `depositFor(account, amount)` function on the Symmio contract.
   * The amount is converted into 18‑decimals and passed to the `allocate(uint256)` function via an internal call.
   * **Example Call (JavaScript with web3):**

     ```javascript
     const depositAmount = web3.utils.toWei("10", "ether");
     await multiAccountContract.methods
       .depositAndAllocateForAccount(subAccountAddress, depositAmount)
       .send({ from: myWalletAddress });
     ```
3. **Events:**
   * On successful execution, the function emits two events:
     * **DepositForAccount:** Indicates that funds have been deposited into the sub‑account.
     * **AllocateForAccount:** Confirms that the deposited funds have been allocated for trading.

{% hint style="info" %}
The collateral token address can be found by calling `getCollateral()` on the SYMM Diamond's view facet
{% endhint %}
