KIP17

KIP17

A warpping class that connects KIP17 API.

Constructor

new KIP17(client, accessOptions)

Creates an instance of KIP17 api.

Parameters:
Name Type Description
client ApiClient

The Api client to use to connect with KAS.

accessOptions AccessOptions

An instance of AccessOptions including chainId, accessKeyId and secretAccessKey.

Members

auth :string

Type:
  • string

accessKeyId :string

Type:
  • string

secretAccessKey :string

Type:
  • string

chainId :string

Type:
  • string

accessOptions :AccessOptions

Type:

apiInstances :object

Type:
  • object

client :object

Type:
  • object

kip17Api :KIP17Api

Type:

Methods

deploy(name, symbol, alias, callbackopt) → {Kip17TransactionStatusResponse}

Deploy KIP-17 token contract with a Klatn account in KAS.
POST /v1/contract

Example
const ret = await caver.kas.kip17.deploy('Jasmine', 'JAS', 'jasmine-alias')
Parameters:
Name Type Attributes Description
name string

The name of KIP-17 token.

symbol string

The symbol of KIP-17 token.

alias string

The alias of KIP-17 token.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17TransactionStatusResponse

getContractList(queryOptionsopt, callbackopt) → {Kip17ContractListResponse}

Search the list of deployed KIP-17 contracts using the Klaytn account in KAS.
GET /v1/contract

Example
// without query parameter
const ret = await caver.kas.kip17.getContractList()

// with query parameter
const ret = await caver.kas.kip17.getContractList({ size: 1, cursor: 'eyJjc...' })
Parameters:
Name Type Attributes Description
queryOptions KIP17QueryOptions <optional>

Filters required when retrieving data. size, and cursor.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17ContractListResponse

getContract(addressOrAlias, callbackopt) → {Kip17ContractInfoResponse}

Retrieves KIP-17 contract information by either contract address or alias.
GET /v1/contract/{contract-address-or-alias}

Example
// with contract address
const ret = await caver.kas.kip17.getContract('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16')

// with contract alias
const ret = await caver.kas.kip17.getContract('jasmine-alias')
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17ContractInfoResponse

mint(addressOrAlias, to, tokenId, tokenURI, callbackopt) → {Kip17TransactionStatusResponse}

Mints a new token on the requested KIP-17 contract. The target contract can be requested by either contract address or alias.
POST /v1/contract/{contract-address-or-alias}/token

Example
// with contract address and token id in hex
const ret = await caver.kas.kip17.mint('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', '0x6650d7f9bfb13561a37b15707b486f103f3a15cd', '0x1', 'uri')

// with contract alias and token id in number
const ret = await caver.kas.kip17.mint('jasmine-alias', '0x6650d7f9bfb13561a37b15707b486f103f3a15cd', 1, 'uri string')
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

to string

The address of recipient EOA account for the newly minted token.

tokenId string | number

The token ID for the newly minted token. This cannot be overlapped with an existing ID.

tokenURI string

The token URI for the newly minted token.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17TransactionStatusResponse

getTokenList(addressOrAlias, queryOptionsopt, callbackopt) → {ListKip17TokensResponse}

Return all tokens minted from a particular KIP-17 contract.
GET /v1/contract/{contract-address-or-alias}/token

Example
// with contract address and without query parameter
const ret = await caver.kas.kip17.getTokenList('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16')

// with contract alias and query parameter
const ret = await caver.kas.kip17.getTokenList('jasmine-alias', { size: 1, cursor: 'eyJjc...' })
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

queryOptions KIP17QueryOptions <optional>

Filters required when retrieving data. size, and cursor.

callback function <optional>

The callback function to call.

Returns:
Type
ListKip17TokensResponse

getToken(addressOrAlias, tokenId, callbackopt) → {GetKip17TokenResponse}

Retrieves the requested token information of a parcitular KIP-17 contract.
GET /v1/contract/{contract-address-or-alias}/token/{token-id}

Example
// with contract address and token id in hex
const ret = await caver.kas.kip17.getToken('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', '0x1')

// with contract alias and token id in number
const ret = await caver.kas.kip17.getToken('jasmine-alias', 1)
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

tokenId string | number

The token ID to retreive.

callback function <optional>

The callback function to call.

Returns:
Type
GetKip17TokenResponse

transfer(addressOrAlias, sender, owner, to, tokenId, callbackopt) → {Kip17TransactionStatusResponse}

Transfers a token. If sender and owner are not the same, then sender must have been approved for this token transfer.
POST /v1/contract/{contract-address-or-alias}/token/{token-id}

Example
const sender = '0x6650d7f9bfb13561a37b15707b486f103f3a15cd'
const owner = '0x0c12a8f720f721cb3879217ee45709c2345c8446'
const to = '0x661e2075de14d267c0f141e917a76871d3b299ad'

// with contract address and token id in hex
const ret = await caver.kas.kip17.transfer('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', sender, owner, to, '0x1')

// with contract alias and token id in number
const ret = await caver.kas.kip17.transfer('jasmine-alias', sender, owner, to, 1)
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

sender string

The address of the account sending the transaction to transfer the token. The sender must be the owner of the token or have been approved by the owner for the token to be transfered.

owner string

The address of the account that owns the token.

to string

The address of account to receive tokens.

tokenId string | number

The token ID to transfer.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17TransactionStatusResponse

burn(addressOrAlias, from, tokenId, callbackopt) → {Kip17TransactionStatusResponse}

Burns a token. If from is not the owner or has been approved for this operation, then the transaction submitted from this API will be reverted.
DELETE /v1/contract/{contract-address-or-alias}/token/{token-id}

Example
const from = '0x661e2075de14d267c0f141e917a76871d3b299ad'

// with contract address and token id in hex
const ret = await caver.kas.kip17.burn('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', from, '0x1')

// with contract alias and token id in number
const ret = await caver.kas.kip17.burn('jasmine-alias', from, 1)
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

from string

The address of sender or owner. If the from that burns the token is not the owner, the sender that sends the transaction to burn the token must have been approved by the owner.

tokenId string | number

The token ID to burn.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17TransactionStatusResponse

approve(addressOrAlias, from, to, tokenId, callbackopt) → {Kip17TransactionStatusResponse}

Approves an EOA, to, to perform token operations on a particular token of a contract which from owns.
If from is not the owner, then the transaction submitted from this API will be reverted.
POST /v1/contract/{contract-address-or-alias}/approve/{token-id}

Example
const from = '0x0c12a8f720f721cb3879217ee45709c2345c8446'
const to = '0x661e2075de14d267c0f141e917a76871d3b299ad'

// with contract address and token id in hex
const ret = await caver.kas.kip17.approve('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', from, to, '0x1')

// with contract alias and token id in number
const ret = await caver.kas.kip17.approve('jasmine-alias', from, to, 1)
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

from string

The address of owner.

to string

The address of EOA to be approved.

tokenId string | number

The token ID to approve.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17TransactionStatusResponse

approveAll(addressOrAlias, from, to, approved, callbackopt) → {Kip17TransactionStatusResponse}

Approves an EOA, to, to perform token operations on all token of a contract which from owns.
POST /v1/contract/{contract-address-or-alias}/approveall

Example
const from = '0x0c12a8f720f721cb3879217ee45709c2345c8446'
const to = '0x661e2075de14d267c0f141e917a76871d3b299ad'

// with contract address
const ret = await caver.kas.kip17.approveAll('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', from, to, true)

// with contract alias
const ret = await caver.kas.kip17.approveAll('jasmine-alias', from, to, true)
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

from string

The address of owner.

to string

The address of EOA to be approved.

approved boolean

A boolean value to set; true for approval, false for revocation.

callback function <optional>

The callback function to call.

Returns:
Type
Kip17TransactionStatusResponse

getTokenListByOwner(addressOrAlias, owner, queryOptionsopt, callbackopt) → {GetOwnerKip17TokensResponse}

Lists all tokens of the same owner (owner-address) of a contract.
GET /v1/contract/{contract-address-or-alias}/owner/{owner-address}

Example
const owner = '0x0c12a8f720f721cb3879217ee45709c2345c8446'

// without query parameter
const ret = await caver.kas.kip17.getTokenListByOwner('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', owner)

// with query parameter
const ret = await caver.kas.kip17.getTokenListByOwner('jasmine-alias', owner, { size: 1, cursor: 'eyJjc...' })
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

owner string

The address of owner.

queryOptions KIP17QueryOptions <optional>

Filters required when retrieving data. size, and cursor.

callback function <optional>

The callback function to call.

Returns:
Type
GetOwnerKip17TokensResponse

getTransferHistory(addressOrAlias, tokenId, queryOptionsopt, callbackopt) → {GetKip17TokenHistoryResponse}

Lists token transfer histories starting from the time the requested token was minted, where each entry of the response items shows a transfer record.
GET /v1/contract/{contract-address-or-alias}/token/{token-id}/history

Example
// with token id in hex and without query parameter
const ret = await caver.kas.kip17.getContractList('0x9ad4163329aa90eaf52a27ac8f5e7981becebc16', '0x1')

// with token id in number and query parameter
const ret = await caver.kas.kip17.getContractList('jasmine-alias', 1, { size: 1, cursor: 'eyJjc...' })
Parameters:
Name Type Attributes Description
addressOrAlias string

The contract address (hexadecimal, starting with 0x) or alias.

tokenId string | number

The token ID to search transfer history.

queryOptions KIP17QueryOptions <optional>

Filters required when retrieving data. size, and cursor.

callback function <optional>

The callback function to call.

Returns:
Type
GetKip17TokenHistoryResponse