# BaseCore

`BaseCore.sol` contains the base logic for the proxy contracts used in the Unlockd Protocol. It provides functions for creating and managing module proxies and handling module-specific logic.

### Key variables:

`_moduleLookup`: A mapping that stores the implementation address for each module ID.

`_proxyLookup`: A mapping that stores the proxy address for each module ID (only for single-proxy modules).

`_trustedSenders`: A mapping that stores the trusted sender information for each proxy address, including the module ID and implementation address (only for external single-proxy modules).

### Key functions:

```solidity
function _createProxy(
    uint256 proxyModuleId
) internal returns (address)
```

Creates a new proxy contract for the specified module ID. It deploys a new instance of the `UnlockdMinimalProxy` contract and stores the proxy address in the `_proxyLookup` mapping if the module ID is within the range of external single-proxy modules. It also updates the `_trustedSenders` mapping with the module ID and implementation address for the proxy.

### Parameters:

`proxyModuleId`: The ID of the module for which to create a proxy.

### Returns:&#x20;

The address of the created proxy contract.

***

```solidity
function callInternalModule(
    uint256 moduleId,
    bytes memory input
  ) internal returns (bytes memory)
```

Performs a delegatecall to the specified module contract with the provided input data. It retrieves the module implementation address from the `_moduleLookup` mapping and delegates the call using assembly. If the call fails, it reverts with the returned error data.

### Parameters:

`moduleId`: The ID of the module to call.

`input`: The input data for the module call.

### Returns:&#x20;

The return data from the module call.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devs.unlockd.finance/core/debt-tokens-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
