> ## 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.

# Resource Locks

> How Resource Locks enable fast cross-chain transactions by eliminating finality wait times and preventing double-spending

## Overview

Resource Locks are OneBalance's innovative solution that transforms cross-chain transactions by delivering three critical improvements: **speed**, **reliability**, and **cost efficiency**.

Resource Locks enable cross-chain transactions to execute at the speed of the destination chain while providing cryptographic guarantees and reducing operational costs through optimized settlement patterns.

## How Resource Locks Work

Resource Locks are managed by OneBalance's RL Service, which performs four critical functions:

<Steps>
  <Step title="Verifies">
    Validates user on-chain and locked balances
  </Step>

  <Step title="Co-signs">
    Adds signatures to operations, ensures control over account state transition and prevents double-spending
  </Step>

  <Step title="Provides Guarantees">
    Issues security attestations to solvers for immediate delivery, given delayed settlement
  </Step>

  <Step title="Tracks Positions">
    Ensures not yet settled balance follows risk policies to maintain system integrity
  </Step>
</Steps>

<Info>
  This system enables asynchronous execution where intent fulfillment is separated from settlement, dramatically improving user experience.
</Info>

## Key Benefits

Resource Locks deliver three fundamental improvements to cross-chain operations:

<CardGroup cols={3}>
  <Card title="Speed" icon="zap">
    Execute cross-chain transactions in **seconds** instead of minutes by eliminating finality wait times and double-spend prevention delays.
  </Card>

  <Card title="Reliability" icon="shield-check">
    Cryptographic guarantees ensure **100% transaction success** with OneBalance's co-signing mechanism preventing failed or stuck transactions.
  </Card>

  <Card title="Cost Efficiency" icon="coins">
    Reduce gas costs by **up to 40%** through batched settlements and optimized cross-chain routing patterns.
  </Card>
</CardGroup>

### Speed: Near-Instant Execution

Traditional cross-chain transactions require waiting for source chain finality (often 12+ minutes on Ethereum). Resource Locks eliminate this wait by providing immediate execution guarantees through cryptographic co-signing.

### Reliability: Guaranteed Settlement

Unlike intent-based systems that can fail due to solver unavailability or market conditions, Resource Locks provide mathematical certainty that operations will complete successfully.

### Cost Efficiency: Optimized Economics

Resource Locks enable transaction batching and optimal routing decisions that significantly reduce the total cost of cross-chain operations for both users and applications.

## Evolution of Cross-Chain Bridging

<CardGroup cols={3}>
  <Card title="Classical Bridge" icon="clock">
    <div className="space-y-2 mt-4">
      <p className="text-sm font-semibold">
        Critical Path:
      </p>

      <p className="text-xs">
        Source chain finality + Destination chain inclusion
      </p>

      <p className="text-sm font-semibold mt-4">
        Typical Duration:
      </p>

      <p className="text-xs">
        3 minutes or more
      </p>
    </div>
  </Card>

  <Card title="Intent Bridge" icon="shield-half">
    <div className="space-y-2 mt-4">
      <p className="text-sm font-semibold">
        Critical Path:
      </p>

      <p className="text-xs">
        Source chain inclusion + Routing + Destination chain inclusion
      </p>

      <p className="text-sm font-semibold mt-4">
        Typical Duration:
      </p>

      <p className="text-xs">
        15-45 seconds
      </p>
    </div>
  </Card>

  <Card title="RL-enabled Bridge" icon="zap">
    <div className="space-y-2 mt-4">
      <p className="text-sm font-semibold">
        Critical Path:
      </p>

      <p className="text-xs">
        Lock verification + Routing + Destination chain inclusion
      </p>

      <p className="text-sm font-semibold mt-4">
        Typical Duration:
      </p>

      <p className="text-xs">
        5-10 seconds
      </p>
    </div>
  </Card>
</CardGroup>

### Classical Bridge: Source Chain Finality + Destination Chain Inclusion

Traditional bridges require waiting for source chain finality before processing on the destination chain, resulting in significant delays.

![Classical Bridge Flow](https://storage.googleapis.com/onebalance-public-assets/docs/concepts/ClassicalBridgeFlow.png)

### Intent Bridge: Solver Assumes Finality Risk

Intent-based bridges improve speed by having solvers take on the finality risk, but still require source chain inclusion.

![Intent Bridge Flow](https://storage.googleapis.com/onebalance-public-assets/docs/concepts/IntentBridgeFlow.png)

### Fast Intent Bridge: Lock Provider Eliminates Double-Spend and Finality Risk

<Tip>
  OneBalance's Fast Intent Bridge achieves near-instant cross-chain execution by removing both double-spend risk and finality waiting times through Resource Locks.
</Tip>

![Fast Intent Bridge Flow](https://storage.googleapis.com/onebalance-public-assets/docs/concepts/FastIntentBridgeFlow.png)

## Types of Resource Locks

Resource Locks fall into two main categories:

1. **Account-based locks** - Locks are implemented at the account level, allowing seamless compatibility with existing user flows and wallet interactions.
2. **Escrow-based locks** - Instead of locking accounts, this approach implements an escrow smart contract where users deposit tokens for cross-chain operations.

Currently, OneBalance primarily uses account-based locks for optimal user experience and compatibility.

Once Resource Lock is enabled, transactions can be sent only via OneBalance Toolkit, as otherwise it is impossible to prevent the double-spending in asynchronious execution environment.

<Info>
  For detailed integration instructions, see our [Getting Started](/getting-started/introduction) guide.
</Info>

## Additional Resources

Dive deeper into Resource Locks with these resources:

<CardGroup cols={1}>
  <Card title="ETH Research Paper: Introducing OneBalance" icon="file-text" href="https://ethresear.ch/t/introducing-onebalance/19557">
    Technical deep-dive into Resource Locks architecture, cryptographic proofs, and formal verification of the system's security guarantees.
  </Card>

  <Card title="Interop/Acc Podcast: Resource Locks Explained" icon="podcast" href="https://youtu.be/79IdtPkQ6XE?si=s3NwpV704FZb6gKy">
    A discussion on how Resource Locks solve cross-chain interoperability challenges and their impact on the ecosystem.
  </Card>

  <Card title="Into the Bytecode: OneBalance Technical Overview" icon="headphones" href="https://youtu.be/fKoE9h50ch0?si=Lg936OxEDfhLAxPH">
    Technical breakdown of OneBalance's implementation, covering Resource Locks, account abstraction, and cross-chain execution patterns.
  </Card>
</CardGroup>
