Technical Docs
Dao Docs
  • ✨Concepts
    • What is Connext?
    • How It Works
      • Architecture
      • Transaction Lifecycle
    • Background
      • What is a Bridge?
      • Modular Bridges
      • Message Verification
    • Use Cases
    • FAQ
  • 🤝Developers
    • Introduction
    • Quickstart
    • Guides
      • Frontend
      • SDK
      • Estimating Fees
      • Tracking xCalls
      • Authentication
      • Handling Failed xCalls
      • Nested xCalls
    • Reference
      • SDK
        • SdkShared
        • SdkBase
        • SdkPool
        • SdkRouter
        • SdkUtils
        • Types
      • Contracts
        • Calls
        • Routers
        • Stableswap
      • Subgraphs
        • Entities
        • Sample Queries
        • Subgraph Resources
      • Integration
        • Adapters
        • Receivers
    • Examples
      • Simple Bridge
      • Authenticated Greeter
      • Ping Pong
  • 📦Usecases
    • xERC20
      • Setup Overview
      • Detailed Setup Guide
      • Connext and xERC20s
    • Chain Abstraction
      • Chain Abstraction Guide
    • xGovernance
  • 📜Resources
    • Subgraphs
    • Deployments
  • 🖥️Routers
    • Basics
    • Spinning Up
    • Guides
      • Community Guides
      • Providing Liquidity
      • Managing Your Router
      • Security
    • Reference
      • Configuration
Powered by GitBook
On this page
Edit on GitHub
  1. Developers
  2. Guides

Nested xCalls

Cross-chain calls can easily be composed together by xcalling within the xReceive function of a target contract. In effect, the target contract becomes the source contract of that nested xcall.

xCall in xReceive

contract Target is IXReceiver {
  function xReceive(
    bytes32 _transferId,
    uint256 _amount,
    address _asset,
    address _originSender,
    uint32 _origin,
    bytes memory _callData
  ) external returns (bytes memory) {
    // After handling the first xcall...
    ...

    // Send another xcall within the xReceive function!
    connext.xcall{value: relayerFee}(...);
  }
}

There are many ways to use nested xcalls to extend cross-chain functionality. With this technique, it's possible to:

  • Emulate the behavior of a "callback" between chains to verify state changes and/or followup asynchronously

  • Disperse data to multiple different chains at once

PreviousHandling Failed xCallsNextReference

Last updated 1 year ago

See this in action in the example.

🤝
Ping Pong