Overview
DeBridgeGate is the core contract of the deBridge Protocol that handles all cross-chain asset transfers and arbitrary data messaging. Users interact with this contract to send assets or messages to other supported blockchain networks.
Contract Location : contracts/transfers/DeBridgeGate.sol
Key Features
Cross-chain asset transfers using lock-and-mint mechanism
Arbitrary data messaging between blockchains
Fee management and collection
Oracle-based transaction validation
Support for native tokens and ERC-20 assets
Configurable fee discounts
Admin-controlled asset and chain support
State Variables
Constants
Basis points denominator used for fee calculations (1 BPS = 0.01%)
Role identifier for governance monitoring that can pause transfers
Prefix used in submissionId calculation
Prefix used in deployId calculation
Key Variables
Address of the DeBridgeTokenDeployer contract for wrapped token creation
Current signature verifier contract address
Proxy contract address for executing cross-chain calls
Fallback fixed fee in native asset when chain-specific fee is not set
Fallback transfer fee in basis points when chain-specific fee is not set
Main Functions
send
Transfers assets to another blockchain network.
function send (
address _tokenAddress ,
uint256 _amount ,
uint256 _chainIdTo ,
bytes memory _receiver ,
bytes memory _permit ,
bool _useAssetFee ,
uint32 _referralCode ,
bytes calldata _autoParams
) external payable returns ( bytes32 submissionId );
Token address to transfer. Use address(0) for native token (ETH, BNB, etc.)
Amount to transfer (in token’s smallest unit)
Destination chain ID (e.g., 1 for Ethereum, 56 for BSC)
Receiver address on the destination chain (encoded as bytes)
EIP-2612 permit signature for gasless ERC-20 approvals (empty bytes if not used)
If true, deduct fees from transferred amount; if false, pay fees separately in native token
Referral code for fee sharing (0 if not used)
Encoded parameters for automatic execution on destination chain (empty if not used)
Unique identifier for this transfer submission
Example Usage:
// Send 0.1 ETH to BSC
bytes32 submissionId = deBridgeGate.send{value : 0.1 ether + protocolFee}(
address ( 0 ), // native token
0.1 ether , // amount
56 , // BSC chain ID
abi . encodePacked (receiver), // receiver address
"" , // no permit
false , // pay fee separately
0 , // no referral
"" // no auto params
);
// Approve tokens first
IERC20 (token). approve ( address (deBridgeGate), amount);
// Send tokens
bytes32 submissionId = deBridgeGate.send{value : protocolFee}(
tokenAddress, // ERC-20 token
amount, // amount to send
137 , // Polygon chain ID
abi . encodePacked (receiver), // receiver address
"" , // no permit
false , // pay fee separately
0 , // no referral
"" // no auto params
);
sendMessage
Sends arbitrary data to another blockchain without transferring assets.
function sendMessage (
uint256 _chainIdTo ,
bytes memory _targetContractAddress ,
bytes memory _targetContractCalldata
) external payable returns ( bytes32 submissionId );
Target contract address on destination chain (encoded as bytes)
Calldata to execute on the target contract
Example Usage:
// Encode the function call
bytes memory calldata = abi . encodeWithSignature (
"setValue(uint256)" ,
newValue
);
// Send message
bytes32 submissionId = deBridgeGate.sendMessage{value : protocolFee + executionFee}(
42161 , // Arbitrum chain ID
abi . encodePacked (targetContract), // target contract
calldata // function call
);
claim
Claims a cross-chain transfer on the destination chain using oracle signatures.
function claim (
bytes32 _debridgeId ,
uint256 _amount ,
uint256 _chainIdFrom ,
address _receiver ,
uint256 _nonce ,
bytes calldata _signatures ,
bytes calldata _autoParams
) external ;
In production, claiming is typically handled by automated keepers/executors. Users don’t need to call this function directly unless they want to claim manually.
Events
Sent
event Sent (
bytes32 submissionId ,
bytes32 debridgeId ,
uint256 amount ,
bytes receiver ,
uint256 nonce ,
uint256 chainIdTo ,
uint32 referralCode ,
FeeParams feeParams ,
bytes autoParams ,
address nativeSender
);
Emitted when assets or messages are sent cross-chain.
Claimed
event Claimed (
bytes32 submissionId ,
bytes32 debridgeId ,
uint256 amount ,
address receiver ,
uint256 nonce ,
uint256 chainIdFrom ,
bytes autoParams ,
bool isNativeToken
);
Emitted when a transfer is claimed on the destination chain.
Admin Functions
addExternalAsset Adds support for an external asset from another chain. function addExternalAsset (
address _tokenAddress ,
uint256 _chainId ,
uint256 _maxAmount ,
uint16 _minReservesBps ,
bytes memory _name ,
bytes memory _symbol
) external onlyAdmin ;
addNativeAsset Adds support for a native asset of the current chain. function addNativeAsset (
address _tokenAddress ,
uint256 _maxAmount ,
uint16 _minReservesBps
) external onlyAdmin ;
updateChainSupport Updates chain support configuration for sending or receiving transfers. function updateChainSupport (
uint256 _chainId ,
bool _isSupported ,
bool _isChainFrom
) external onlyAdmin ;
setChainFee Sets fixed and transfer fees for a specific chain. function setChainFee (
uint256 _chainId ,
uint256 _fixedNativeFee ,
uint16 _transferFeeBps ,
bool _isChainFrom
) external onlyAdmin ;
updateGlobalFee Updates global fallback fees. function updateGlobalFee (
uint256 _globalFixedNativeFee ,
uint16 _globalTransferFeeBps
) external onlyAdmin ;
updateFeeDiscount Sets fee discount for a specific address. function updateFeeDiscount (
address _address ,
uint16 _discountFixBps ,
uint16 _discountTransferBps
) external onlyAdmin ;
Fee Calculation
Fees consist of two components:
Fixed Native Fee : Paid in the native token of the source chain (ETH, BNB, etc.)
Transfer Fee : Percentage-based fee calculated on the transfer amount
// Get fee information
( uint256 fixedFee, uint256 transferFee) = deBridgeGate. getDebridgeFeeInfo (
debridgeId
);
// Calculate total fee
uint256 totalFee = fixedFee + (amount * transferFeeBps) / BPS_DENOMINATOR;
// Apply discounts if available
if (hasDiscount) {
fixedFee = fixedFee * (BPS_DENOMINATOR - discountFixBps) / BPS_DENOMINATOR;
transferFee = transferFee * (BPS_DENOMINATOR - discountTransferBps) / BPS_DENOMINATOR;
}
Security Considerations
Always verify that:
The destination chain is supported before sending
You send enough native tokens to cover protocol fees
The amount doesn’t exceed maxAmount for the asset
The receiver address is correctly encoded for the destination chain
Use the getDebridgeId function to check if an asset is supported before attempting a transfer.
Integration Checklist
Check Asset Support
Verify the asset is supported on both source and destination chains using getDebridge().
Calculate Fees
Query fee structure and calculate total fees including fixed and percentage-based components.
Approve Tokens (if ERC-20)
Approve DeBridgeGate to spend tokens or use permit for gasless approval.
Call send()
Execute the transfer with appropriate parameters and native token for fees.
Monitor Events
Listen for Sent event to confirm submission and track the submissionId.
DeBridgeTokenDeployer Manages wrapped token deployment
SignatureVerifier Verifies oracle signatures for claims
CallProxy Executes cross-chain calls
OraclesManager Manages validator network
Further Reading