# 지갑 연결

## 1. Request.connectWallet <a href="#id-1.-request.connectwallet" id="id-1.-request.connectwallet"></a>

**Parameters**

<table><thead><tr><th width="183">이름</th><th width="178.33333333333331">타입</th><th>설명</th></tr></thead><tbody><tr><td>appName</td><td>string</td><td>지갑 연결 시 FAVORLET 앱에 노출될 이름</td></tr><tr><td>chainId</td><td>number</td><td>해당 네트워크의 체인 아이디 (optional)</td></tr></tbody></table>

**Response**

<table><thead><tr><th width="183">이름</th><th width="178.33333333333331">타입</th><th>설명</th></tr></thead><tbody><tr><td>requestId</td><td>string</td><td>작업 또는 트랜잭션 요청을 추적하기 위한 id</td></tr><tr><td>expiredAt</td><td>number</td><td>작업 또는 트랜잭션 요청이 만료 되는 시간(단위: 초)</td></tr></tbody></table>

**Example**

```javascript
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,
}
*/
```

### createDeepLink <a href="#id-2.-createdeeplink" id="id-2.-createdeeplink"></a>

**Parameters**

<table><thead><tr><th width="185">타입</th><th>설명</th></tr></thead><tbody><tr><td>string</td><td>Request 요청시 전달받은 requestId</td></tr></tbody></table>

**Response**

<table><thead><tr><th width="185">타입</th><th>설명</th></tr></thead><tbody><tr><td>string</td><td>FAVORLET 앱 내 해당 요청 페이지 DeepLink</td></tr></tbody></table>

**Example**

```javascript
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 <a href="#id-3.-receipt" id="id-3.-receipt"></a>

```javascript
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",
  chainId: "8217" //지갑에 연결된 chainId
  connectWallet: {
    status: "succeed",
    address: "0x817228A2B8BFbb73d504504696fD6E423b9D561B",
    errorMessage: null
  }
}
*/
```

## 2. Request.connectWalletAndSignMessage (>= v1.3.0) <a href="#id-1.-request.connectwallet" id="id-1.-request.connectwallet"></a>

지갑연결과 서명값을 1개의 qr코드 처리 방식으로 완료합니다.

#### Parameters

<table><thead><tr><th width="185">이름</th><th width="148">타입</th><th>설명</th></tr></thead><tbody><tr><td>appName</td><td>string</td><td>지갑 연결 시 FAVORLET 앱에 노출될 이름</td></tr><tr><td>chainId</td><td>number</td><td>해당 네트워크의 체인 아이디 (optional)</td></tr><tr><td>message</td><td>string</td><td>서명할 메세지</td></tr></tbody></table>

#### Response

<table><thead><tr><th width="185">이름</th><th width="151">타입</th><th>설명</th></tr></thead><tbody><tr><td>requestId</td><td>string</td><td>작업 또는 트랜잭션 요청을 추적하기 위한 id</td></tr><tr><td>expiredAt</td><td>number</td><td>작업 또는 트랜잭션 요청이 만료 되는 시간 (단위: 초)</td></tr></tbody></table>

```javascript
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,
}
*/
```

### createDeepLink <a href="#id-2.-createdeeplink" id="id-2.-createdeeplink"></a>

**Parameters**

<table><thead><tr><th width="185">타입</th><th>설명</th></tr></thead><tbody><tr><td>string</td><td>Request 요청시 전달받은 requestId</td></tr></tbody></table>

#### Response

<table><thead><tr><th width="185">타입</th><th>설명</th></tr></thead><tbody><tr><td>string</td><td>FAVORLET 앱 내 해당 요청 페이지 DeepLink</td></tr></tbody></table>

#### Example

```javascript
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 <a href="#id-3.-receipt" id="id-3.-receipt"></a>

```javascript
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"
  }
}
*/
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.favorlet.io/dev/app2app/connect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
