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

# Contract Calls Overview

> Overview of OneBalance smart contract calls, enabling cross-chain execution with gas abstraction and unified asset management.

Contract calls enable you to execute any smart contract operation using your aggregated balance. This powerful feature allows for complex DeFi operations, NFT interactions, gaming actions, and custom business logic - all while benefiting from unified asset management.

## What Are Contract Calls?

Contract calls let you interact with smart contracts on any supported chain while OneBalance handles:

* **Cross-chain token routing** - Use tokens from any chain to pay for operations
* **Automatic gas abstraction** - No need to hold native tokens on target chains
* **Token approvals** - Automatic ERC20 approvals when needed
* **Transaction bundling** - Multiple operations in a single user experience

<Warning>
  **Account Configuration Required**: Contract calls require proper account setup. Choose your account model based on your security and operational needs. See [Account Models](/concepts/accounts) for setup instructions.
</Warning>

## Quick Example

Here's how to transfer USDC on Arbitrum using funds from your aggregated balance:

```bash Terminal theme={null}
curl -X POST "https://be.onebalance.io/api/quotes/prepare-call-quote" \
  -H "x-api-key: ONEBALANCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "account": {
      "sessionAddress": "0x1cBF...",
      "adminAddress": "0xc162...",
      "accountAddress": "0xE202..."
    },
    "targetChain": "eip155:42161",
    "calls": [{
      "to": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
      "data": "0xa9059cbb000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e0000000000000000000000000000000000000000000000000000000005f5e100",
      "value": "0x0"
    }],
    "tokensRequired": [{
      "assetType": "eip155:42161/erc20:0xaf88d065e77c8cc2239327c5edb3a432268e5831",
      "amount": "100000000"
    }],
    "allowanceRequirements": []
  }'
```

## Cross-Chain Funding with Solana

You can fund EVM contract calls using assets from Solana for cost efficiency and liquidity access:

<CardGroup cols={2}>
  <Card title="Solana Contract Calls" icon="code" href="/guides/solana/contract-calls">
    Complete examples for funding EVM contract calls with SOL and USDC from Solana
  </Card>

  <Card title="EIP-7702 + Solana" icon="key" href="/guides/solana/contract-calls#eip-7702-integration">
    Use Solana assets with EIP-7702 delegated accounts for atomic cross-chain execution
  </Card>
</CardGroup>

<Info>
  Solana funding enables you to leverage cheaper transaction fees and access SOL/USDC liquidity for EVM contract execution.
</Info>

## How It Works

OneBalance contract calls are executed through a three-phase process that handles all the complexity behind the scenes.

### Phase Breakdown

1. **Prepare Quote** - Submit your contract calls and requirements to get executable operations. OneBalance analyzes your requirements, generates user operations, and calculates optimal routing across chains.
2. **Sign Target Operation** - Sign the generated target chain operation with your wallet. This happens client-side using standard EIP-712 typed data signatures. See [Signing Guide](/concepts/signing) for complete implementation details.
3. **Get Full Quote** - Submit the signed target operation to get the complete cross-chain quote including all origin chain operations required.
4. **Sign & Execute** - Sign all origin chain operations, then submit the fully signed quote for execution across all chains.

```mermaid theme={null}
flowchart LR
    A[Prepare Quote] --> B[Sign Target] --> C[Get Full Quote] --> D[Sign & Execute]
```

### Detailed Flow

For those interested in the technical details, here's the complete execution flow:

```mermaid theme={null}
sequenceDiagram
    participant User
    participant OneBalance API
    participant Origin Chain
    participant Target Chain

    Note over User, Target Chain: Phase 1: Preparation
    User->>OneBalance API: 1. Prepare call quote
    Note right of OneBalance API: • Analyze requirements<br/>• Generate target operation<br/>• Calculate routing
    OneBalance API-->>User: Target operation + typed data

    Note over User, Target Chain: Phase 2: Sign Target
    User->>User: 2. Sign target operation
    Note right of User: • Sign with session key<br/>• EIP-712 signature
    User->>OneBalance API: 3. Get full quote

    Note over User, Target Chain: Phase 3: Get Full Quote
    OneBalance API-->>User: Complete quote with origin operations
    User->>User: 4. Sign all origin operations
    Note right of User: • Sign each origin operation<br/>• Multiple signatures

    Note over User, Target Chain: Phase 4: Execution
    User->>OneBalance API: 5. Execute quote
    OneBalance API->>Origin Chain: Execute origin operations
    Note right of Origin Chain: • Token transfers<br/>• Cross-chain bridging
    OneBalance API->>Target Chain: Execute target operation
    Note right of Target Chain: • Smart contract calls<br/>• Token settlements
    OneBalance API-->>User: Transaction confirmations
```

<Tip>
  Each phase uses specific API endpoints:

  * **Phase 1: Prepare** - [POST /quotes/prepare-call-quote](/api-reference/quotes/prepare-call-quote) - Analyzes your calls and generates target operation
  * **Phase 2: Sign Target** - Client-side signing with your wallet or library
  * **Phase 3: Get Full Quote** - [POST /quotes/call-quote](/api-reference/quotes/get-call-quote) - Returns complete cross-chain quote
  * **Phase 4: Execute** - [POST /quotes/execute-quote](/api-reference/quotes/execute-quote) - Submits fully signed quote for execution
</Tip>

## Common Use Cases

<CardGroup cols={2}>
  <Card title="Token Operations" icon="coins">
    Cross-chain transfers, swaps, and token management
  </Card>

  <Card title="DeFi Protocols" icon="trending-up">
    Lending, borrowing, staking, and yield farming
  </Card>

  <Card title="NFT Interactions" icon="image">
    Minting, trading, and marketplace operations
  </Card>

  <Card title="DAO Governance" icon="vote">
    Proposal voting and treasury management
  </Card>
</CardGroup>

### Real-World Examples

* **Cross-chain DEX Trading** - Use USDC from Polygon to trade on Uniswap on Base
* **Multi-chain Staking** - Stake ETH on Ethereum using tokens from your Arbitrum balance
* **NFT Minting** - Mint NFTs on any chain using your unified token balance
* **DAO Participation** - Vote on proposals using tokens from multiple chains

## Benefits

<CardGroup cols={2}>
  <Card title="Unified Experience" icon="globe">
    One API for all chains and protocols
  </Card>

  <Card title="Gas Efficiency" icon="zap">
    Optimized routing and batched operations
  </Card>

  <Card title="Enhanced UX" icon="sparkles">
    No chain switching or token bridging required
  </Card>

  <Card title="Developer Friendly" icon="code">
    Simple integration with existing smart contracts
  </Card>
</CardGroup>

<Info>
  **Getting Started**: All examples in this section use **Role-Based** accounts. For complete setup instructions and to choose the right account model for your needs, see [Account Models](/concepts/accounts).
</Info>

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart Guide" icon="rocket" href="/guides/contract-calls/getting-started">
    Build your first contract call integration step-by-step
  </Card>

  <Card title="Working Examples" icon="file-code" href="/guides/contract-calls/examples">
    Copy-paste examples for common use cases and protocols
  </Card>

  <Card title="Advanced Patterns" icon="layers" href="/guides/contract-calls/advanced-patterns">
    Complex scenarios, batch operations, and optimization techniques
  </Card>

  <Card title="Approvals & Allowances" icon="shield-check" href="/guides/contract-calls/allowances-and-approvals">
    Handle token approvals and permission management
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/guides/contract-calls/troubleshooting">
    Debug common issues and error handling strategies
  </Card>
</CardGroup>
