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
       **/
    }
});

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.

Last updated

Was this helpful?