# 클립의 밸런스를 구하는 방법을 알고싶습니다

**URL:** <https://devforum.kaia.io/t/topic/1279>\
**Category:** Klip (아카이브)\
**Tags:** klaytn\
**Created:** [6월 11, 2021, 3:04오전 UTC](https://devforum.kaia.io/t/topic/1279 "2021-06-11T03:04:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hansol](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/hansol/32/978_2.png) [@hansol](https://devforum.kaia.io/u/hansol)\
**Post date:** [6월 11, 2021, 3:04오전 UTC](https://devforum.kaia.io/t/topic/1279/1 "2021-06-11T03:04:25Z")

</div>

klip의 auth를 통해서 klaytn\_address를 구했습니다.

이 klaytn\_address로 balance를 구하려면 어떻게 해야 하나요??

---

<div class="post-metadata">

**Author:** ![hansol](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/hansol/32/978_2.png) [@hansol](https://devforum.kaia.io/u/hansol)\
**Post date:** [6월 11, 2021, 8:32오전 UTC](https://devforum.kaia.io/t/topic/1279/2 "2021-06-11T08:32:35Z")

</div>

해결되었습니다.---------------------

---

<div class="post-metadata">

**Author:** ![colin.kim](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/colin.kim/32/55_2.png) [@colin.kim](https://devforum.kaia.io/u/colin.kim)\
**Post date:** [6월 15, 2021, 6:53오전 UTC](https://devforum.kaia.io/t/topic/1279/3 "2021-06-15T06:53:32Z")

</div>

해결되셨다니 다행이네요. 빠른 답변을 드리지 못해 죄송합니다.

해결하신 내용을 답변에 적어주시면 다른 분들도 비슷한 문제를 겪었을 때 도움이 될 수 있을 것 같습니다. 🙂

감사합니다.

---

<div class="post-metadata">

**Author:** ![hansol](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/hansol/32/978_2.png) [@hansol](https://devforum.kaia.io/u/hansol)\
**Post date:** [6월 15, 2021, 9:20오전 UTC](https://devforum.kaia.io/t/topic/1279/4 "2021-06-15T09:20:15Z")

</div>

Klaytn의 Balance를 조회 하는 법. (이 방법은 클레이튼 체인의 네이티브 토큰인 Klaytn만 조회 가능).

1. 클립 docs([https://docs.klipwallet.com/](https://docs.klipwallet.com/))를 참조하여, 본인의 앱에서 사용하기 가장 유리한 rest api or sdk를 선택함. (필자는 javascript sdk를 사용하였음.)

2. prepare.auth를 통해 request\_key를 받아옴.

3. 

pc의 경우 : QR코드를 이용하여 폰 =\> 웹 앱으로 request\_key를 포함하여 응답함.  
mobile의 경우 : 딥링크로 카카오톡에 접속하여 request\_key를 응답함. (현재, pc 웹앱만 개발중이므로, 모바일에 대한 설명이 미흡합니다.)

1. pc의 경우 : getResult(${request\_key}). 를 하여 klaytn\_address를 받아옴. 기억이 잘 안나는데, 결과를 주기적으로 폴링하다가, status가 completed가 되었을 때의 klaytn\_address를 받아와야 함.

2. pc(javascript)의 경우 : caver-js의 default 객체인 Caver를 이용, new 문법으로 객체를 생성함.([caver.klay - Klaytn Docs KO](https://ko.docs.klaytn.com/bapp/sdk/caver-js/v1.4.1/api-references/caver.klay))

3. caver.klay.getBalance 메소드에 klip으로 구한 klaytn\_address를 파라미터로 집어넣어 balance를 구함.

예 )

```auto
let klaytn_address = null;
try {
    const { request_key } = await prepare.auth();
    // 이 request_key로 qrCode로 만들어서 촬영하게 함.
    const res = await getResult(request_key);
    if (res.status === 'completed') klaytn_address = res.data.klaytn_address;
} catch (e) throw e;

const caver = new Caver(rpcURI);
let balance = null;
try {
    balance = await caver.klay.getBalance(klaytn_address);
} catch (e) throw e;

!! balance !!

```

대충 이런 과정의 수도 코드 입니다. 중간에 address가 없거나, res가 없거나, balance가 없거나 하는 예외는 앱에 맞게 예외처리 하시면 됩니다.
