bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 31쪽 중 18쪽
a
// to different chains simultaneously - that's why Submission.findAll()
// returns an array of Submission objects
const submissions = await evm.Submission.findAll(transactionHash, context);
// take the first submission.
// DO YOUR OWN SANITY CHECKS TO ENSURE IT CONTAINS THE EXPECTED NUMBER OF SUBMISSIONS
const [submission] = submissions;
```
## Checking the status of the submission
The submission gets accepted by the validators after a transaction (containing the cross-chain call has been submitted) receives 12 block
confirmations (256 for the Polygon chain). This is a required transaction finality validators are waiting for to avoid the consequences of the network
divergence. You can monitor the finality of the transaction in a few ways: either using the preferred library (web3.js, ethers.js, or whatever) or
with a [little help of deSDK](https://github.com/debridge-finance/desdk#tracking-submissions):
```solidity theme={null}
// check if submission if confirmed: validator nodes wait a specific block
// confirmations before sign the message. Currently, 12 blocks is expected
// for most supported EVM chains (256 for Polygon).
const isConfirmed = await submission.hasRequiredBlockConfirmations();
```
The number of block confirmations required for sent messages can be found in Fees and Supported Chains section
## Pulling signatures
After the origin transaction receives enough block confirmations, we may start pulling the signatures. Currently, signatures are available through the
deBridge API: you can query them manually by calling the API directly, or use deSDK which additionally checks if enough signatures have been published
already:
```ts theme={null}
if (isConfirmed) {
const claim = await submission.toEVMClaim(evmDestinationContext);
// check if claim has been signed by enough validators
await isSigned = await claim.isSigned();
}
```
## Crafting transactions to claiming a submission
After the submission has been confirmed and signed by enough validators, it's time to craft a claiming transaction that will land down the submission
and execute the message on the destination chain.
To claim a submission, a call to the `deBridgeGate.claim()` method on the destination chain must be crafted using the data from taken from various
sources, which isn't an easy task, so there is deSDK which [takes the burden of data
preparation](https://github.com/debridge-finance/desdk#tracking-and-executing-claims):
```ts theme={null}
// the resulting tuple of args to be then passed to the deBridgeGate.claim() method
const claimArgs = await claim.getEncodedArgs();
// e.g. using ethers.js:
// await deBridgeGate.claim(...claimArgs, { gasLimit: 8_000_000 });
```
Then you can pass the args to the `deBridgeGate.claim()` method, and finally sign and broadcast your transaction and wait for the `Claimed` event. This
will indicate a successful submission completion.
<Warning>
Keep in mind that estimating gas for such transaction may have undesirable pitfalls that we have covered in our small research - this may be the case
if you turn off the `REVERT_IF_EXTERNAL_FAIL` flag. We recommend using professional transaction simulation services (offered by Tenderly or Blocknative)
rather than calling your RPC's `eth_estimateGas` endpoint.
</Warning>
# Further reading
* Consider using the [debridge-hardhat](https://github.com/debridge-finance/hardhat-debridge) plugin for Hardhat to test your contracts on the
emulated environment
* Find the [source code](https://github.com/debridge-finance/debridge-cross-chain-dapp-example) of the example project examined in this document,
along with tests and helper commands.
* Start using [deSDK](https://github.com/debridge-finance/desdk) to send, track and claim submissions programmatically
* Watch the walkthrough video on how to use deBridge emulator for your development environment:
debridge protocol advanced topics:
* [Gathering data for the claim](/dmp-details/dev-guides/gathering-data-for-claim)
* deBridge protocol flags explained (coming soon)
* Transaction bundling explained (coming soon)
* Execution fee explained (coming soon)
* Bridging arbitrary assets explained (coming soon)
# ICallProxy
Source: https://docs.debridge.com/dmp-details/dev-guides/evm/interfaces/ICallProxy
ICallProxy interface details - functions.
## Functions
### submissionChainIdFrom
```solidity theme={null}
function submissionChainIdFrom() external returns (uint256)
```
Chain from which the current submission is received.
### submissionNativeSender
```solidity theme={null}
function submissionNativeSender() external returns (bytes)
```
Native sender of the current submission.
### call
```solidity theme={null}
function call(
address _reserveAddress,
address _receiver,
bytes _data,
uint256 _flags,
bytes _nativeSender,
uint256 _chainIdFrom
) external returns (bool)
```
Used for calls where native asset transfer is involved.
**Parameters:**
| Name | Type | Description |
| ----------------- | --------- | ------------------------------------- |
| `_reserveAddress` | `address` | Receiver if call to `_receiver` fails |
| `_receiver` | `address` | Contract to be called |
| `_data` | `bytes` | Call data |
| `_flags` | `uint256` | Behavior flags (see Flags library) |
| `_nativeSender` | `bytes` | Native sender |
| `_chainIdFrom` | `uint256` | Chain ID of the originating chain |
### callERC20
```solidity theme={null}
function callERC20(
address _token,
address _reserveAddress,
address _receiver,
bytes _data,
uint256 _flags,
bytes _nativeSender,
uint256 _chainIdFrom
) external returns (bool)
```
Used for calls where ERC20 transfer is involved.
**Parameters:**
| Name | Type | Description |
| ----------------- | --------- | ------------------------------------- |
| `_token` | `address` | Asset address |
| `_reserveAddress` | `address` | Receiver if call to `_receiver` fails |
| `_receiver` | `address` | Contract to be called |
| `_data` | `bytes` | Call data |
| `_flags` | `uint256` | Behavior flags (see Flags library) |
| `_nativeSender` | `bytes` | Native sender |
| `_chainIdFrom` | `uint256` | Chain ID of the originating chain |
# IDeBridgeGate
Source: https://docs.debridge.com/dmp-details/dev-guides/evm/interfaces/IDeBridgeGate
IDeBridgeGate interface details - functions, events, and structs.
## Functions
### isSubmissionUsed
```solidity theme={null}
function isSubmissionUsed(
bytes32 submissionId
) external returns (bool)
```
Returns whether the transfer with the submissionId was claimed. submissionId is generated in `getSubmissionIdFrom`.
### getNativeInfo
```solidity theme={null}
function getNativeInfo(
address token
) external returns (uint256 nativeChainId, bytes nativeAddress)
```
Returns native token info by wrapped token address.
### send
```solidity theme={null}
function send(
address _tokenAddress,
uint256 _amount,
uint256 _chainIdTo,
bytes _receiver,
bytes _permit,
bool _useAssetFee,
uint32 _referralCode,
bytes _autoParams
) external
```
This method is used for the transfer of assets
[from the native chain](/dmp-details/dePort/transfer-flow#transfers-from-native-source-chain). It locks an asset in the smart
contract in the native chain and enables minting of deAsset on the secondary chain.
**Parameters:**
| Name | Type | Description |
| --------------- | --------- | ------------------------------------------------------------- |
| `_tokenAddress` | `address` | Asset identifier. |
| `_amount` | `uint256` | Amount to be transferred (note: the fee can be applied). |
| `_chainIdTo` | `uint256` | Chain id of the target chain. |
| `_receiver` | `bytes` | Receiver address. |
| `_permit` | `bytes` | deadline + signature for approving the spender by signature. |
| `_useAssetFee` | `bool` | use assets fee for pay protocol fix (only for special tokens) |
| `_referralCode` | `uint32` | Referral code |
| `_autoParams` | `bytes` | Auto params for external call in target network |
### claim
```solidity theme={null}
function claim(
bytes32 _debridgeId,
uint256 _amount,
uint256 _chainIdFrom,
address _receiver,
uint256 _nonce,
bytes _signatures,
bytes _autoParams
) external
```
Used for transfers [into the native chain](/dmp-details/dePort/transfer-flow#transfers-from-native-source-chain) to unlock the
designated amount of asset from collateral and transfer it to the receiver.
**Parameters:**
| Name | Type | Description |
| -------------- | --------- | --------------------------------------------------------------- |
| `_debridgeId` | `bytes32` | Asset identifier. |
| `_amount` | `uint256` | Amount of the transferred asset (note: the fee can be applied). |
| `_chainIdFrom` | `uint256` | Chain where submission was sent |
| `_receiver` | `address` | Receiver address. |
| `_nonce` | `uint256` | Submission id. |
| `_signatures` | `bytes` | Validators signatures to confirm |
| `_autoParams` | `bytes` | Auto params for external call |
### flash
```solidity theme={null}
function flash(
address _tokenAddress,
address _receiver,
uint256 _amount,
bytes _data
) external
```
Get a flash loan, msg.sender must implement IFlashCallback.
**Parameters:**
| Name | Type | Description |
| --------------- | --------- | ------------------------------- |
| `_tokenAddress` | `address` | An asset to loan |
| `_receiver` | `address` | Where funds should be sent |
| `_amount` | `uint256` | Amount to loan |
| `_data` | `bytes` | Data for sender's flashCallback |
### getDefiAvaliableReserves
```solidity theme={null}
function getDefiAvaliableReserves(
address _tokenAddress
) external returns (uint256)
```
Get reserves of a token available to use in DeFi.
**Parameters:**
| Name | Type | Description |
| --------------- | --------- | -------------- |
| `_tokenAddress` | `address` | Token address. |
### requestReserves
```solidity theme={null}
function requestReserves(
address _tokenAddress,
uint256 _amount
) external
```
Request the assets to be used in DeFi protocol.
**Parameters:**
| Name | Type | Description |
| --------------- | --------- | ------------------ |
| `_tokenAddress` | `address` | Asset address. |
| `_amount` | `uint256` | Amount to request. |
### returnReserves
```solidity theme={null}
function returnReserves(
address _tokenAddress,
uint256 _amount
) external
```
Return the assets that were used in DeFi protocol.
**Parameters:**
| Name | Type | Description |
| --------------- | --------- | ----------------- |
| `_tokenAddress` | `address` | Asset address. |
| `_amount` | `uint256` | Amount to return. |
### withdrawFee
```solidity theme={null}
function withdrawFee(
bytes32 _debridgeId
) external
```
Withdraw collected fees to feeProxy.
**Parameters:**
| Name | Type | Description |
| ------------- | --------- | ----------------- |
| `_debridgeId` | `bytes32` | Asset identifier. |
### getDebridgeChainAssetFixedFee
```solidity theme={null}
function getDebridgeChainAssetFixedFee(
bytes32 _debridgeId,
uint256 _chainId
) external returns (uint256)
```
Returns asset fixed fee value for specified debridge and chainId.
**Parameters:**
| Name | Type | Description |
| ------------- | --------- | ----------------- |
| `_debridgeId` | `bytes32` | Asset identifier. |
| `_chainId` | `uint256` | Chain id. |
## Events
### Sent
```solidity theme={null}
event Sent(
bytes32 submissionId,
bytes32 debridgeId,
uint256 amount,
bytes receiver,
uint256 nonce,
uint256 chainIdTo,
uint32 referralCode,
struct IDeBridgeGate.FeeParams feeParams,
bytes autoParams,
address nativeSender
)
```
Emitted once the tokens are sent from the original(native) chain to the other chain; the transfer tokens are expected to be
claimed by the users.
### Claimed
```solidity theme={null}
event Claimed(
bytes32 submissionId,
bytes32 debridgeId,
uint256 amount,
address receiver,
uint256 nonce,
uint256 chainIdFrom,
bytes autoParams,
bool isNativeToken
)
```
Emitted once the tokens are transferred and withdrawn on a target chain.
### PairAdded
```solidity theme={null}
event PairAdded(
bytes32 debridgeId,
address tokenAddress,
bytes nativeAddress,
uint256 nativeChainId,
uint256 maxAmount,
uint16 minReservesBps
)
```
Emitted when new asset support is added.
### MonitoringSendEvent
```solidity theme={null}
event MonitoringSendEvent(
bytes32 submissionId,
uint256 nonce,
uint256 lockedOrMintedAmount,
uint256 totalSupply
)
```
### MonitoringClaimEvent
```solidity theme={null}
event MonitoringClaimEvent(
bytes32 submissionId,
uint256 lockedOrMintedAmount,
uint256 totalSupply
)
```
### ChainSupportUpdated
```solidity theme={null}
event ChainSupportUpdated(
uint256 chainId,
bool isSupported,
bool isChainFrom
)
```
Emitted when the asset is allowed/disallowed to be transferred to the chain.
### ChainsSupportUpdated
```solidity theme={null}
event ChainsSupportUpdated(
uint256 chainIds,
struct IDeBridgeGate.ChainSupportInfo chainSupportInfo,
bool isChainFrom
)
```
Emitted when the supported chains are updated.
### CallProxyUpdated
```solidity theme={null}
event CallProxyUpdated(
address callProxy
)
```
Emitted when the new call proxy is set.
### AutoRequestExecuted
```solidity theme={null}
event AutoRequestExecuted(
bytes32 submissionId,
bool success,
address callProxy
)
```
Emitted when the transfer request is executed.
### Blocked
```solidity theme={null}
event Blocked(
bytes32 submissionId
)
```
Emitted when a submission is blocked.
### Unblocked
```solidity theme={null}
event Unblocked(
bytes32 submissionId
)
```
Emitted when a submission is unblocked.
### Flash
```solidity theme={null}
event Flash(
address sender,
address tokenAddress,
address receiver,
uint256 amount,
uint256 paid
)
```
Emitted when a flash loan is successfully returned.
### WithdrawnFee
```solidity theme={null}
event WithdrawnFee(
bytes32 debridgeId,
uint256 fee
)
```
Emitted when fee is withdrawn.
### FixedNativeFeeUpdated
```solidity theme={null}
event FixedNativeFeeUpdated(
uint256 globalFixedNativeFee,
uint256 globalTransferFeeBps
)
```
Emitted when `globalFixedNativeFee` and `globalTransferFeeBps` are updated.
### FixedNativeFeeAutoUpdated
```solidity theme={null}
event FixedNativeFeeAutoUpdated(
uint256 globalFixedNativeFee
)
```
Emitted when `globalFixedNativeFee` is updated by `feeContractUpdater`.
## Structs
### TokenInfo
```solidity theme={null}
struct TokenInfo {
uint256 nativeChainId;
bytes nativeAddress;
}
```
### DebridgeInfo
```solidity theme={null}
struct DebridgeInfo {
uint256 chainId;
uint256 maxAmount;
uint256 balance;
uint256 lockedInStrategies;
address tokenAddress;
uint16 minReservesBps;
bool exist;
}
```
### DebridgeFeeInfo
```solidity theme={null}
struct DebridgeFeeInfo {
uint256 collectedFees;
uint256 withdrawnFees;
mapping(uint256 => uint256) getChainFee;
}
```
### ChainSupportInfo
```solidity theme={null}
struct ChainSupportInfo {
uint256 fixedNativeFee;
bool isSupported;
uint16 transferFeeBps;
}
```
### DiscountInfo
```solidity theme={null}
struct DiscountInfo {
uint16 discountFixBps;
uint16 discountTransferBps;
}
```
### SubmissionAutoParamsTo
```solidity theme={null}
struct SubmissionAutoParamsTo {
uint256 executionFee;
uint256 flags;
bytes fallbackAddress;
bytes data;
}
```
### SubmissionAutoParamsFrom
```solidity theme={null}
struct SubmissionAutoParamsFrom {
uint256 executionFee;
uint256 flags;
address fallbackAddress;
bytes data;
bytes nativeSender;
}
```
### FeeParams
```solidity theme={null}
struct FeeParams {
uint256 receivedAmount;
uint256 fixFee;
uint256 transferFee;
bool useAssetFee;
bool isNativeToken;
}
```
# IDeBridgeToken
Source: https://docs.debridge.com/dmp-details/dev-guides/evm/interfaces/IDeBridgeToken
IDeBridgeToken interface details - functions.
## Functions
### mint
```solidity theme={null}
function mint(
address _receiver,
uint256 _amount
) external
```
Issues new tokens.
**Parameters:**
| Name | Type | Description |
| ----------- | --------- | -------------------- |
| `_receiver` | `address` | Token's receiver. |
| `_amount` | `uint256` | Amount to be minted. |
### burn
```solidity theme={null}
function burn(
uint256 _amount
) external
```
Destroys existing tokens.
**Parameters:**
| Name | Type | Description |
| --------- | --------- | ------------------- |
| `_amount` | `uint256` | Amount to be burnt. |
# IDeBridgeTokenDeployer
Source: https://docs.debridge.com/dmp-details/dev-guides/evm/interfaces/IDeBridgeTokenDeployer
IDeBridgeTokenDeployer interface details - functions and events.
## Functions
### deployAsset
```solidity theme={null}
function deployAsset(
bytes32 _debridgeId,
string _name,
string _symbol,
uint8 _decimals
) external returns (address deTokenAddress)
```
Deploy a deToken(`DeBridgeTokenProxy`) for an asset.
**Parameters:**
| Name | Type | Description |
| ------------- | --------- | ------------------------------------------ |
| `_debridgeId` | `bytes32` | Asset id, see `DeBridgeGate.getDebridgeId` |
| `_name` | `string` | The asset's name |
| `_symbol` | `string` | The asset's symbol |
| `_decimals` | `uint8` | The asset's decimals |
## Events
### DeBridgeTokenDeployed
```solidity theme={null}
event DeBridgeTokenDeployed(
address asset,
string name,
string symbol,
uint8 decimals
)
```
Emitted when a deToken(`DeBridgeTokenProxy`) is deployed using this contract
# IOraclesManager
Source: https://docs.debridge.com/dmp-details/dev-guides/evm/interfaces/IOraclesManager
IOraclesManager interface details - events and structs.
## Events
### AddOracle
```solidity theme={null}
event AddOracle(
address oracle,
bool required
)
```
Emitted when an oracle is added.
**Parameters:**
| Name | Type | Description |
| ---------- | --------- | ------------------------------------------------------ |
| `oracle` | `address` | Address of an added oracle |
| `required` | `bool` | Is this oracle's signature required for every transfer |
### UpdateOracle
```solidity theme={null}
event UpdateOracle(
address oracle,
bool required,
bool isValid
)
```
Emitted when an oracle is updated.
**Parameters:**
| Name | Type | Description |
| ---------- | --------- | ------------------------------------------------------ |
| `oracle` | `address` | Address of an updated oracle |
| `required` | `bool` | Is this oracle's signature required for every transfer |
| `isValid` | `bool` | Is this oracle valid, i.e. should it be treated as one |
### DeployApproved
```solidity theme={null}
event DeployApproved(
bytes32 deployId
)
```
Emitted once the submission is confirmed by min required amount of oracles.
### SubmissionApproved
```solidity theme={null}
event SubmissionApproved(
bytes32 submissionId
)
```
Emitted once the submission is confirmed by min required amount of oracles.
## Structs
### OracleInfo
```solidity theme={null}
struct OracleInfo {
bool exist;
bool isValid;
bool required;
}
```
# ISignatureVerifier
Source: https://docs.debridge.com/dmp-details/dev-guides/evm/interfaces/ISignatureVerifier
ISignatureVerifier interface details - functions and events.
## Functions
### submit
```solidity theme={null}
function submit(
bytes32 _submissionId,
bytes _signatures,
uint8 _excessConfirmations
) external
```
Check confirmation (validate signatures) for the transfer request.
**Parameters:**
| Name | Type | Description |
| ---------------------- | --------- | -------------------------------- |
| `_submissionId` | `bytes32` | Submission identifier. |
| `_signatures` | `bytes` | Array of signatures by oracles. |
| `_excessConfirmations` | `uint8` | override min confirmations count |
## Events
### Confirmed
```solidity theme={null}
event Confirmed(
bytes32 submissionId,
address operator
)
```
Emitted once the submission is confirmed by one oracle.
### DeployConfirmed
```solidity theme={null}
event DeployConfirmed(
bytes32 deployId,
address operator
)
```
Emitted once the submission프로젝트로 돌아가기