Skip to main content

Order Tracking

getOrderIdByTransactionHash

Retrieve the order ID associated with a transaction hash.
getOrderIdByTransactionHash(txHash: string): Promise<any>
txHash
string
required
Transaction hash from the source chain
return
Promise<any>
Returns order IDs associated with the transaction
Location: src/utils/deBridge/index.ts:1 Example:
const orderIds = await getOrderIdByTransactionHash(
  "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
);
console.log("Order IDs:", orderIds);

getOrderStatusByOrderId

Retrieve the current status and details of a bridge order.
getOrderStatusByOrderId(orderId: string): Promise<any>
orderId
string
required
Unique order identifier
return
Promise<any>
Returns complete order status including source and destination transaction details
Location: src/utils/deBridge/index.ts:22 Example:
const status = await getOrderStatusByOrderId("order-123");
console.log("Order status:", status.status);
console.log("Source chain tx:", status.srcChainTx);

Order Creation

createDebridgeBridgeOrder

Create a bridge order for cross-chain token transfer.
createDebridgeBridgeOrder(params: deBridgeOrderInput): Promise<deBridgeOrderResponse>
params
deBridgeOrderInput
required
Bridge order parameters object
srcChainId
string
required
Source chain ID
srcChainTokenIn
string
required
Token address on source chain
srcChainTokenInAmount
string
required
Amount to bridge in token’s smallest unit
dstChainId
string
required
Destination chain ID (must differ from source)
dstChainTokenOut
string
required
Token address on destination chain
dstChainTokenOutRecipient
string
required
Recipient address on destination chain
account
string
required
Sender’s wallet address
dstChainTokenOutAmount
string
Expected output amount (default: “auto”)
referralCode
number
Referral code for the transaction
affiliateFeePercent
number
Affiliate fee percentage (must be used with affiliateFeeRecipient)
affiliateFeeRecipient
string
Address to receive affiliate fees
return
Promise<deBridgeOrderResponse>
Returns bridge order details including transaction data
Location: src/utils/deBridge/createDeBridgeOrder.ts:17 Example:
const order = await createDebridgeBridgeOrder({
  srcChainId: "1",
  srcChainTokenIn: "0x...",
  srcChainTokenInAmount: "1000000",
  dstChainId: "137",
  dstChainTokenOut: "0x...",
  dstChainTokenOutRecipient: "0x...",
  account: "0x..."
});

createDebridgeBridgeHook

Create a bridge order with a hook for executing actions on the destination chain.
createDebridgeBridgeHook(params: deBridgeHookInput): Promise<deBridgeOrderResponse>
params
deBridgeHookInput
required
Bridge order parameters with hook
dlnHook
object
required
Hook object containing destination chain actions
All other parameters are the same as createDebridgeBridgeOrder
Location: src/utils/deBridge/createDeBridgeHook.ts:18 Example:
const orderWithHook = await createDebridgeBridgeHook({
  srcChainId: "1",
  srcChainTokenIn: "0x...",
  srcChainTokenInAmount: "1000000",
  dstChainId: "137",
  dstChainTokenOut: "0x...",
  dstChainTokenOutRecipient: "0x...",
  account: "0x...",
  dlnHook: {
    targetAddress: "0x...",
    callData: "0x..."
  }
});

createDeBridgeSameChainSwap

Create a same-chain token swap transaction.
createDeBridgeSameChainSwap(params: SameChainSwapInput): Promise<SameChainSwapResponse>
params
SameChainSwapInput
required
Same-chain swap parameters
chainId
string
required
Chain ID where the swap occurs
tokenIn
string
required
Input token address
tokenInAmount
string
required
Amount to swap in token’s smallest unit
tokenOut
string
required
Output token address
tokenOutRecipient
string
required
Recipient address
senderAddress
string
required
Sender’s wallet address
srcChainPriorityLevel
string
Priority level: “normal” or “high” (default: “normal”)
slippage
string
Slippage tolerance (default: “auto”)
referralCode
number
Referral code for tracking
affiliateFeePercent
number
Affiliate fee percentage (0-100)
Location: src/utils/deBridge/sameChainSwap.ts:4 Example:
const swap = await createDeBridgeSameChainSwap({
  chainId: "137",
  tokenIn: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC
  tokenInAmount: "1000000", // 1 USDC
  tokenOut: "0x0000000000000000000000000000000000000000", // MATIC
  tokenOutRecipient: "0x...",
  senderAddress: "0x..."
});

createDeBridgeSameChainSwapEstimate

Get an estimation for a same-chain token swap without creating a transaction.
createDeBridgeSameChainSwapEstimate(params: SameChainSwapEstimateInput): Promise<SameChainSwapEstimateResponse>
params
SameChainSwapEstimateInput
required
Estimation parameters
chainId
string
required
Chain ID where the swap will occur
tokenIn
string
required
Input token address
tokenInAmount
string
required
Amount to swap in token’s smallest unit
tokenOut
string
required
Output token address
slippage
string
Slippage tolerance (default: “auto”)
affiliateFeePercent
number
Affiliate fee percentage for calculation
Location: src/utils/deBridge/sameChainSwapEstimate.ts:4 Example:
const estimate = await createDeBridgeSameChainSwapEstimate({
  chainId: "137",
  tokenIn: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
  tokenInAmount: "1000000",
  tokenOut: "0x0000000000000000000000000000000000000000"
});
console.log("Expected output:", estimate.tokenOut.amount);

HTTP Utilities

post

Make a POST request to the deBridge API.
post(URL: string, requestBody: object): Promise<any>
URL
string
required
API endpoint URL
requestBody
object
required
Request body to send
Location: src/utils/http.ts:1

get

Make a GET request to the deBridge API.
get(URL: string): Promise<any>
URL
string
required
API endpoint URL
Location: src/utils/http.ts:26

Solana Utilities

prepareSolanaTransaction

Prepare a Solana transaction with appropriate priority fees and blockhash.
prepareSolanaTransaction(
  solRpcUrl: string,
  txData: string,
  solWallet: Keypair
): Promise<VersionedTransaction>
solRpcUrl
string
required
RPC URL of the Solana network
txData
string
required
Serialized transaction data from the API
solWallet
Keypair
required
Signer keypair
return
Promise<VersionedTransaction>
A signed Solana transaction ready for submission
Location: src/utils/solana.ts:12 Features:
  • Simulates the transaction to calculate compute units
  • Fetches recent prioritization fees and sets a median priority fee
  • Updates blockhash and signs the transaction

updatePriorityFee

Update the priority fee in a Solana transaction.
updatePriorityFee(
  tx: VersionedTransaction,
  computeUnitPrice: number,
  computeUnitLimit?: number
): void
tx
VersionedTransaction
required
Transaction to update
computeUnitPrice
number
required
Compute unit price in micro-lamports
computeUnitLimit
number
Optional compute unit limit
Location: src/utils/index.ts:136

TRON Utilities

initTronWeb

Initialize a TronWeb client instance.
initTronWeb(config: {
  privateKey: string;
  rpcUrl: string;
  apiKey?: string;
}): TronWeb
config
object
required
Configuration object
privateKey
string
required
TRON private key
rpcUrl
string
required
TRON RPC URL
apiKey
string
TronGrid API key (optional)
Location: src/utils/tron.ts:28

toTronHex41

Convert an address to TRON hex41 format.
toTronHex41(tronWeb: TronWeb, address: string): string
tronWeb
TronWeb
required
TronWeb instance
address
string
required
Address to convert (base58 or hex)
Location: src/utils/tron.ts:20

simulateTriggerContract

Simulate a TRON smart contract call.
simulateTriggerContract(
  tronWeb: TronWeb,
  params: {
    ownerAddress: string;
    contractAddress: string;
    callValue: number;
    data: string;
    label?: string;
  }
): Promise<{ ok: boolean; energyUsed?: number; error?: string }>
Location: src/utils/tron.ts:52

getTRC20Balance

Get TRC20 token balance.
getTRC20Balance(
  tronWeb: TronWeb,
  tokenAddress: string,
  ownerAddress: string
): Promise<number>
Location: src/utils/tron.ts:142

getTRC20Allowance

Get TRC20 token allowance.
getTRC20Allowance(
  tronWeb: TronWeb,
  tokenAddress: string,
  ownerAddress: string,
  spenderAddress: string
): Promise<bigint>
Location: src/utils/tron.ts:152

checkTronTransactionReceipt

Check if a TRON transaction broadcast was successful.
checkTronTransactionReceipt(receipt: any): {
  success: boolean;
  error?: string;
}
Location: src/utils/tron.ts:113

Environment & Provider Utilities

getEnvConfig

Load and validate environment variables.
getEnvConfig(): {
  privateKey: string;
  solPrivateKey: string;
  polygonRpcUrl: string;
  arbRpcUrl: string;
  bnbRpcUrl: string;
  baseRpcUrl: string;
  solRpcUrl: string;
  tronPrivateKey: string;
  tronRpcUrl: string;
  tronGridApiKey?: string;
  megaEthRpcUrl?: string;
}
Location: src/utils/index.ts:62

getJsonRpcProviders

Create JSON-RPC providers for multiple EVM chains.
getJsonRpcProviders(): Promise<{
  polygonProvider: JsonRpcProvider;
  arbitrumProvider: JsonRpcProvider;
  bnbProvider: JsonRpcProvider;
  baseProvider: JsonRpcProvider;
  megaEthProvider: JsonRpcProvider;
}>
Location: src/utils/index.ts:5

General Utilities

delay

Delay execution for a specified number of milliseconds.
delay(ms: number): Promise<void>
ms
number
required
Milliseconds to wait
Location: src/utils/index.ts:153 Example:
console.log("Waiting...");
await delay(3000);
console.log("Done!");

clipHexPrefix

Remove “0x” prefix from a hex string if present.
clipHexPrefix(hex: string): string
Location: src/utils/tron.ts:4

hexToUtf8

Convert a hex string to UTF-8 (useful for error messages).
hexToUtf8(hex?: string): string
Location: src/utils/tron.ts:9

Build docs developers (and LLMs) love