Processing Bridge IDRX Request

The typical flow to process bridge requests from your user

To bridge IDRX, first execute a burnBridge transaction on the source blockchain. Then, use the resulting transaction hash as the value for the txHashBurn parameter in the POST /api/transaction/bridge-request endpoint.

Here’s an example code snippet to perform a burnBridge transaction. In this example, we will bridge IDRX from the Polygon network to BSC network.

Check this page to see the list of chains where IDRX is available

  • The balance will be processed and credited to destinationWalletAddress max 24 hours after your request is submitted.

  • The minimum transaction is 20,000 IDR.

  • IDRX is not responsible if an error occurs due to an incorrect wallet address.

import * as sha256 from 'sha256';
const { ethers } = require("ethers");
const idrxAbi = [{"inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "_user", "type": "address" } ], "name": "AddedBlackList", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "previousAdmin", "type": "address" }, {"indexed": false, "internalType": "address", "name": "newAdmin", "type": "address" } ], "name": "AdminChanged", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "owner", "type": "address" }, {"indexed": true, "internalType": "address", "name": "spender", "type": "address" }, {"indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Approval", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "beacon", "type": "address" } ], "name": "BeaconUpgraded", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "_user", "type": "address" }, {"indexed": false, "internalType": "uint256", "name": "_amount", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "amountAfterCut", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "toChain", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "_bridgeNonce", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "platformFee", "type": "uint256" } ], "name": "BurnBridge", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "_user", "type": "address" }, {"indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }, {"indexed": false, "internalType": "string", "name": "hashedAccountNumber", "type": "string" } ], "name": "BurnWithAccountNumber", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "_blackListedUser", "type": "address" }, {"indexed": false, "internalType": "uint256", "name": "_balance", "type": "uint256" } ], "name": "DestroyedBlackFunds", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" } ], "name": "Initialized", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "_user", "type": "address" }, {"indexed": false, "internalType": "uint256", "name": "_amount", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "amountAfterCut", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "fromChain", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "fromBridgeNonce", "type": "uint256" }, {"indexed": false, "internalType": "uint256", "name": "platformFee", "type": "uint256" } ], "name": "MintBridge", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "account", "type": "address" } ], "name": "Paused", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "_platformFeeRecipient", "type": "address" }, {"indexed": false, "internalType": "uint64", "name": "_burnBridgeFee", "type": "uint64" }, {"indexed": false, "internalType": "uint64", "name": "_mintBridgeFee", "type": "uint64" } ], "name": "PlatformFeeInfoUpdated", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "_user", "type": "address" } ], "name": "RemovedBlackList", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, {"indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, {"indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" } ], "name": "RoleAdminChanged", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, {"indexed": true, "internalType": "address", "name": "account", "type": "address" }, {"indexed": true, "internalType": "address", "name": "sender", "type": "address" } ], "name": "RoleGranted", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, {"indexed": true, "internalType": "address", "name": "account", "type": "address" }, {"indexed": true, "internalType": "address", "name": "sender", "type": "address" } ], "name": "RoleRevoked", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "from", "type": "address" }, {"indexed": true, "internalType": "address", "name": "to", "type": "address" }, {"indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "account", "type": "address" } ], "name": "Unpaused", "type": "event" }, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "implementation", "type": "address" } ], "name": "Upgraded", "type": "event" }, {"inputs": [], "name": "BLACKLIST_ROLE", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "DEFAULT_ADMIN_ROLE", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "MINTER_ROLE", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "PAUSER_ROLE", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "PLATFORM_FEE_SETTER_ROLE", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "UPGRADER_ROLE", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "", "type": "address" } ], "name": "_balances", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "_bridgeNonce", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "_totalSupply", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "_evilUser", "type": "address" } ], "name": "addBlackList", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "owner", "type": "address" }, {"internalType": "address", "name": "spender", "type": "address" } ], "name": "allowance", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "spender", "type": "address" }, {"internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "approve", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "account", "type": "address" } ], "name": "balanceOf", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "burn", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "uint256", "name": "amount", "type": "uint256" }, {"internalType": "uint256", "name": "toChain", "type": "uint256" } ], "name": "burnBridge", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "account", "type": "address" }, {"internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "burnFrom", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "uint256", "name": "amount", "type": "uint256" }, {"internalType": "string", "name": "accountNumber", "type": "string" } ], "name": "burnWithAccountNumber", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [], "name": "decimals", "outputs": [{"internalType": "uint8", "name": "", "type": "uint8" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "spender", "type": "address" }, {"internalType": "uint256", "name": "subtractedValue", "type": "uint256" } ], "name": "decreaseAllowance", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "_blackListedUser", "type": "address" } ], "name": "destroyBlackFunds", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "uint256", "name": "", "type": "uint256" }, {"internalType": "uint256", "name": "", "type": "uint256" } ], "name": "fromChainNonceUsed", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "_maker", "type": "address" } ], "name": "getBlackListStatus", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "getPlatformFeeInfo", "outputs": [{"internalType": "address", "name": "", "type": "address" }, {"internalType": "uint64", "name": "", "type": "uint64" }, {"internalType": "uint64", "name": "", "type": "uint64" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32" } ], "name": "getRoleAdmin", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32" }, {"internalType": "address", "name": "account", "type": "address" } ], "name": "grantRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32" }, {"internalType": "address", "name": "account", "type": "address" } ], "name": "hasRole", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "spender", "type": "address" }, {"internalType": "uint256", "name": "addedValue", "type": "uint256" } ], "name": "increaseAllowance", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "", "type": "address" } ], "name": "isBlackListed", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "maxPlatformFee", "outputs": [{"internalType": "uint64", "name": "", "type": "uint64" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "to", "type": "address" }, {"internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "mint", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "to", "type": "address" }, {"internalType": "uint256", "name": "amount", "type": "uint256" }, {"internalType": "uint256", "name": "fromChain", "type": "uint256" }, {"internalType": "uint256", "name": "fromChainBridgeNonce", "type": "uint256" } ], "name": "mintBridge", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [], "name": "name", "outputs": [{"internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [], "name": "paused", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "proxiableUUID", "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "_clearedUser", "type": "address" } ], "name": "removeBlackList", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32" }, {"internalType": "address", "name": "account", "type": "address" } ], "name": "renounceRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32" }, {"internalType": "address", "name": "account", "type": "address" } ], "name": "revokeRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "_platformFeeRecipient", "type": "address" }, {"internalType": "uint64", "name": "_burnBridgeFee", "type": "uint64" }, {"internalType": "uint64", "name": "_mintBridgeFee", "type": "uint64" } ], "name": "setPlatformFeeInfo", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "bytes4", "name": "interfaceId", "type": "bytes4" } ], "name": "supportsInterface", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "symbol", "outputs": [{"internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function" }, {"inputs": [], "name": "totalSupply", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, {"inputs": [{"internalType": "address", "name": "to", "type": "address" }, {"internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transfer", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "from", "type": "address" }, {"internalType": "address", "name": "to", "type": "address" }, {"internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transferFrom", "outputs": [{"internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "newImplementation", "type": "address" } ], "name": "upgradeTo", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, {"inputs": [{"internalType": "address", "name": "newImplementation", "type": "address" }, {"internalType": "bytes", "name": "data", "type": "bytes" } ], "name": "upgradeToAndCall", "outputs": [], "stateMutability": "payable", "type": "function" } ];

const ALCHEMY_POLYGON_NETWORK = "matic";
const ALCHEMY_API_KEY = "{ALCHEMY API KEY}";
const WALLET_PRIVATE_KEY = "{WALLET PRIVATE KEY}";
const IDRX_CONTRACT_ADDRESS = "0x649a2DA7B28E0D54c13D5eFf95d3A660652742cC";

const provider = new ethers.providers.AlchemyProvider(ALCHEMY_POLYGON_NETWORK, ALCHEMY_API_KEY);
const signer = new ethers.Wallet(WALLET_PRIVATE_KEY, provider);

async function burnBridge() {
    const amount = "21500"; // raw amount
    const destinationChainId = "56"; // destination chain id (BSC)

    const idrxContract = new ethers.Contract(IDRX_CONTRACT_ADDRESS, idrxAbi, provider);
    const idrxContractSigner = idrxContract.connect(signer);
    const tx = await idrxContractSigner.burnBridge(amount, destinationChainId);
    const txHash = tx.hash;

    console.log('txHash: ');
    console.log(txHash);
}

burnBridge();

After the burnBridge transaction is confirmed on the source blockchain, use the resulting transaction hash as the value for the txHashBurn parameter when making a bridge request.

import { createSignature } from "./createSignature";
const axios = require('axios');

const apiKey = "{API_KEY}";
const secret = "{API_SECRET}";

async function bridgeRequest() {
  const path = "https://idrx.co/api/transaction/bridge-request";

  const req = {
    "txHashBurn": "0x5d18bfc66cb345a03fcd1fab7c4edee12a065ab20b4ba5ebf005828116d62f8a",
    "bridgeToChainId": 56,
    "bridgeFromChainId": 137,
    "amount": "21500",
    "bridgeNonce": "26", // get this from the log of the burn transaction
    "destinationWalletAddress": "0x4313816F7Bfcff384053C70365eb6F3a4dbDD39f"
  };
  const bufferReq = Buffer.from(JSON.stringify(req), 'base64').toString('utf8');
  const timestamp = Math.round((new Date()).getTime()).toString();
  const sig = createSignature('POST', path, bufferReq, timestamp, secret);

  const res = await axios.post(path, req, {
    headers: {
      'Content-Type': 'application/json',
      'idrx-api-key': apiKey,
      'idrx-api-sig': sig,
      'idrx-api-ts' : timestamp,
    },
  });

  console.log('res.data: ');
  console.log(res.data);
}

bridgeRequest();


After a successful request, you will get a response as follows:

{
  "statusCode": 201,
  "message": "success",
  "data": {
    "id": 3,
    "userId": 1,
    "bridgeFromChainId": 137,
    "bridgeToChainId": 56,
    "txHashBurn": "0x5d18bfc66cb345a03fcd1fab7c4edee12a065ab20b4ba5ebf005828116d62f8a",
    "txHashMint": null,
    "qredoTxId": null,
    "signedTx": null,
    "bridgeNonce": "26",
    "amount": "21500",
    "bridgeStatus": "REQUESTED",
    "deleted": false
  }
}

To check the status of the transaction, you can use the Transaction History API. The bridge request will then be processed shortly after, and the IDRX will be sent to the destination wallet address.

Last updated