App2App
This page explains how to use App2App REST API to integrate Klip to your BApp.
※ Introduction
There are three steps involved in using App2App API: Prepare, Request, and Result.
Do not impersonate "GroundX" when using Klip API.
Only you are responsible for any consequences arising from using Klip API. GroundX is not responsible for its users or third parties.
Your account may be blocked without prior notice in case of any illegal or abnormal use of Klip API, such as creating unsually high traffic.
Prepare
This step involves selecting the actions you would like to enable for your BApp. All the actions except for "Authentication" require sending a transaction to the Klaytn network. You therefore have to create a transaction object for these steps. The actions are as follows:
Authentication
Sending KLAY
Sending Tokens
Sending Cards
Executing Smart Contract
Authentication
This is a process to access a BApp user's Klip wallet. It is used to obtain a Klip user's EOA in a BApp. You should comply with the button style guide below when providing a button to enable this feature.
Klip Log-In Button Guide
Klip App2App Button Template Download
When enabling this feature, you must include a way to disconnect Klip Account, and when doing so must immediately delete all collected EOA data.
Nonadherence to this policy may result in the blocking of APIs without prior notice.
Sending KLAY
This step involves sending KLAY from a BApp Member's Klip Wallet to a Klaytn account address (EOA). A transaction object will be created.
Sending Tokens
This step involves sending FTs (Fungible Tokens) from a BApp Member's Klip Wallet to a Klaytn account address (EOA). A transaction object will be created.
Sending Cards
This step involves sending NFTs (Non-Fungible Tokens) from a BApp Member's Klip Wallet to a Klaytn account address (EOA). A transaction object will be created.
Executing Smart Contract
This step involves executing a smart contract using a Klip account. A transaction object will be created.
A successful Prepare API request will return a request key. Request key is used for the steps Request and Result, where the actions specified during the Prepare step will be requested for actual execution.
Request
The actions specified in the previous Prepare step will be executed.
All actions other than "Authentication", which is basically importing BApp Member's Klip Wallet Address (EOA) to the BApp, involve obtaining a signature for the transaction. The four actions "Sending Token", "Sending KLAY", "Sending Cards" and "Executing Smart Contract" require that transactions be sent to Klaytn. For this step, these transactions will be signed using Klaytn account keys and then be submitted to the Klaytn network.
Authentication or signature will be requested on Klip via deep link.
For example, when a BApp Member “A” clicks on the button to send tokens to another Member “B”, your BApp will use the App2App API to first authenticate “A”'s Klip Wallet address (can be ommitted) and access “A”'s Klip Wallet. It will then submit a transaction to send tokens or Cards to “B”'s Klaytn account address.
Result
Finally in the Result step, you will receive the result or response of the request from the previous step.
The API has two forms: whereas the Prepare and Result steps are RESTful APIs that send a request to the Klip Backend server, the Request step creates a deep link to use Klip. There is also a RESTful API request for retrieving Card information.
※ API Flow Diagram
The basic flow of an App2App process looks like this:
Aside from the API request, retrieving Card Information shares the same flow as other REST API requests. It sends a request to the backend to retrieve information, without involving Klip. This flow is demonstrated below:
Deep link is implemented via URL Scheme on iOS, and intentURI on Android. URL Scheme is a link that looks like the one below. When a BApp user clicks on it, Klip, located in the More[…] tab on KakaoTalk, will be launched. In the request_key
field, use the request key obtained in the Prepare step.
IntentURI for Android looks like this:
※ API Specification
Below is the specification for App2App API.
Prepare
POST
https://a2a-api.klipwallet.com/v2/a2a/prepare
Prepares to process an App2App API request and issues a request key.
Headers
Request Body
** bapp
Object Sample **
name
is the name of the BApp displayed on the Klip user's screen during authentication or transaction signing. The success
field under callback
is a deep link to return to the BApp once user validation on Klip is successful. fail
is a deep link to return to the BApp in case of failures. The callback
object is optional.
** transaction
Object Sample **
type:
send_klay
to
is the Klaytn address of the KLAY recipient. amount
is the amount of KLAY being sent. from
is the Klip user's address. from
is an optional field used to sort out unwanted requests through comparison with Klip users' actual address.
type:
send_token
contract
is the smart contract address of the token. to
is the Klaytn account address of the recipient. amount
is the amount of tokens to receive. amount
is converted automatically based on the decimals of the contract. For example, a KIP-7 contract (FT contract) has 18 decimals, so amount
1 would mean 10^18 tokens in its smallest denomination. from
is the Klip user's address. from
is an optional field used to sort out unwanted requests through comparison with Klip users' actual address.
type:
send_card
contract
is the smart contract address of the token. to
is the Klaytn account address of the Card recipient. card_id
is the identification number of the Card to be sent. from
is the Klip user's address. from
is an optional field used to sort out unwanted requests through comparison with Klip users' actual address.
type:
execute_contract
to
is the address of the smart contract to be executed. value
is the amoung of KLAY to be sent to that contract. The unit is peb. For example, 1 KLAY equals 1000000000000000000 pebs. abi
is the function data of the contract to be executed. params
refer to the parameter to be passed to the function. from
is the Klip user's address. from
is an optional field used to sort out unwanted requests through comparison with Klip user's actual address. More detailed explanations of abi
and params
can be found in the tutorial.
Although from
is optional, it is recommended to test that the Klip user is the actual intended user for the transaction.
Request Example
Response Details
status
can be one of the following: prepared
, requested
, completed
, canceled
, or error
. canceled
is set when the user intentionally cancels the App2App process.
Please refer to our Tutorial for more details. If you need help with this document or with Klip in general, please visit our Developer Forum.
Request
DEEP LINK
kakaotalk://klipwallet/open?url=https://klipwallet.com/?target=/a2a?request_key=
There are currently two ways to request authentication or signature on Klip: deep link and QR code. Specific request methods differ for each development environment. Deep link uses kakaotalk://
for iOS, and intent://
for Android. And QR code uses a URL of the form: https://
. Refer to the Request Example below for more details.
Query Parameters
Request Example
The request_key
field is set with the value obtained in the Prepare step.
iOS
Android
PC or Other Devices (QR Code)
QR code is generated as a URL as below. Users can process App2App requests by reading a QR code through Klip or the native camera app.
Refer to the following open source projects on creating QR codes:
JavaScript : https://www.npmjs.com/package/qrcode
Android : https://github.com/zxing/zxing
iOS : https://github.com/EFPrefix/EFQRCode
Result
GET
https://a2a-api.klipwallet.com/v2/a2a/result?request_key=
Returns the result of a specified App2App API request.
Query Parameters
Request Example
Response Details
type:
auth
status
can be one of the following: prepared
, requested
, completed
, canceled
, or error
. canceled
is set when the user intentionally cancels the App2App process.
type: Types other than
auth
If the status
field in the result
object reads pending
, it means that the transaction is still being processed on Klaytn. Normally, you would be able to see the request processed after a few seconds. success
means that the request was successful, and fail
means that it failed.
Please refer to our Tutorial for more details. If you need help with this document or with Klip in general, please visit our Developer Forum.
Get Card Information
GET
https://a2a-api.klipwallet.com/v2/a2a/cards?cursor=
Returns a list of Cards owned by a specified EOA, minted with a specified NFT contract.
Query Parameters
Request Example
Response Details
Response Details for cards[i]
Please refer to our Tutorial for more details. If you need help with this document or with Klip in general, please visit our Developer Forum.
Last updated