# trade()

```solidity
    function trade(Token token, uint128 targetAmount) external payable;
```

This function will allow anyone to trade the existing tokens held by the contract at the indicated price available in the contract at the moment of execution.&#x20;

Currently, ETH is paired with BNT while all other tokens are paired with ETH.

{% hint style="info" %}
It is recommended to first identify the current price using the relevant [read functions](/contracts-and-functions/carbonvortex-functions/read-functions.md)
{% endhint %}

### **Function Arguments**

<table><thead><tr><th width="162">Name</th><th width="114.66666666666663">Type</th><th>Description</th></tr></thead><tbody><tr><td>token</td><td>Token</td><td>The token address of the token you would like to trade out of the contract</td></tr><tr><td>targetAmount</td><td>uint128</td><td>The amount of target tokens you would like to trade out of the contract</td></tr></tbody></table>

### Example

{% code overflow="wrap" %}

```solidity
trade(
0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c, //token address
1000000000000000000000 //token amount indicated in the token wei 
)
```

{% endcode %}

During function execution, the required source token amount would be deducted from the caller wallet in return for the target token amount the caller is asking to trade out of the contract.

{% hint style="warning" %}
Approve is required for this transaction
{% endhint %}


---

# 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.carbondefi.xyz/contracts-and-functions/carbonvortex-functions/write-functions/trade.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.
