Connect Wallet

1. Request.connectWallet

Parameters

Name
Type
Description

chainId

number

Chain ID of the particular network

appName

string

Name of the FAVORLET app that will appear when the wallet is connected

Response

Name
Type
Description

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.connectWallet({
  chainId: 8217, // 해당 체인 id
  appName: "BlockChainApp" // FAVORLET 앱에 노출
});

console.log(response);
/*
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
}
*/

Parameters

Type
Description

string

Request ID received upon making the request

Response

Type
Description

string

DeepLink to the specific request page within the 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=635b7750-5de2-48eb-9a6c-fba8763f7484

3. receipt

import { receipt } from "favorlet.js";

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

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

### requested
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
  action: "connectWallet",
  connectWallet: {
    status: "requested"
  }
}

### canceled
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
  action: "connectWallet",
  connectWallet: {
    status: "canceled",
    address: null,
    errorMessage: null
  }
}

### succeed
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
  action: "connectWallet",
  connectWallet: {
    status: "succeed",
    address: "0x817228A2B8BFbb73d504504696fD6E423b9D561B",
    errorMessage: null
  }
}
*/

2. Request.connectWalletAndSignMessage (>= v1.3.0)

It completes the wallet connection and signature verification with a single QR code process.

Parameters

Name
Type
Description

chainId

number

Chain ID of the particular network (optional)

appName

string

Name of the FAVORLET app that will appear when the wallet is connected

message

string

Signature Message

Response

Name
Type
Description

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.

import { Request } from "favorlet.js";

const response = await Request.connectWalletAndSignMessage({
  chainId: 8217, // 해당 체인 id
  appName: "BlockChainApp" // FAVORLET 앱에 노출
  message: "sign message" // 서명할 메세지
});

console.log(response);
/*
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
}
*/

Parameters

Type
Description

string

Request ID received upon making the request

Response

Type
Description

string

DeepLink to the specific request page within the 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=635b7750-5de2-48eb-9a6c-fba8763f7484

receipt

import { receipt } from "favorlet.js";

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

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

### requested
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
  action: "connectWalletAndSignMessage",
  connectWalletAndSignMessage: {
    status: "requested"
  }
}

### canceled
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
  action: "connectWalletAndSignMessage",
  connectWalletAndSignMessage: {
    status: "canceled",
    address: null,
    signature: null,
    errorMessage: null
  }
}

### succeed
{
  requestId: "635b7750-5de2-48eb-9a6c-fba8763f7484",
  expiredAt: 1667890657,
  action: "connectWalletAndSignMessage",
  connectWalletAndSignMessage: {
    "status": "succeed",
    "address": "0x123...123”,
    "signature": "0xasdkasldjwqevnwrejkqwkeqlwkejq"
  }
}
*/

Last updated