Biconomy Gasless SDK (EOA)
DashboardMediumWebsite
  • 🚀Getting Started
  • Introduction
    • 🤘Why Biconomy?
    • 🙂How we simplify transactions
  • Products
    • 💸Gasless Transactions
      • Choose An Approach to Enable Gasless
        • Standard EIP 2771 Approach
          • 1. Register Artifacts on the Dashboard
          • 2. Code Changes
            • Using SDK
            • Using API
        • Custom Implementation Approach
          • 1. Register Artifacts on the Dashboard
          • 2. Code Changes
            • Using SDK
            • Using API
        • Smart Contract Wallet Approach
          • Gnosis
        • Network Agnostic Transactions
          • EIP-2771 Approach
          • Custom Approach
      • Conditional Whitelisting
      • Gasless SDK (EOA) 3
      • Networks Supported
    • ↔️Hyphen - Instant Cross-Chain Transfers
      • SDK
        • DepositManager
        • TransferManager
        • TokenManager
      • APIs
      • Helper Methods
      • Migrating from Hyphen V1
      • Contract Addresses
      • Hyphen Widget
  • Guides
    • 💻Dashboard
      • DApp Statistics
    • ⛽Gas Tank Deposits
      • Via Dashboard
      • Via Smart Contract
  • api
    • 🔧Native Meta Transaction
      • Get Retried Hashes
    • 🌎Dashboard APIs
    • ⚪Whitelist API
      • Whitelist Destination Address
      • Whitelist Proxy Contracts
    • 〰️ Check Limits
    • 💿Biconomy Data API
      • 👨‍🚀Unique User Data
      • 🧑‍🔧Per User Limits Data
      • ⛽Gas Tank Balance Data
  • SDK
    • 📙Gasless SDK (EOA)
      • Configuration
  • Tutorials
    • 🔰Native Meta Transactions
      • How To Build Your First DApp
        • Write Your First Smart Contract
        • Initialize Web3 on Client Side
        • Executing First Blockchain Transaction
      • Enable Native Meta Transactions
        • Smart Contract
          • Describe Your Structs
          • Declare Your Variables
          • Modify Respective Function
        • Client Side
          • Design Your JSON structure
          • Design Your Domain Separator
          • Design Data Types
          • Define Data To Sign
          • Generate Signatures
      • Integrate Biconomy
        • Register On Dashboard
        • Integrate Gasless SDK (EOA)
      • Summary
  • BICO Staking
    • 🪁Safety Module
  • Get in touch
    • 👥Contact Us
  • Misc
    • 🧩Projects on Biconomy
    • 🌐Supported Networks
    • 📫Contract Addresses
    • ✔︎ Smart Contracts Audit
    • ❓FAQs
Powered by GitBook
On this page
  • Listen for Cross-Chain Transfer Transaction
  • Trigger Cross-Chain Transfer Manually

Was this helpful?

  1. Products
  2. Hyphen - Instant Cross-Chain Transfers

Helper Methods

Helper methods during cross-chain transfers

Listen for Cross-Chain Transfer Transaction

Once you have the deposit hash there are two ways of listening for cross-chain transfer transaction.

  1. One via SDK where you pass the callback method onFundsTransfered(data) in Hyphen constructor and let SDK call this method whenever a cross-chain transfer happens corresponding to the deposit transaction done by the user via SDK.

  2. Or you can call the SDK method checkDepositStatus({depositHash, fromChainId}) manually to check the status of cross-chain transfer for a given depositHash and fromChainId.

let hyphen = new Hyphen(provider, {
    // other options here
    onFundsTransfered: (data) => {
      /** 
        * data will contain following fields:
        * fromChainId  => Chain id from where funds were transferred
        * toChainId    => Chain id to where funds are transferred
        * amount       => Amount of tokens transferred in smallest unit of token
        * tokenAddress => Address of token that was trasnferred
        * depositHash  => Deposit transacion hash on fromChainId
        * exitHash     => Transfer transaction hash on toChainId
       **/
    }
});
import { RESPONSE_CODES } from "@biconomy/hyphen";
const EXIT_STATUS = {
	PROCESSING: 1,
	PROCESSED: 2,
	FAILED: 3
}

let depsitHash = "";
let fromChainId = 80001; 

// Assuming you already have the deposit transaction hash and the chain id
// where the transaction was done.

// Periodically call checkDepositStatus method unitll you get the response
const response = await hyphen.depositManager.checkDepositStatus({
                depositHash: depsitHash, 
                fromChainId: fromChainId
});
if(response && response.code === RESPONSE_CODES.SUCCESS) {
    if(response.statusCode === EXIT_STATUS.PROCESSED && response.exitHash) {
        // ✅ Cross-Chain transfer successfull
        /** 
        * response will contain following fields:
        * 
        * fromChainId  => Chain id from where funds were transferred
        * toChainId    => Chain id to where funds are transferred
        * amount       => Amount of tokens transferred in smallest unit of token
        * tokenAddress => Address of token that was trasnferred
        * depositHash  => Deposit transacion hash on fromChainId
        * exitHash     => Transfer transaction hash on toChainId
       **/
    } else if(response.statusCode === EXIT_STATUS.PROCESSING && response.exitHash) {
        // Cross-chain transfer is initiated but transaction is not confirmed yet
        /** 
        * response will contain following fields:
        * 
        * fromChainId  => Chain id from where funds were transferred
        * toChainId    => Chain id to where funds are transferred
        * amount       => Amount of tokens transferred in smallest unit of token
        * tokenAddress => Address of token that was trasnferred
        * depositHash  => Deposit transacion hash on fromChainId
        * exitHash     => Transfer transaction hash on toChainId
       **/
    }
}


Trigger Cross-Chain Transfer Manually

In case you don't get the transfer transaction hash on the destination chain within 5 minutes and you are not getting the success response from checkDepositStatus method also, you can manually trigger the cross-chain transfer by calling triggerManualTransfer method.

// Assuming you already have the deposit transaction hash on fromChain
let depsitHash = "0x.....";
let fromChainId = "137"; 

let transferStatus = await hyphen.transfer.triggerManualTransfer(depsitHash, fromChainId);

if(transferStatus && transferStatus.code === 200 && transferStatus.exitHash) {
    // Successfuly got the transfer transaction hash on toChain
    // transferStatus will contain following fields
    /*
     *   "code": Status code. 200 for success else failure.
     *   "message": Human readable response message.
     *   "exitHash": transaction hash for trasnfer transaction on toChain
    **/
}

PreviousAPIsNextMigrating from Hyphen V1

Last updated 3 years ago

Was this helpful?

↔️