Skip to content

Transfer wallet frontend integration

Communication with iframe

The client should implement the handle mechanism of the next iframe message by dataType for correct interaction between the client’s platform and iFrame. Example below:

window.addEventListener("message", () => {
  if (data.type === "user.balance_transfer") {
    // this message is being posted when user clicks on Deposit/Withdrawal button in iframe. This action needed to handle transaction request.
  }
});

The event of clicking on Deposit/Withdrawal in iframe is processed on the client's website using postMessage from iframe with type type: "user.balance_transfer" and field value, which contains the type and amount of the transaction:

The post message example below:

{
  type: "user.balance_transfer",
  value: { 
    type: 0,
    amount: 10,
  },
},

After which need to send a request with the POST method to perform the transaction https://${transferBalanceHost}/v1/transfer-wallet/transactions.

The request body must contain the value received from the postMessage from the Iframe.

From the client site - use post message to send command to Iframe to notify about transaction complete.

It is the operator's responsibility to send us a “balanceTransferSuccess” postMessage (example below).

Post message example:
window.frames.target.postMessage(
  {
    type: "iframe",
    value: { balanceTransferSuccess: `${status}` },
  },
  "*"
); // where * should be replaced with iframe domain

${status} - true or false, depending on the status of the response transaction request