Build with deBridge πŸ› 
Get started building cross-chain applications
deBridge is a generic messaging protocol and decentralized infrastructure that enables any arbitrary cross-chain interactions in a single transaction. Due to the ability to simultaneously send arbitrary assets and data, deBridge acts as a unified framework for all cross-chain needs and is capable of interconnecting any smart contract on any blockchain.

Interact with the deBridge Infrastructure

Cross-chain smart contract calls through deBridge
Interaction with the deBridge infrastructure is as simple as calling the send method of debridgeGate smart-contract deployed on all supported blockchains. The method can be called by any arbitrary address β€” either EOA or smart contracts.
1
function send(
2
address _tokenAddress,
3
uint256 _amount,
4
uint256 _chainIdTo,
5
bytes memory _receiver,
6
bytes memory _permit,
7
bool _useAssetFee,
8
uint32 _referralCode,
9
bytes calldata _autoParams
10
) external payable;
Copied!
The method accepts the following parameters:
Parameter Name
Type
Description
_tokenAddress
address
Address of the token being sent (address(0) for chain base assets like ETH)
_amount
uint256
Token amount to be transferred
_chainIdTo
uint256
Id of the receiving chain
_receiver
bytes
Address of the receiver
_permit
bytes
In case the token being passed supports EIP-2612, signed permits can be used instead of allowance approvals
_useAssetFee
bool
Should also be set to False. (Reserved for future use by governance to accept fees in the form of the transferred token)
_referralCode
uint32
Your generated referral code
_autoParams
bytes
Structure that enables passing arbitrary messages and call data
You can always check examples of cross-chain applications provided below to see how parameters are set for the send method. Here is an example of the send method for an incrementor smart contract.
If you integrate with or build applications on top of the deBridge infrastructure, make sure you specify your referral code that can be generated by pressing the WAGMI button at https://app.debridge.finance/. Governance may thank you later for being an early builder.
_autoParams is a structure that allows passing arbitrary messages and call data to be executed as an external call to the receiver address in the destination chain. This structure also enables setting an executionFee, a reward suggested to any wallet or keeper that will complete the transaction on the target chain. It enables a crypto-economic design where gas fees are paid from the blockchain where the transaction is initiated. The _autoParams field has the following structure:
1
struct SubmissionAutoParamsTo {
2
uint256 executionFee;
3
uint256 flags;
4
bytes fallbackAddress;
5
bytes data;
6
}
Copied!
Parameter Name
Type
Description
executionFee
uint256
Suggested reward (in Tokens) paid to anyone who will execute transaction on the destination chain
flags
uint256
Flags set specific flows for call data execution
fallbackAddress
bytes
In case execution of call data fails, all tokens will be transferred to the fallback address
data
bytes
Message/Call data to be passed to the receiver on the destination chain during the external call execution
Flags are a bit mask that allows to achieve specific flow of the transaction execution on the destination chain.
1
library Flags {
2
/// @dev Flag to unwrap ETH
3
uint256 public constant UNWRAP_ETH = 0;
4
/// @dev Flag to revert if external call fails
5
uint256 public constant REVERT_IF_EXTERNAL_FAIL = 1;
6
/// @dev Flag to call proxy with a sender contract
7
uint256 public constant PROXY_WITH_SENDER = 2;
8
/// @dev Data is hash in DeBridgeGate send method
9
uint256 public constant SEND_HASHED_DATA = 3;
10
/// @dev First 24 bytes from data is gas limit for external call
11
uint256 public constant SEND_EXTERNAL_CALL_GAS_LIMIT = 4;
12
/// @dev Support tx bundling (multi-send) for externall call
13
uint256 public constant MULTI_SEND = 5;
14
}
Copied!
Flag Name
Value
Description
UNWRAP_ETH
0
Automatically unwrap blockchain base asset
REVERT_IF_EXTERNAL_FAIL
1
Revert transaction if external call was not completed
PROXY_WITH_SENDER
2
Set in case receiving smart contract should validate sending chain id and address
SEND_HASHED_DATA
3
Pass hash of the call data instead of data itself. Only those who know the original call data will be able to claim the transaction on the target chain. If this flag is set, transaction won't be automatically claimed by external keepers.
SEND_EXTERNAL_CALL_GAS_LIMIT
4
Specify minimal gas limit to be passed to external call during the transaction claim. Gas limit should be passed in the first 4 bytes of the data
MULTI_SEND
5
With this flag passed call data will be executed through Gnosis multisend implementation embedded into deBridge callProxy. (Receiver address is not used in this case). We recommend using https://github.com/gnosis/ethers-multisend to configure data for multisend
PROXY_WITH_SENDER should be set whenever the receiving smart contract should check whether the message sender is trusted or not. If the flag was set during the claim transaction on the destination chain, the deBridge protocol will automatically store the submissionNativeSender address and submissionChainIdFrom, so that the receiving smart contract can read the properties and validate if the sender is trusted.
The receiving smart contract should retrieve the address of callProxy from the debridgeGate smart contract. You can use onlyControllingAddress modifier or inherit it from BridgeAppBase.sol to properly implement this validation logic.

Cross-Chain Smart Contracts Examples

​