일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- SCN
- 클레이튼
- blockchain
- 프론트엔드
- 이더리움
- javascript
- Klaytn
- 웹
- Web
- 서비스체인
- frontend
- 블록체인
- 접근제어자
- kas
- web3
- Geth
- ethereum
- vue.js
- 솔리디티
- 프레임워크
- nodejs
- geth구현
- web3.js
- vue
- 블록체인 구조와 이론
- Klaytn API Service
- 제어자
- Solidity
- API
- 앵커링
- Today
- Total
BloCCat
KAS 사용하기 - 기본 세팅 본문
KAS를 사용하여 BAPP을 개발하기 앞서 모든 API가 그렇듯 해당 Document를 참고하여 개발을 한다.
KAS또한 Document가 굉장히 잘 정리되어 있고 개발자 포럼에도 직원들이 24시간 내에 빠르고 친절이 답해준다.
(기본적으로 BApp, DApp들은 주로 java와 java script를 지원하는데 이중 java script 언어에 대한 지원이 더 잘 돼있기 때문에 js 위주로 글을 작성한다.)
Introduction
이 페이지는 Klaytn API Service (KAS)를 소개합니다.
docs.klaytnapi.com
https://forum.klaytn.com/c/kas/25
KAS
This category is for questions related to Klaytn API Service (KAS). KAS is an API service for easier and quicker blockchain service development.
forum.klaytn.com
1. SDK 설치
$ npm install caver-js
$ npm install caver-js-ext-kas
2. apiCaller.js 작성
const request = require('request')
class ApiCaller {
constructor(_endpoint) {
this.endpoint = _endpoint;
}
async call(options){
options.url = this.endpoint + options.url;
options.json = true;
if(!options.headers) options.headers = {};
options.headers['x-chain-id'] = '1001';
options.headers['content-type'] = 'application/json';
options.headers.Authorization = ' '
return new Promise((resolve, reject) => {
request(options,function(error, _response, body){
if(error) reject(error);
else resolve(body);
})
})
}
}
module.exports = ApiCaller;
KAS에서 제공하는 API를 호출할때 header 부분에는 x-chain-id , content-type, Authorization이 있는데
이를 apiCaller에서 미리 정의해두고 사용하려는 api를 호출하는 파일들을 상속시켜 사용할 예정이다.
x-chain-id : 클레이튼 네트워크의 번호이며 메인 네트워크(Cypress)는 8217, 테스트 네트워크(Baobab)는 1001
Authorization : KAS Console에서 생성한 Authorization id 를 입력한다.
'Study > 클레이튼' 카테고리의 다른 글
SCN(Service Chain Network)에서 klay 송금 (0) | 2021.12.10 |
---|---|
SCN(Service Chain Network) 구축 (0) | 2021.12.10 |
KAS 사용하기 - 준비 (0) | 2021.09.24 |
클레이튼 네트워크 구성 (1) | 2021.09.24 |
클레이튼의 합의 알고리즘 : IBFT (0) | 2021.08.22 |