> For the complete documentation index, see [llms.txt](https://instantmiso.gitbook.io/miso/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://instantmiso.gitbook.io/miso/dev/misofermentationvault-contracts/token-vault-contract.md).

# Token Vault Contract

### Address

### Lock and Unlock Functions

```
function lockTokens(
        address _tokenAddress,
        uint256 _amount,
        uint256 _unlockTime,
        address payable _withdrawer
    )
        public returns (uint256 _id)
```

| Parameter      | Description                                            |
| -------------- | ------------------------------------------------------ |
| \_tokenAddress | Address of the token locked.                           |
| \_amount       | Number of tokens locked.                               |
| \_unlockTime   | Timestamp number marking when tokens get unlocked.     |
| \_withdrawer   | Address where tokens can be withdrawn after unlocking. |

Function for locking tokens in the vault.

```
function withdrawTokens(
        address _tokenAddress,
        uint256 _index,
        uint256 _id,
        uint256 _amount
    )
        external
```

| Parameter      | Description                        |
| -------------- | ---------------------------------- |
| \_tokenAddress | Address of the token to withdraw.  |
| \_index        | Index number of the list with Ids. |
| \_id           | Id number of the locked item.      |
| \_amount       | Number of tokens to withdraw.      |

Function for withdrawing tokens from the vault.

### Read-Only Functions

```
function getItemAtUserIndex(
        uint256 _index,
        address _tokenAddress,
        address _user
    )
        external view returns (uint256, uint256, address, uint256)
```

| Name           | Description                                      |
| -------------- | ------------------------------------------------ |
| \_index        | Index number of the list with Item ids.          |
| \_tokenAddress | Address of the token corresponding to this Item. |
| \_user         | User address.                                    |

Function to retrieve data from the Item under user index number.

```
function getUserLockedItemAtIndex(
        address _user, 
        uint256 _index
    ) 
        external view returns (address)
```

| Name    | Description   |
| ------- | ------------- |
| \_user  | User address. |
| \_index | Index number. |

Function to retrieve token address at desired index for the specified user.

```
function getLockedItemAtId(uint256 _id) 
    external 
    view 
    returns (uint256, uint256, address, uint256)
```

| Name | Description |
| ---- | ----------- |
| \_id | Id number.  |

Function to retrieve all the data from Item struct under given Id.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://instantmiso.gitbook.io/miso/dev/misofermentationvault-contracts/token-vault-contract.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
