# Reactive Execution

**Use Case:** Monitor on-chain wallets, addresses, or smart contracts and trigger trades or logic based on specific activity.\
**How Treza Helps:** Agents can listen for state changes (e.g., whale deposits, token unlocks) and react within sub-seconds by executing logic inside trusted enclaves.

Examples:

* Copy-trading top wallets in real time
* React to DAO proposals or governance actions
* Exit positions based on smart contract events

```ts
import { TrezaClient } from '@treza/sdk'

const client = new TrezaClient({
  apiKey: process.env.TREZA_API_KEY,
})

// Agent listens for wallet activity and reacts to large deposits
const task = {
  taskName: '0xwallet_monitor_v2', // pre-deployed reactive strategy
  inputs: {
    watchAddress: '9xWhale123...', // target wallet to monitor
    triggerCondition: {
      token: 'USDC',
      threshold: 50000, // trigger on $50k+ deposit
    },
    action: {
      type: 'copyTrade',
      pair: 'SOL/USDC',
      amountPct: 0.1, // copy with 10% size of detected trade
    },
  },
  mode: 'watch', // special mode for long-running monitoring tasks
}

async function startMonitoring() {
  const result = await client.submitTask(task)
  console.log('Monitoring initiated:', result)
}

startMonitoring()
```

> 🔁 Use `mode: 'watch'` for tasks that stay live and respond to on-chain events. Treza handles the infra and execution logic trustlessly.

***

#### Create Your First Enclave with the SDK

[**GitHub**](https://github.com/treza-labs)\
Start building with Treza’s open-source libraries and examples.

[**Treza SDK**](https://github.com/treza-labs/treza-sdk)\
Create secure enclaves and run your application privately inside Docker containers.

[**Add KYC to Your App with Treza**](https://github.com/treza-labs/treza-contracts)\
Private, zero-knowledge identity verification for KYC/AML.


---

# 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.trezalabs.com/use-cases/reactive-execution.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.
