Documentation
Plugins

Across Bridge

BuildBear Across Bridge is a service that allows you to explore the blockchain.

Overview

The Across Bridge Plugin is a cutting-edge solution that integrates the Across Bridge interoperability protocol with BuildBear Sandboxes. This plugin empowers developers to simulate, test, and deploy cross-chain applications with unmatched speed and cost-efficiency. By leveraging the intent-based framework of Across Bridge, developers gain access to advanced tools for creating seamless cross-chain value transfers within a secure, BuildBear Sandbox environment.

Whether you're developing decentralized applications (dApps) or testing cross-chain solutions, the Across Bridge Plugin offers everything you need to streamline your development process.


Features

Interoperability with Cross-Chain Intents

Effortlessly transfer assets or data between multiple BuildBear Sandboxes using the Across Bridge protocol. Define, simulate, and execute cross-chain intents securely and efficiently within your Sandbox environment.

SDK and API Integration

  • Seamlessly integrate with the @across-protocol/app-sdk for building applications.
  • Use the Across API for advanced features such as querying intent status, requesting quotes, and monitoring cross-chain activities.

Intents Explorer

Track cross-chain intents and their execution status through an integrated explorer linked to the Across plugin.

Advanced Developer Config

  • On-Chain Relayer Mimic: Simulate real-world or user-defined conditions by configuring whether quotes should reflect real-time on-chain values or mock values for testing purposes.
  • Intent Fulfillment Delay: Set custom delays for intent fulfillment to simulate varying network conditions and better analyze cross-chain transaction performance.

How to Use

Step 1: Install the Plugin

  1. Log in to your BuildBear account and navigate to the Plugin Marketplace.
  2. Search for the "Across Bridge Plugin" and click "Install." Plugin Installation

Step 2: Configure Your Sandbox

  1. Create a new Sandbox or navigate to an existing one in the BuildBear Dashboard.
  2. Launch the Across Bridge Plugin and configure linked Sandboxes for cross-chain interaction.
  3. Optionally, set custom configurations for:
    • On-Chain Relayer Mimic
    • Fulfillment Delay

Step 3: Define and Submit Intents

  1. Use the Across API to fetch available routes, transfer limits, and quotes.

    You will need two sandboxes, one for the source chain and one for the destination chain.

    console.log('Fetching available quotes...');
    const apiUrl = 'https://api.buildbear.io/{from-sandbox-id}/plugin/across/{to-sandbox-id}/suggested-fees';
    const payload = {
        originChainId: sourceChainId,
        destinationChainId: destinationChainId,
        amount: ethers.utils.parseEther('0.1').toString(),
        outputToken: '<OUTPUT_TOKEN_CONTRACT_ADDRESS>',
        inputToken: '<INPUT_TOKEN_CONTRACT_ADDRESS>',
    };
     
    const response = await axios.post(apiUrl, payload);
    const { quote } = response.data;
    console.log('Quote received:', quote);
  2. Create an intent specifying the source chain, destination chain, asset type, and transaction details.

     const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
     
     // Bridge to the same address on the destination chain.
     // Note: If the depositor is not an EOA then the depositor's address
     // might not be valid on the destination chain.
     const depositor = <USER_ADDRESS>;
     const recipient = depositor;
     
     // Test WETH deposit.
     const inputToken = <ORIGIN_CHAIN_WETH_ADDRESS>;
     
     // The 0 address is resolved automatically to the equivalent supported
     // token on the the destination chain. Any other input/output token
     // combination should be advertised by the Across API available-routes
     // endpoint.
     const outputToken = ZERO_ADDRESS;
     
     // The outputAmount is set as the inputAmount - relay fees.
     // totalRelayFee.total is returned by the BuildBear-Across API suggested-fees
     // endpoint.
     const outputAmount = inputAmount.sub(BigNumber.from(response.totalRelayFee.total));
     
     // fillDeadline: A fill deadline of 5 hours. Can be up to
     // SpokePool.getCurrentTime() + SpokePool.fillDeadlineBuffer() seconds.
     const fillDeadlineBuffer = 18000;
     const fillDeadline = Math.round(Date.now() / 1000) + fillDeadlineBuffer;
     
     // timestamp is returned by the BuildBear-Across API suggested-fees endpoint.
     // This should be _at least 2_ mainnet blocks behind the current time
     // for best service from relayers.
     const quoteTimestamp = response.timestamp;
     
     // Exclusive relayer and exclusivity deadline should be taken from the
     // Across API suggested-fees response.
     const exclusivityDeadline = response.exclusivityDeadline;
     const exclusiveRelayer = response.exclusiveRelayer;
     
     // No message will be executed post-fill on the destination chain.
     // See `Across+ Integration` for more information.
     const message = "0x";
  3. Call the depositV3 method on the SpokePool of the source Sandbox.

    const spokePoolAddress = '<SPOKE_POOL_CONTRACT_ADDRESS>';
    const spokePool = new ethers.Contract(
        spokePoolAddress,
        ['function depositV3(uint256 destinationChainId, address recipient, address originToken, uint256 amount, uint64 relayerFeePct, bytes32 quoteHash) external payable'],
        signer
    );
     
    spokePool.depositV3(
        depositor,
        recipient,
        inputToken,
        outputToken,
        inputAmount,
        outputAmount,
        destinationChainId,
        exclusiveRelayer,
        quoteTimestamp,
        fillDeadline,
        exclusivityDeadline,
        message
    );

Step 4: Monitor and Verify

  1. Track intent execution using:
    • The integrated Intents Explorer in the plugin.
    • Across API endpoints for status and lifecycle updates.
    API URL: https://api.buildbear.io/{from-sandbox-id}/plugin/across/{to-sandbox-id}/deposit/status
    Reference: API Reference | Across Docs
  2. Verify fulfillment results on the destination Sandbox via emitted events or explorer data.

Step 5: Iterate and Optimize

Test various scenarios by adjusting configurations like relayer mimic settings, fulfillment delays, or transaction data to ensure your cross-chain application meets performance and reliability expectations.


Conclusion

The Across Bridge Plugin is your gateway to mastering cross-chain interoperability within BuildBear Sandboxes.