# Integration Example: Auto-Staking Workflow

The figure below demonstrates a typical workflow of how on‐chain rewards from a third‐party “Rewards Dapp” can be automatically re‑staked into a separate “Staking Dapp” via an off‑chain “Auto‑staking Service” and an MBA wallet module.&#x20;

<figure><img src="/files/Fou0jvVDSjT8Lu9kfxZC" alt=""><figcaption></figcaption></figure>

The auto-staking process consists of the following five steps:

**Step 1: Rewards Distribution → MBA** The third‑party Rewards Dapp issues a token transfer to the MBA address (0x1234) by calling `transfer(address recipient, uint256 amount)` on the token contract. Those tokens land in the MBA’s on‑chain account.

**Step 2: Event Monitoring by Off‑chain Indexer** The Auto‑staking Service’s off‑chain indexer watches the blockchain for the `Transfer` event to the user’s MBA address. As soon as it sees a new reward deposit, it triggers the next step.

**Step3: Indexer → Auto‑staking Contract Invocation** The indexer sends an on‑chain transaction invoking the Auto‑staking Service’s smart contract, passing in the recipient address (0x1234) so that the service can act on behalf of that user.

**Step 4: Auto‑staking Contract → MBA DelegateCall** The Auto‑staking Contract uses Solidity’s `call` to execute a payload `{stake(uint256 amount)}` in the context of the MBA. This means the MBA itself is authorizing the staking action, preserving the user’s on‑device key/security assumptions.

**Step 5: MBA → Third‑party Staking Dapp** Finally, the  MBA makes a standard `stake(uint256 amount)` call to the third‑party Staking Dapp’s contract (staking service can be provided by other projects), locking the newly received reward tokens into the staking program.


---

# 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.iotex.io/ioid/integration-example-auto-staking-workflow.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.
