Skip to main content

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

BPS_DENOMINATOR
uint256
default:"10000"
Basis points denominator used for fee calculations (1 BPS = 0.01%)
GOVMONITORING_ROLE
bytes32
Role identifier for governance monitoring that can pause transfers
SUBMISSION_PREFIX
uint256
default:"1"
Prefix used in submissionId calculation
DEPLOY_PREFIX
uint256
default:"2"
Prefix used in deployId calculation

Key Variables

deBridgeTokenDeployer
address
Address of the DeBridgeTokenDeployer contract for wrapped token creation
signatureVerifier
address
Current signature verifier contract address
callProxy
address
Proxy contract address for executing cross-chain calls
globalFixedNativeFee
uint256
Fallback fixed fee in native asset when chain-specific fee is not set
globalTransferFeeBps
uint16
Fallback transfer fee in basis points when chain-specific fee is not set

Main Functions

send

Transfers assets to another blockchain network.
Function Signature
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);
_tokenAddress
address
required
Token address to transfer. Use address(0) for native token (ETH, BNB, etc.)
_amount
uint256
required
Amount to transfer (in token’s smallest unit)
_chainIdTo
uint256
required
Destination chain ID (e.g., 1 for Ethereum, 56 for BSC)
_receiver
bytes
required
Receiver address on the destination chain (encoded as bytes)
_permit
bytes
EIP-2612 permit signature for gasless ERC-20 approvals (empty bytes if not used)
_useAssetFee
bool
required
If true, deduct fees from transferred amount; if false, pay fees separately in native token
_referralCode
uint32
Referral code for fee sharing (0 if not used)
_autoParams
bytes
Encoded parameters for automatic execution on destination chain (empty if not used)
submissionId
bytes32
Unique identifier for this transfer submission
Example Usage:
Send Native Token
// 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
);
Send ERC-20 Token
// 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 Signature
function sendMessage(
    uint256 _chainIdTo,
    bytes memory _targetContractAddress,
    bytes memory _targetContractCalldata
) external payable returns (bytes32 submissionId);
_chainIdTo
uint256
required
Destination chain ID
_targetContractAddress
bytes
required
Target contract address on destination chain (encoded as bytes)
_targetContractCalldata
bytes
required
Calldata to execute on the target contract
Example Usage:
Cross-Chain Message
// 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 Signature
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:
  1. Fixed Native Fee: Paid in the native token of the source chain (ETH, BNB, etc.)
  2. Transfer Fee: Percentage-based fee calculated on the transfer amount
Fee Calculation Example
// 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

1

Check Asset Support

Verify the asset is supported on both source and destination chains using getDebridge().
2

Calculate Fees

Query fee structure and calculate total fees including fixed and percentage-based components.
3

Approve Tokens (if ERC-20)

Approve DeBridgeGate to spend tokens or use permit for gasless approval.
4

Call send()

Execute the transfer with appropriate parameters and native token for fees.
5

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

Build docs developers (and LLMs) love