> ## Documentation Index
> Fetch the complete documentation index at: https://docs.biconomy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Web3 Automation: Automated Blockchain Transactions

> Learn about Web3 automation: automated blockchain transactions, scheduled execution, trigger-based operations, and building autonomous onchain agents

# Web3 Automation: Automated Blockchain Transactions

<Accordion title="What is Web3 automation?">
  **Web3 automation** enables blockchain transactions to execute automatically without manual user intervention. This includes:

  * **Scheduled transactions**: Execute at specific times or intervals
  * **Trigger-based execution**: React to onchain or offchain events
  * **Conditional operations**: Execute when certain conditions are met
  * **Autonomous agents**: AI or rule-based systems managing onchain activities

  Automation transforms blockchain from a manual, click-to-execute system into a programmable, always-on infrastructure.
</Accordion>

<Accordion title="What are common Web3 automation use cases?">
  | Category           | Use Cases                                                                                      |
  | ------------------ | ---------------------------------------------------------------------------------------------- |
  | **DeFi**           | Auto-compounding yields, rebalancing portfolios, stop-loss orders, recurring investments (DCA) |
  | **Trading**        | Limit orders, arbitrage bots, MEV strategies, market making                                    |
  | **Treasury**       | Scheduled payments, payroll, vesting distributions                                             |
  | **Gaming**         | Auto-claiming rewards, resource harvesting, scheduled actions                                  |
  | **Infrastructure** | Oracle updates, keeper operations, protocol maintenance                                        |
  | **Personal**       | Subscription payments, recurring transfers, automated savings                                  |
</Accordion>

<Accordion title="How do automated transactions work?">
  Automated transactions require three components:

  1. **Authorization**: User grants permission for specific actions
  2. **Trigger**: Condition or schedule that initiates execution
  3. **Executor**: Service that submits the transaction when triggered

  ```
  ┌──────────────┐     ┌──────────────┐     ┌──────────────┐
  │    User      │────▶│   Session    │────▶│   Executor   │
  │  (one-time   │     │    Key       │     │   (always    │
  │   setup)     │     │  (limited    │     │    online)   │
  └──────────────┘     │   scope)     │     └──────────────┘
                       └──────────────┘            │
                                                   ▼
                                            ┌──────────────┐
                                            │  Blockchain  │
                                            └──────────────┘
  ```

  With session keys, users can authorize specific automated actions without exposing their main private key.
</Accordion>

<Accordion title="What are session keys and how do they enable automation?">
  **Session keys** are temporary, scoped signing keys that enable secure automation:

  * **Time-limited**: Valid only for a specific duration
  * **Action-scoped**: Can only perform specific operations
  * **Revocable**: User can cancel authorization anytime
  * **Non-custodial**: User retains full control of main wallet

  ```typescript theme={null}
  import { createSessionKey } from "@biconomy/abstractjs";

  // Create a session key for automated swaps
  const session = await createSessionKey({
    account: smartAccount,
    permissions: [
      {
        type: "contract-call",
        target: UNISWAP_ROUTER,
        functions: ["exactInputSingle"],
        constraints: {
          maxValue: parseEther("1.0"), // Max 1 ETH per transaction
          dailyLimit: parseEther("10.0") // Max 10 ETH per day
        }
      }
    ],
    expiry: Date.now() + 7 * 24 * 60 * 60 * 1000 // 7 days
  });
  ```

  The executor uses this session key to submit transactions within the defined scope.
</Accordion>

<Accordion title="What are agentic signers?">
  **Agentic signers** are autonomous programs that hold session keys and execute transactions based on predefined logic or AI decisions. Types include:

  | Type               | Description                  | Example                                                |
  | ------------------ | ---------------------------- | ------------------------------------------------------ |
  | **Rule-based**     | Executes on fixed conditions | Stop-loss bot: sell if price drops 10%                 |
  | **Schedule-based** | Executes at intervals        | DCA bot: buy \$100 ETH every week                      |
  | **AI-powered**     | Uses ML for decisions        | Trading agent: analyze market and optimize entries     |
  | **Event-driven**   | Reacts to onchain events     | Arbitrage bot: execute when price discrepancy detected |

  ```typescript theme={null}
  // Example: Agentic signer for DCA strategy
  const dcaAgent = new AgentSigner({
    sessionKey: session,
    strategy: {
      type: "schedule",
      interval: "weekly",
      action: {
        type: "swap",
        from: "USDC",
        to: "ETH",
        amount: "100"
      }
    }
  });

  dcaAgent.start(); // Runs autonomously
  ```
</Accordion>

<Accordion title="How do I set up automated DeFi trades?">
  Setting up automated trading with Biconomy involves:

  **Step 1: Create a smart account with MEE**

  ```typescript theme={null}
  import { createMeeClient, toMultichainNexusAccount } from "@biconomy/abstractjs";

  const account = await toMultichainNexusAccount({
    signer: ownerSigner,
    chains: [base, arbitrum]
  });

  const meeClient = await createMeeClient({ account });
  ```

  <Note>
    MEE (Modular Execution Environment) provides all ERC-4337 bundler and paymaster functionality needed for automation, plus cross-chain capabilities.
  </Note>

  **Step 2: Define automation policy**

  ```typescript theme={null}
  const policy = {
    permissions: [{
      type: "defi",
      protocols: ["uniswap-v3", "aave"],
      actions: ["swap", "deposit", "withdraw"],
      constraints: {
        maxSlippage: 0.5, // 0.5%
        dailyVolumeLimit: parseEther("100")
      }
    }],
    validUntil: Date.now() + 30 * 24 * 60 * 60 * 1000 // 30 days
  };
  ```

  **Step 3: Grant session to executor**

  ```typescript theme={null}
  const session = await account.createSession({
    policy,
    executor: AUTOMATION_SERVICE_ADDRESS
  });
  ```

  **Step 4: Configure automation logic**

  ```typescript theme={null}
  await automationService.configure({
    sessionId: session.id,
    triggers: [
      { type: "price", token: "ETH", condition: "lt", value: 2000 },
      { type: "schedule", cron: "0 0 * * 1" } // Every Monday
    ],
    actions: [...]
  });
  ```
</Accordion>

<Accordion title="What security measures exist for automation?">
  Biconomy's automation infrastructure includes multiple security layers:

  | Protection             | Description                                              |
  | ---------------------- | -------------------------------------------------------- |
  | **Scoped permissions** | Session keys can only perform explicitly allowed actions |
  | **Spending limits**    | Per-transaction, daily, and total limits on value        |
  | **Time bounds**        | Sessions automatically expire after set duration         |
  | **Revocation**         | Users can cancel sessions instantly                      |
  | **Allowlists**         | Restrict to specific contracts and functions             |
  | **Rate limits**        | Prevent excessive transaction frequency                  |

  ```typescript theme={null}
  // Example: Highly restricted session
  const restrictedSession = {
    permissions: [{
      target: SPECIFIC_CONTRACT,
      functions: ["deposit"],
      constraints: {
        maxValuePerTx: parseEther("0.1"),
        maxTxPerDay: 5,
        maxTotalValue: parseEther("1.0")
      }
    }],
    validUntil: Date.now() + 24 * 60 * 60 * 1000, // 24 hours only
    requireConfirmationAbove: parseEther("0.5") // Require user signature above 0.5 ETH
  };
  ```
</Accordion>

<Accordion title="Can I automate cross-chain operations?">
  Yes! Biconomy's automation supports cross-chain workflows:

  ```typescript theme={null}
  const crossChainAutomation = {
    trigger: {
      type: "price",
      chain: 1, // Monitor on Ethereum
      token: "ETH",
      condition: "gt",
      value: 4000
    },
    action: {
      type: "orchestrated",
      instructions: [
        { chain: 1, action: "swap", from: "ETH", to: "USDC" },
        { action: "bridge", from: 1, to: 8453 }, // Bridge to Base
        { chain: 8453, action: "deposit", protocol: "aave" }
      ]
    }
  };
  ```

  The automation service handles:

  * Cross-chain message passing
  * Bridge monitoring
  * Gas on all chains (can be sponsored)
  * Failure recovery
</Accordion>

<Accordion title="What's the difference between keepers and automation?">
  | Aspect            | Traditional Keepers            | Smart Account Automation       |
  | ----------------- | ------------------------------ | ------------------------------ |
  | **Control**       | Protocol-controlled            | User-controlled                |
  | **Scope**         | Protocol-specific tasks        | Any user-defined action        |
  | **Authorization** | Relies on protocol permissions | Session keys with user consent |
  | **Flexibility**   | Fixed functionality            | Fully programmable             |
  | **Cost**          | Usually subsidized by protocol | User or sponsor pays           |

  Biconomy's automation lets *users* set up their own "keepers" for personal workflows.
</Accordion>

<Accordion title="How do I build an AI-powered trading agent?">
  Building an AI agent with Biconomy MEE:

  ```typescript theme={null}
  import { createMeeClient, toMultichainNexusAccount, createSession } from "@biconomy/abstractjs";
  import { TradingAI } from "./your-ai-model";

  // 1. Setup smart account with MEE
  const account = await toMultichainNexusAccount({
    signer: ownerSigner,
    chains: [base]
  });
  const meeClient = await createMeeClient({ account });

  // 2. Create scoped session for AI
  const session = await createSession({
    account,
    permissions: [{
      type: "trading",
      maxPositionSize: parseEther("10"),
      allowedPairs: ["ETH/USDC", "BTC/USDC"],
      maxSlippage: 1 // 1%
    }]
  });

  // 3. Initialize AI with session
  const agent = new TradingAI({
    sessionKey: session.key,
    meeClient,
    
    async onDecision(action) {
      // AI decides to trade - execute via MEE
      if (action.type === "buy") {
        const quote = await meeClient.getQuote({
          instructions: [buildSwapInstruction(action)],
          feeToken: { address: "sponsored" }
        });
        return meeClient.executeQuote({ quote, sessionKey: session.key });
      }
    }
  });

  // 4. Run agent
  agent.start({
    dataFeeds: ["price", "volume", "sentiment"],
    decisionInterval: 60 * 1000 // Every minute
  });
  ```
</Accordion>

***

## Start automating

<CardGroup cols={2}>
  <Card title="Automate DeFi Trades" icon="chart-line" href="/faq/automate-defi-trades">
    Build automated trading strategies
  </Card>

  <Card title="Session Policies" icon="shield" href="/agents-automation/policies/index">
    Configure automation permissions
  </Card>
</CardGroup>
