Card Minting
This tutorial is a guide to help Klip Partners mint and manage Cards conveniently using APIs.
1. Klip Partners
1-1. Request Membership and Approval
In order to start minting Cards, you first have to join Klip Partners. Upon requesting membership, you will receive an approval after an individual consultation with the Klip staff. When you receive the approval, you will get a confirmation email and will be eligible to log in to Klip Partners. For more details on membership, please visit Klip Partners. If you need help with this document or with Klip in general, please visit our Developer Forum.
1-2. Sign In
Pass your ID(email
) and password to Klip Partners via Sign In.
password
is a 64-digit string and a hash(SHA256) of the password.Password is a string consisting of 8-16 alphabet characters, numbers, and special characters.
If the request is successful, it returns the following:
When you sign up for Klip Partners, an EOA address and a smart contract is created on the Klaytn blockchain from which you can mint Cards. klaytn_address
is your EOA address created in the Klaytn blockchain, and contract_address
is the (SCA) from which you can mint Cards.
You will receive a JWT authentication token(access_token
) which is valid for 24 hours. This token will expire after 24 hours, in which case you have to obtain a new token.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
2. Mint Cards
2-1. Upload Card Image
Card image is what will be visible to Klip users. In order to start minting Cards, you have to upload Card image. Pass the Card image file and the access_token
you received when signing in to Klip Partners via Upload Image and request image upload.
To mint Cards using Mint Card To user, you first have to upload Card images using Upload Image API
If the request is successful, it returns the following:
If the image file is successfully uploaded, it returns the URL address of the uploaded image file.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
2-2. Mint Card to EOA
Pass the mint_info.json
file, and the access_token
you received when signing in to Klip Partners via Mint Card To user. It uses the uploaded Card image. Any user with an EOA can receive the Cards.
An example of a mint_info.json
file is shown below. This file contains the URL of the Card image and the information necessary to mint Cards.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.PIN Code is a 6-digit string.
If
sendable
TRUE, the recipient of the Card can send that Card to another user on Klip.If
send_friend_only
is TRUE, the recipient of the Card can send that Card to only his or her KakaoTalk friends on Klip.The maximum number of elements in the array
hashtags
is 10. The maximum number of characters for each element is 100.If you set
external_link
, you can include a URL address that redirects to an external browser outside of Klip. The maximum number of characters is 255.We recommend the
qr_code
image to be at least 400px in width and without margins in any direction.We recommend the
bar_code
image to be at least 400px in width and without margins in any direction.attributes
is an array ofobject
s containing the properties of the Cards in the formtrait_type/value
.
If the request is successful, it returns the following:
If the Card is minted successfully, it returns the the transaction hash of the smart contract. You can track the transaction by entering the hash in Klaytnscope to confirm that the transaction has been executed successfully.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
2-3. Mint Card to Klip Member
Pass the mint_info.json
file, and the access_token
that you received when signing in to Klip Partners via Mint Card To Klip Member and send a request to mint Card. Sends Cards only to a Klip Member identified by name and phone number.
An example of the mint_info.json
file is shown below. This file contains the URL of the Card image and the information necessary to mint Cards.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.PIN Code is a 6-digit string.
to_person
is a 2-dimensional array containing the users[Real Name, Phone Number] that will receive the Cards.If you pass an array with just one element to
to_person
, it is be sent to just one user.The maximum number of the element [Real Name, Phone Number] that can be included in
to_person
is 200 per API request.If there is not a Klip user with the corresponding Real Name and Phone Number passed to the
to_person
parameter, minting will fail.
If
sendable
TRUE, the recipient of the Card can send that Card to another user on Klip.If
send_friend_only
is TRUE, the recipient of the Card can send that Card to only his or her KakaoTalk friends on Klip.The maximum number of elements in the array
hashtags
is 10. The maximum number of characters for each element is 100.If you set
external_link
, you can include a URL address that redirects to an external browser outside of Klip. The maximum number of characters is 255.We recommend the
qr_code
image to be at least 400px in width and without margins in any direction.We recommend the
bar_code
image to be at least 400px in width and without margins in any direction.attributes
is an array ofobject
s containing the properties of the Cards in the formtrait_type/value
.
If the request is successful, it returns the following:
If the Card is minted successfully, it returns the the transaction hash of the smart contract and the result. If at least one user from the array in to_person
received the Card, the request is regarded as successful.
From the result above, the user "Alice" has a Membership record with the corresponding Real Name and Phone Number, so she receives the Card. From the result above, the user "Brian" does not have a Membership record with the corresponding Real Name and Phone Number, so he doesn't receive the Card.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
2-4. Upload Card Video Clip
If you want to use the animation_url
field when minting Cards, you first have to upload the file of the Card video clip. Pass the file of the clip and the access_token
that you received when signing in Klip Partners via Upload NFT Resource and request Card Video Clip Upload.
If the request is successful, it returns the following:
If the file is uploaded, it returns the URL of the uploaded file.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
3. Get Card Information
3-1. Get Card Information by BApp
After you minted a Card, you can retrieve the Card's information along with the BApp information. Pass the access_token
that you received when siging in to Get Card Information by BApp and make the request.
If the request is successful, it returns the following:
If the request is successful, it returns a list of all the BApps and the Cards by BApp.
bapp from
bapps
refers to a BApp provided by a Klip Partner.card from
cards
refers to Klip Card used in this BApp. BApp contains one type of Card.nft_id
refers to the ID of the smart contract from which this card.nft and bapp always corresponds 1:1.
card_uri
is the URL containing the JSON file of the Card's metadata.Card metadata contains the basic information of the Card such as
name
,description
,image
,background_color
,attributes
defined when minting the Card.
You can get a maximum of 100 elements of BApp information from a single request. If there are over 100 BApps to query, the result will return bapps.next_cursor
, with which you can retrieve the rest of the BApps.
To retrieve the rest of the BApps, set the cursor
parameter with bapps.next_cursor
and make another request to the same endpoint.
The maximum number of Cards returned for a BApp in a single request is 100. If the number of Cards of a BApp exceeds 100, you can retrieve the rest of the Cards using Get Card Information.
From the API response above, you can see that the minter uses 2 BApps. The first BApp has three Cards, and the second BApp has one Card. The bapps[0].cards
array shows you the information including when the Card was created/updated, the address of the Card owner, the address of the Card sender, and the hash of the transaction that minted the Card.
If the number of BApps to query exceeds 100, the reponse will only contain 100 BApps per request along with the bapps.next_cursor
.
To retrieve the rest of the BApps, set the cursor
parameter with bapps.next_cursor
and make another request to the same endpoint.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
3-2. Get Card Information
Each BApp has an nft_id
, which is the ID of the smart contract from which the Cards are minted. Pass the path parameter nft_id
and the access_token
which you received when signing up to Klip Partners via Get Card Information.
If the request is successful, it returns the following:
If the request is successful, it returns the list of Cards owned by the BApp and their detailed information.
card from
cards
refers to Klip Card used in this BApp. BApp contains one type of Card.You must use either
cursor
orisAll
as query parameter (You can usecursor
ifisAll
isfalse
).If you use
cursor
, Pagination will be used.You can receive information of 100 Cards per one request.
If the number of Cards to query exceeds 100, you can retrieve the rest of the Cardi information using
next_cursor
, which is the pointer from which to return the next 100 objects.To retrive the rest of the Card information, set the
cursor
parameter withnext_cursor
and make another request to the same endpoint.
nft_id
can be found via Get Card Information by BApp.
From the example above, since the field cards.next_cursor
has a value, this account has over 100 conan Cards.
If the number of Cards to query exceeds 100, the reponse will only contain 100 Cards per request along with the cards.next_cursor
. To retrieve the rest of the Card information, set the cursor
parameter with cards.next_cursor
and make another request to the same endpoint.
For example, if there are a total of 150 Cards from which to retrieve information, the request will return the information of 100 Cards and the cards.next_cursor
.
You can retrieve the information of the remaining 50 Cards, by setting the cursor
parameter with the cards.next_cursor
from the previous step and make another request to the same endpoint.
If the request is not successful, it returns the following:
Pass cards.next_cursor
and the access_token
that you received when signing in to Klip Partners via Get Card Information and send a request to retrieve the rest of the Cards.
If the request is successful, it returns the following:
The details of the cards
array is the same as that of bapps[i].cards
from Get Card Information by BApp.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
3-3. Retrieving the remaining Cards when total Card number exceeds 100
Get Card Information By BApp will return the information of up to 100 Cards per request. If the number of Cards by of a BApp exceeds 100, you have to send a request to Get Card Information to retrieve the rest of the Cards. To make a query from the 101st Card, set the cursor
parameter with bapps[i].cards_next_cursor
and send a request to Get Card Information.
For example, say you have 2 BApps. BApp1 has 150 Cards, and BApp2 has 200 Cards. If you send a request to Get Card Information By BApp, you will get information of 100 Cards for both BApp1 and BApp2. Pass the access_token
that you received when signing in and Get Card Information By BApp and make the request.
If the request is successful, it returns the following:
If the request is not successful, it returns the following:
To retrieve the information for the rest of the Cards in BApp1, set the cursor
parameter with bapps[0].cards_next_cursor
(gKvkL1lPYv1P93dpE...
) and send a request to Get Card Information.
Pass gKvkL1lPYv1P93dpE...
and the access_token
that you received while signing up to Klip Partners via Get Card Information and send a request to retrieve information for the rest of the 50 Cards in BApp1.
If the request is successful, it returns the following:
If the request is not successful, it returns the following:
To retrieve the information of the remaining 100 Cards in BApp2, set the cursor
parameter with bapps[1].cards_next_cursor
(Xrzed2Ot9LeEor...
) and send a request to Get Card Information. Pass Xrzed2Ot9LeEor...
and the access_token
that you received when signing in to Klip Partners via Get Card Information and send a request to retrieve the information of the remaining 100 Cards in BApp2.
If the request is successful, it returns the following:
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
3-4. Get all Cards
To get the information of all Cards at once instead of using pagination to get 100 Cards per request, send the Query parameter isAll
, the Path parameter nft_id
and the access_token
that you received when signing in to [Klip Partners](https://partners.klipwallet.com via Get Card Information and send a request for all Cards.
If the request is successful, it returns the following:
If your request is successful, i will return a list of all Cards used in this BApp and their information.
You must use either
cursor
orisAll
as query parameter (You can usecursor
ifisAll
isfalse
).
The details of the cards
array is the same as that of bapps[i].cards
in Get Card Information by BApp.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
4. Send Card
4-1. Send to EOA
Pass the access_token
that you received when signing in, the send_info.json
file, nft_id
and card_id
(Path Parameters) of the BApp Cards to send to Klip Partners via Send Card To user, and send a request to send the Card held by the current EOA address to another EOA address.
Any user with an EOA can receive Cards.
An example of a send_info.json
file is shown below:
This file contains the Card name, pin
, and the recipient's EOA address.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.PIN Code is a 6-digit string.
If the request is successful, it returns the following:
If the request is successful, it returns the the Card recipient's EOA address, the number of failed attemps, and the hash of the transaction that sent the Card. If the Card is successfully sent, fail_count
returns 0.
When a Card is sent, the Klip user recipient receives a notification. The sender does not get any notification. You have to include card_name
so that the Card name appears for the recipient.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
4-2. Send to Klip Member
Pass the access_token
that you received when signing in, and the send_info.json
file, the nft_id
and card_id
(Path Parameter) of the BApp Card to Klip Partners via Send Card To Klip Member and send a request to send the Card currently held by the EOA address to another user.
Sends Cards only to a Klip Member identified by name and phone number.
An example of a send_info.json
file looks like this:
This file contains the card name, pin
, and the name and phone number of the Card receiver used when signing up for Klip.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.PIN Code is a 6-digit string.
If the Klip Member with the corresponding name and phone number passed to the
to_person
parameter doesn't exist, the send request will fail.
If the send request is successful, it returns the following:
If the send request is successful, fail_count
will return 0.
When a Card is sent, the Klip user recipient receives a notification. The sender does not get any notification. You have to include card_name
so that the Card name appears for the recipient.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
5. Escrow
5-1. Approve Escrow
In order to use escrow, you first have to enable escrow in the Card minting contract. You do this by using Approve Escrow. You only need to give your approval only once.
An example of the approve.json
is shown below:
This file contains pin
, and the contract_address
, which is the address of the smart contract(SCA) that minted the Card.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.
If the request is successful, it returns the following:
If the escrow is successfully initiated, it returns the transaction hash. If the pin
could not be verified, fail_count
returns a number higher than 0.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
5-2. Get Escrow Approval Status
You can find out whether escrow is enabled or not.
If the request is successful, it returns the following:
If the escrow is successfully initiated, the approve
field returns true
.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
5-3. Creat Escrow
Escrow allows you to send a Card through a link, instead of directly sending it to a Klip Member. In order to use escrow, you first have to send a request to the Create Escrow API to generate a link through which Klip user can receive the Card. You can initiate escrow process for Cards that you hold. Once the escrow process is initiated, the Card will no longer be visible from the Card list.
An example of the escrow_info.json
file is shown below:
This file contains pin
, and the contract_address
, which is the address of the smart contract(SCA) that minted the Card, and the array card_ids
, which will be sent using escrow.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.
If the request is successful, it returns the following:
If the escrow process is successfully initiated, it returns the transaction hash, the link through which to receive the Card,and the fail_count
reading 0.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
5-4. Get Cards in Escrow
If the escrow process is initiated successfully, you can retrieve the Cards that are currently in escrow.
If the request is successful, it returns the following:
For details on the cards
array, please refer to the Response Detail in Get Cards in Escrow.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
5-5. Cancel Escrow
You can the escrow process for Cards that are in escrow. Once cancelled, the Cards become visible in the Card list again.
An example of the cancel_info.json
file is shown below:
This file contains pin
, the contract_address
, which is the address of the smart contract(SCA) that minted the Card, and the array card_ids
, which are Cards for which the escrow process will be cancelled.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.
If the request is successful, it returns the following:
If the escrow process is successfully initiated, it returns the transaction hash with fail_count
reading 0.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
6. Transaction
6-1. Get Transaction Result
You can find out whether the transaction has been successfully recorded on blockchain. If you attempt to retrieve the result right after sending a transaction request, it may return 4700: no transaction receipt
. It is recommended to wait at least 2 seconds and repeat the request until it succeeds.
If the request is successful, it returns the following:
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
7. Manage Account
7-1. Change Password and PIN
Send old_password
, new_password
and the access_token
that you received when signing in to Klip Partners via Change Passwordand send a request to change password.
old_password
andnew_password
are 64-digit strings and hash(SHA256) of the old/new passwords.Password is a string consisting of 8-16 alphabet characters, numbers, and special characters.
If the request is successful, it returns the following:
If there is no error, the password should have changed successfully.
If the request is not successful, it returns the following:
Pass the old PIN, new PIN, and the access_token
that you received when signing in to Klip Partners via Change PIN and send a request to change PIN.
old_pin
andnew_pin
are 64-digit strings and hash(SHA256) of the old/new PIN.old_pin
andnew_pin
are used in place of the private key to sign transactions.The old/new PIN are a 6-digit string of numbers.
If the request is successful, it returns the following:
If there is no error, your PIN should have changed successfully.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
7-2. Get Mint Count
You can find out the total number of Cards minted using a Partner account. The count is renewed on the 1st day of each month.
If the request is successful, it returns the following:
mint_count
returns the total number of Cards minted.
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
7-3. Delete Card
Pass the delete_info.json
file, the access_token
that you received when signing in to Klip Partners via Delete Card and send a request to delete the Card.
An example of the delete_info.json
file is shown below:
This file contains the ID of the Card to delete, the SCA address of the contract that minted the Card, and the PIN.
pin
is a 64-digit string and hash(SHA256) of the PIN Code(The 6-digit string that you entered when signing up for Klip Partners).pin
is used in place of the private key to sign transactions.
If the request is successful, it returns the following:
If there is no error, the Card should have been deleted successfully. With successful deletion, it returns the transaction hash.
You can't delete Cards already sent to others. Deleting a Card will not delete the Card image.
If the request is not successful, it returns the following:
If you need help with this document or with Klip in general, please visit our [Developer Forum](https://forum.klaytn.com/c/klip-api/28).
Last updated