Bridging WETH from Ethereum Mainnet to Base Mainnet Using the Across Bridge Plugin
Across is an interoperability protocol powered by intents. This guide provides step-by-step instructions for integrating the Across Bridge Plugin with BuildBear Sandboxes.
What is Across
Across is an interoperability protocol powered by intents. It is the first cross-chain intents protocol in production today, enabling the fastest and lowest-cost way to transfer value with better security tradeoffs compared to traditional bridge designs.
Introduction
This guide provides step-by-step instructions for integrating the Across Bridge Plugin with BuildBear Sandboxes. The Across Bridge Plugin enables developers to test and simulate cross-chain transactions using the Across Bridge interoperability protocol. This integration facilitates seamless asset transfers, intent-based execution, and enhanced cross-chain development in a controlled sandbox environment.
What You'll Learn
- How to install and configure the Across Bridge Plugin in your BuildBear Sandbox
- How to retrieve transfer quotes for bridging WETH from Ethereum Mainnet to Base Mainnet
- How to configure and execute a cross-chain WETH deposit on Ethereum Mainnet
- How to extract and decode the Deposit ID
- How to track the status of the deposit on Base Mainnet
Why Use the Across Bridge Plugin
Intents Explorer
- Track cross-chain intents and their execution status through the integrated explorer in the plugin.
Advanced Developer Configurations
- On-Chain Relayer Mimic: Simulate relayer behavior in test environments, ensuring transactions are picked up without relying on external relayers.
- Intent Fulfillment Delay: Introduce delays to evaluate execution performance under varying network conditions.
Cost-Effective Testing
- Test cross-chain applications using BuildBear Sandboxes without spending real assets or incurring mainnet transaction costs.
Real-Time Monitoring
- Use the built-in explorer for real-time monitoring of intents and status, removing reliance on testnet RPCs.
Step 1: Installing the Plugin
Install the Plugin
- Log in to your BuildBear account.
- Navigate to the Plugin Marketplace in both your source and destination sandboxes.
- Search for Across Bridge Plugin and click Install.
Configure the Sandboxes
- Create two new sandboxes or use existing ones.
- Open the Across Bridge Plugin.
- Link the sandboxes to configure cross-chain communication.
- Optionally configure advanced developer settings:
- On-Chain Relayer Mimic
- Intent Fulfillment Delay
Step 2: Defining and Submitting Cross-Chain Intents
Prerequisites
- Install dependencies listed in
package.json
- Add your private key and token information to the .env file
1. Define API URL and Endpoints
let BASE_URL = `https://api.buildbear.io/{from-sandbox-id}/plugin/across/{to-sandbox-id}`;
let GET_SUGGESTED_FEES = `/suggested-fees`;
let BRIDGE_STATUS = `/deposit/status`;
Replace {sandbox-id}
placeholders with your actual BuildBear sandbox IDs.
2. Define Bridge Parameters
let bridgeParams: BridgeParams = {
inputToken: `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2`, // WETH
outputToken: `0x4200000000000000000000000000000000000006`, // WETH
originChainId: 1,
destinationChainId: 8453,
amount: parseEther("0.1"),
};
3. (Optional) Type Declarations
Improve readability and debugging with types. See type-definitions.
4. Fetch Suggested Fees
async function getSuggestedFees(): Promise<RelayQuoteData | undefined> {
let res = await axios.get(`${BASE_URL}${GET_SUGGESTED_FEES}`, {
params: { ...bridgeParams }
});
return res.data;
}
5. Execute Deposit
async function depositToSpokePool(bridgeQuote: RelayQuoteData) {
const provider = new ethers.JsonRpcProvider("https://rpc.buildbear.io/{SANDBOX-ID}");
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
const spokePool = new ethers.Contract(
bridgeQuote.spokePoolAddress,
parseAbi(["function depositV3(...) external"]),
wallet
);
const inputAmount = bridgeParams.amount;
const outputAmount = BigInt(inputAmount) - BigInt(bridgeQuote.totalRelayFee.total);
const tx = await spokePool.depositV3(/* parameters */);
await tx.wait();
const receipt = await provider.getTransactionReceipt(tx.hash);
const depositId = BigInt(receipt?.logs[1].topics[2]).toString();
console.log(`Deposit ID: ${depositId}`);
await getDepositStatus(+depositId);
}
6. Track Deposit Status
async function getDepositStatus(depositId: number): Promise<DepositStatusData | undefined> {
let res = await axios.get(`${BASE_URL}${BRIDGE_STATUS}`, {
params: {
originChainId: bridgeParams.originChainId,
depositId,
},
});
return res.data;
}
Running the Bridge
let bridgeQuote = await getSuggestedFees();
if (bridgeQuote) {
depositToSpokePool(bridgeQuote);
}
Block Explorers and Transaction Debugging
- Use the BlockScout Explorer Plugin in your BuildBear sandbox to track token flows.
- Enable the Sentio plugin to debug and inspect smart contract traces and events.
We can easily observe flow of funds to/from the contracts
Observe the stack traces for a more deeper insight into the transaction
The Call Graph section shows call flow of different functions, across different contracts
We can also observe the tx on the Base Mainnet explorer in the sandbox, which shows the token flow for the tx for cross chain deposit
Similar to Ethereum Mainnet, we can also observe the fund flow, call traces, call graph for the bridge fill transaction on Base Mainnet
Conclusion
The Across Bridge Plugin for BuildBear Sandboxes offers a powerful way to simulate and test cross-chain bridging operations. In this guide, you:
- Set up and configured the plugin
- Fetched fee quotes and route information
- Executed a deposit on Ethereum Mainnet
- Tracked the deposit completion on Base Mainnet
For source code and more examples, check out the GitHub Repository.