The deBridge Ability enables Vincent Apps to bridge tokens across multiple blockchains using the deBridge protocol on behalf of Vincent Users. This allows Vincent Apps to facilitate cross-chain transfers without requiring users to manually approve each bridging transaction.
The deBridge Ability is built using the Vincent Ability SDK and operates in two phases:
Precheck Phase: Validates all prerequisites for the bridge operation
Execution Phase: Executes the cross-chain bridge transaction
Depending on your role in the Vincent Ecosystem, you'll be interacting with this Ability in different ways. Click on the link below that matches your role to see how to get started:
If you want to enable your App Delegatees to bridge tokens across chains on behalf of your Vincent App Users, you can add this Ability to your App.
Adding Abilities to your Vincent App is done using the Vincent App Dashboard. Visit the Create Vincent App guide to learn more about how to add Abilities to your App during creation, or check out the Upgrading Your App guide to learn how to add Abilities to an existing App.
Note
To learn more about executing Vincent Abilities, see the Executing Abilities guide.
Before executing the Ability, the following conditions must be met. You can use the Ability's precheck
function to check if these conditions are met, or you can check them manually.
The Vincent App User's Vincent Wallet must have sufficient balance of the source token to cover the bridge amount plus any protocol fees.
The Vincent Wallet must have sufficient native tokens on the source chain to pay for the bridge transaction gas fees.
For ERC-20 token transfers, the Vincent App User's Vincent Wallet must have approved the deBridge contract to spend the source token.
If your Vincent App has enabled the ERC20 Approval Ability, you can use it to handle submitting the approval transaction using the Vincent Wallet.
precheck
FunctionThis Ability's precheck
function validates all prerequisites for executing a cross-chain bridge operation and provides quote information.
Before executing the precheck
function, you'll need to provide the following parameters for the bridge operation:
{
/**
* RPC URL for the source chain
*/
rpcUrl: string;
/**
* Source chain ID (e.g., '1' for Ethereum, '8453' for Base)
*/
sourceChain: string;
/**
* Destination chain ID (e.g., '1' for Ethereum, '8453' for Base)
*/
destinationChain: string;
/**
* Source token address
* (use 0x0000000000000000000000000000000000000000 for native token)
*/
sourceToken: string;
/**
* Destination token address
* (use 0x0000000000000000000000000000000000000000 for native token)
*/
destinationToken: string;
/**
* Amount to bridge in smallest token unit (e.g., '1000000000000000000' for 1 ETH)
*/
amount: string;
/**
* Slippage tolerance in basis points (100 = 1%). Optional, defaults to 100.
*/
slippageBps?: number;
}
To execute precheck
, you'll need to:
VincentAbilityClient
using the getVincentAbilityClient
function (imported from @lit-protocol/vincent-app-sdk/abilityClient
)
bundledVincentAbility
object (imported from @lit-protocol/vincent-ability-debridge
)ethersSigner
you'll be using to sign the request to Lit with your Delegatee private keyprecheck
functionVincentAbilityClient
instance to call the precheck
functionNote
To learn more about executing Vincent Abilities, see the Executing Abilities guide.
import { getVincentAbilityClient } from '@lit-protocol/vincent-app-sdk/abilityClient';
import { bundledVincentAbility } from '@lit-protocol/vincent-ability-debridge';
// Create ability client
const abilityClient = getVincentAbilityClient({
bundledVincentAbility: bundledVincentAbility,
ethersSigner: yourEthersSigner,
});
// Prepare bridge parameters - Example: Bridge 0.1 ETH from Base to Arbitrum
const bridgeParams = {
rpcUrl: 'https://mainnet.base.org',
sourceChain: '8453', // Base
destinationChain: '42161', // Arbitrum
sourceToken: '0x0000000000000000000000000000000000000000', // Native ETH
destinationToken: '0x0000000000000000000000000000000000000000', // Native ETH
amount: '100000000000000000', // 0.1 ETH in wei
slippageBps: 100, // 1% slippage
};
const precheckResult = await abilityClient.precheck(bridgeParams, {
delegatorPkpEthAddress: '0x...', // The Vincent App User's Vincent Wallet address
});
if (precheckResult.success) {
const { data } = precheckResult.result;
console.log('Estimated destination amount:', data.estimatedDestinationAmount);
console.log('Protocol fee:', data.estimatedFees.protocolFee);
console.log('Estimated execution time:', data.estimatedExecutionTime + ' seconds');
} else {
// Handle different types of failures
if (precheckResult.runtimeError) {
console.error('Runtime error:', precheckResult.runtimeError);
}
if (precheckResult.schemaValidationError) {
console.error('Schema validation error:', precheckResult.schemaValidationError);
}
if (precheckResult.result) {
console.error('Bridge precheck failed:', precheckResult.result.error);
}
}
A successful precheck
response will contain detailed bridge information:
{
data: {
/**
* Source chain ID
*/
sourceChain: string;
/**
* Destination chain ID
*/
destinationChain: string;
/**
* Source token address
*/
sourceToken: string;
/**
* Destination token address
*/
destinationToken: string;
/**
* Amount being sent in smallest token unit
*/
sourceAmount: string;
/**
* Estimated amount to be received on destination chain
*/
estimatedDestinationAmount: string;
/**
* Estimated fees for the transaction
*/
estimatedFees: {
/**
* Protocol fee in smallest token unit
*/
protocolFee: string;
}
/**
* Estimated time for the bridge operation in seconds
*/
estimatedExecutionTime: string;
}
}
A failure precheck
response will contain:
{
/**
* Error message describing why the precheck failed
*/
error: string;
}
execute
FunctionThis Ability's execute
function performs the actual cross-chain bridge transaction.
The execute
function expects the same parameters as the precheck
function, and can be executed using the same VincentAbilityClient
instance:
const executeResult = await abilityClient.execute(bridgeParams, {
delegatorPkpEthAddress: '0x...', // The Vincent App User's Vincent Wallet address
});
if (executeResult.success) {
const { data } = executeResult.result;
console.log('Bridge transaction hash:', data.txHash);
console.log('Order ID for tracking:', data.orderId);
console.log('Bridged amount:', data.sourceAmount);
} else {
// Handle different types of failures
if (executeResult.runtimeError) {
console.error('Runtime error:', executeResult.runtimeError);
}
if (executeResult.schemaValidationError) {
console.error('Schema validation error:', executeResult.schemaValidationError);
}
if (executeResult.result) {
console.error('Bridge execution failed:', executeResult.result.error);
}
}
A successful execute
response will contain:
{
data: {
/**
* Transaction hash of the bridge transaction
*/
txHash: string;
/**
* Source chain ID
*/
sourceChain: string;
/**
* Destination chain ID
*/
destinationChain: string;
/**
* Source token address
*/
sourceToken: string;
/**
* Destination token address
*/
destinationToken: string;
/**
* Amount sent in smallest token unit
*/
sourceAmount: string;
/**
* Order ID for tracking the bridge transaction (optional)
*/
orderId?: string;
};
}
A failure execute
response will contain:
{
/**
* Error message describing why the execution failed
*/
error: string;
}
The deBridge Ability supports bridging between the following networks:
1
8453
42161
10
137
56
43114
When bridging native tokens (ETH, MATIC, etc.), use the zero address: 0x0000000000000000000000000000000000000000
The amount
parameter must be specified in the token's smallest unit:
1
ETH = 1000000000000000000
wei)1
USDC = 1000000
micro-USDC)10^18
Bridge operations are not instantaneous. The estimatedExecutionTime
from the precheck provides an estimate, but actual times can vary based on network congestion and the specific token pair.
The orderId
returned from successful executions can be used to track the bridge status through deBridge's tracking interface or API.
Bridge operations include protocol fees that are automatically deducted from the source amount. The precheck response provides fee estimates, but final fees may vary slightly.
Common failure scenarios include: