Send Platform Coin

1. Request.sendCoin

Parameters

NameTypeDescription

chainId

number

Chain ID of the particular network

appName

string

Name that will appear when sending platform coin in FAVORLE app

transactions

object array

Information required to transfer platform coins (see below for details)

transactions object contains

NameTypeDescription

from

string

Address to send platform coin

to

string

Address to receive platform coin

value

string

전송할 코인의 양 Amount of coin to send

Response

NameTypeDescription

requestId

string

ID to track the operation or transaction request

expiredAt

number

The amount of time (in seconds) that an operation or transaction request expires.

Example

import { Request } from "favorlet.js";

const response = await Request.sendCoin({
  chainId: 8217, // 해당 체인 id
  appName: "BlockChainApp", // FAVORLET 앱에 노출
  transactions: [
    {
      from: "0x{address in hex}", // 코인을 전송할 주소
      to: "0x{address in hex}", // 코인을 받을 주소
      value: "1000000000000000000", // 전송할 코인의 양
    },
  ],
});

console.log(response);
/*
{
  requestId: "56ba790c-aceb-465b-a6f2-33d103b25596",
  expiredAt: 1667891675
}
*/

Parameters

TypeDescription

string

requestId received when requesting

Response

TypeDescription

string

DeepLink to the request page in FAVORLET app

Example

import { createDeepLink } from "favorlet.js";

const deepLink = createDeepLink(response.requestId); // Request를 통해 받은 requestId

/*
- PC: 생성된 deepLink를 qrcode 라이브러리를 이용하여 QR 생성 후 스마트폰으로 스캔
- Mobile: window.location.href 등을 사용하여 생성된 deepLink로 직접 이동
*/
console.log(deepLink);
// https://app.favorlet.link/?requestId=56ba790c-aceb-465b-a6f2-33d103b25596

3. receipt

import { receipt } from "favorlet.js";

const result = await receipt(response.requestId); // Request를 통해 받은 requestId

console.log(result);
/*
- status에 따라 이후 분기 처리

### requested
{
  requestId: "56ba790c-aceb-465b-a6f2-33d103b25596",
  expiredAt: 1667891675,
  action: "sendCoin",
  transactions: [
    { status: "requested" }
  ]
}

### executed
{
  requestId: "56ba790c-aceb-465b-a6f2-33d103b25596",
  expiredAt: 1667891675,
  action: "sendCoin",
  transactions: [
    { status: "executed" }
  ]
}

### canceled
{
  requestId: "56ba790c-aceb-465b-a6f2-33d103b25596",
  expiredAt: 1667891675,
  action: "sendCoin",
  transactions: [
    { 
      status: "canceled",
      txHash: null,
      errorMessage: null
    }
  ]
}

### failed
{
  requestId: "56ba790c-aceb-465b-a6f2-33d103b25596",
  expiredAt: 1667891675,
  action: "sendCoin",
  transactions: [
    { 
      status: "failed",
      txHash: "0x5a4e16cfe0c21c3cd20456340b8614f585d951d9b931b515b11575d08142a6e2",
      errorMessage: "execution reverted : invalid id"
    }
  ]
}

### succeed
{
  requestId: "56ba790c-aceb-465b-a6f2-33d103b25596",
  expiredAt: 1667891675,
  action: "sendCoin",
  transactions: [
    { 
      status: "succeed",
      txHash: "0x5a4e16cfe0c21c3cd20456340b8614f585d951d9b931b515b11575d08142a6e2",
      errorMessage: null
    }
  ]
}
*/

Last updated