# TokenSpender

It is the ‘asset manager’ of the Opium Protocol. Its core responsibility is to manage the transfer of ERC20 and `ERC721O` tokens.&#x20;

Its only consumer contract in the Opium Protocol is the Core contract, which makes use of the `TokenSpender` for actions such as receiving the required margin (collateral) from a user upon a financial product’s creation and transferring the said margin upon a financial product’s execution according to the payout and the outcome fetched at expiry from the `OracleAggregator`.

### Contract functions description

**`claimTokens(IERC20 token, address from, address to, uint256 amount) external onlyWhitelisted`**

As an argument it takes an ERC20 address, the address of the sender from, the address of the recipient to and the `uint256 amount` to be managed. Its main responsibility is to transfer the money from the sender to the recipient with the specified quantity. The function’s usage is restricted by the modifier `onlyWhitelisted`, which allows only a set of whitelisted contracts to call a function to which it is applied. The whitelist of the allowed contracts is managed by the Opium Protocol’s governance contracts.

**`claimPositions(IERC721O token, address from, address to, uint256 tokenId, uint256 amount) onlyWhitelisted`**

As an argument it takes an `ERC721O` address, the address of the sender from, the address of the recipient to and the uint256 amount to be managed. Its main responsibility is to transfer the money from the sender to the recipient with the specified quantity. The function’s usage is restricted by the modifier `onlyWhitelisted`, which allows only a set of whitelisted contracts to call a function to which it is applied. The whitelist of the allowed contracts is managed by the Opium Protocol’s governance contracts.


---

# 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://docs.opium.network/for-developers/protocol/token-spender.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.
