caver.kct.kip17
caver.kct.kip17
helps you easily handle a smart contract that implements KIP-17 as a JavaScript object on the Klaytn blockchain.
caver.kct.kip17
는 KIP-17 토큰 컨트랙트를 구현하기 위해 caver.contract를 상속합니다. caver.kct.kip17
은 caver.contract
와 동일한 속성값들을 가지며, 추가 기능 구현을 위해 메서드를 더 가지고 있습니다. 이 장은 caver.kct.kip17
메서드들 중 오직 새롭게 추가된 것만을 소개합니다.
The code that implements KIP-17 for caver-js is available on the Klaytn Contracts Github Repo. KIP-17 for caver-js supports Ownable interface. Using this, you can designate a contract owner when deploying a contract
For more information about KIP-17, see Klaytn Improvement Proposals.
caver.kct.kip17.deploy
KIP-17 토큰 컨트랙트를 Klaytn 블록체인에 배포합니다. caver.kct.kip17.deploy를 사용해 배포한 컨트랙트는 KIP-17 표준을 따르는 대체 불가 토큰입니다.
성공적으로 배포된 후, 프로미스는 새로운 KIP17 인스턴스를 반환할 것입니다.
Parameters
tokenInfo
object
Klaytn 블록체인에 KIP-17 토큰 컨트랙트를 배포하는 데 필요한 정보입니다. 자세한 내용은 아래 표를 참조하세요.
deployer
string | object
tokenInfo 객체는 다음을 반드시 포함해야 합니다:
name
string
토큰 이름입니다.
기호
string
토큰 심볼입니다.
Return Value
PromiEvent
: 이벤트 이미터와 결합된 프로미스이며 새로운 KIP17 인스턴스를 반환합니다. 추가로 다음 이벤트가 발생할 수 있습니다.
transactionHash
string
트랜잭션이 전송된 직후 및 트랜잭션 해시를 사용할 수 있을 때 발생합니다.
receipt
object
트랜잭션 영수증을 사용할 수 있을 때 발생합니다. 영수증 객체 속성값들에 관한 자세한 정보는 getTransactionReceipt를 참고하십시오. KIP17 인스턴스의 영수증은 'logs' 속성 대신에 ABI로 파싱된 'events' 속성을 가지고 있습니다.
error
Error
전송 중 오류가 나타나면 발생됩니다.
Token Enrollment
To enroll a token on a block explorer, the contract creator must fill out a submission request form. Make note of the specified information required on the form.
Smart Contract Environment
Compiler Type: Solidity
Compiler version: v0.8.4+commit.c7e474f2
Open Source License Type: MIT
Smart Contract Detail
Optimization: --optimize-run 200
Source code: KIP17 Contracts Github Link.
ABI-encoded Value: kip17JsonInterface at dev · klaytn/caver-js · GitHub
Example
caver.kct.kip17.detectInterface
Returns the information of the interface implemented by the token contract. This static function will use kip17.detectInterface.
Parameters
contractAddress
string
KIP-7 토큰 컨트랙트의 주소입니다.
Return Value
Promise
returns an object
containing the result with boolean values whether each KIP-17 interface is implemented.
Example
caver.kct.kip17.create
Creates a new KIP17 instance with its bound methods and events. This function works the same as new KIP17.
NOTE caver.kct.kip17.create
is supported since caver-js v1.6.1.
Parameters
See the new KIP17.
Return Value
See the new KIP17.
Example
new KIP17
Creates a new KIP17 instance with its bound methods and events.
Parameters
tokenAddress
string
(선택 사항) KIP-17 토큰 컨트랙트 주소이며 나중에 kip17.options.address = '0x1234..'
로 값을 설정할 수 있습니다.
Return Value
object
인스턴스 메소드와 이벤트들을 갖고 있는 KIP17 인스턴스입니다.
Example
kip17.clone
Clones the current KIP17 instance.
Parameters
tokenAddress
string
(선택 사항) 다른 KIP17 토큰을 배포했던 스마트 컨트랙트 주소입니다. 입력을 생략하면, 이 주소는 원본 인스턴스의 컨트랙트 주소로 설정됩니다.
Return Value
object
원본 KIP17 인스턴스를 복제한 인스턴스입니다.
Example
kip17.detectInterface
Returns the information of the interface implemented by the token contract.
Parameters
None
Return Value
Promise
returns an object
containing the result with boolean values whether each KIP-17 interface is implemented.
Example
kip17.supportsInterface
Returns true
if this contract implements the interface defined by interfaceId
.
Parameters
interfaceId
string
확인할 interfaceId입니다.
Return Value
Promise
returns boolean
: true
if this contract implements the interface defined by interfaceId
.
Example
kip17.name
Returns the name of the token.
Parameters
None
Return Value
Promise
returns string
: The name of the token.
Example
kip17.symbol
Returns the symbol of the token.
Parameters
None
Return Value
Promise
returns string
: The symbol of the token.
Example
kip17.totalSupply
Returns the total number of tokens minted by the contract.
Parameters
None
Return Value
Promise
returns BigNumber
: The total number of tokens.
Example
kip17.tokenURI
Returns the URI for a given token id.
Parameters
tokenId
BigNumber | string | number
토큰 ID입니다.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns string
: The URI of the given token.
Example
kip17.tokenOfOwnerByIndex
Searches the owner
's token list for the given index, and returns the token id of a token positioned at the matched index in the list if there is a match.
Parameters
owner
string
토큰을 소유한 계정 주소입니다.
index
BigNumber | string | number
토큰 소유자가 가지고 있는 토큰 목록 중 특정 토큰의 위치 인덱스입니다.
NOTE The index
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns BigNumber
: The id of the token.
Example
kip17.tokenByIndex
Searches the list of all tokens in this contract for the given index, and returns the token id of a token positioned at the matched index in the list if there is a match. It reverts if the index is greater or equal to the total number of tokens.
Parameters
index
BigNumber | string | number
검색할 토큰의 인덱스입니다.
NOTE The index
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns BigNumber
: The id of the token.
Example
kip17.balanceOf
Returns the balance of the given account address. The balance of an account in KIP-17 is the total number of NFTs (Non-Fungible Tokens) owned by the account.
Parameters
address
string
잔액을 확인할 계정 주소입니다.
Return Value
Promise
returns BigNumber
: The account balance.
Example
kip17.ownerOf
Returns the address of the owner of the specified token id.
Parameters
tokenId
BigNumber | string | number
The id of the token.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns string
: The address of the account that owns the given token.
Example
kip17.getApproved
Returns the address who was permitted to transfer this token, or 'zero' address, if no address was approved. It reverts if the given token id does not exist.
Parameters
tokenId
BigNumber | string | number
The id of the token.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns string
: The address of the account that has the right to transfer the given token.
Example
kip17.isApprovedForAll
Returns true
if an operator
is approved to transfer all tokens that belong to the owner
.
Parameters
owner
string
토큰을 소유한 계정 주소입니다. 이 계정은 operator에게 자신의 모든 토큰을 전송하도록 허락한 계정입니다.
operator
string
토큰 소유자를 대신해 토큰 소유자의 모든 토큰을 전송하도록 허락받은 계정 주소입니다.
Return Value
Promise
returns boolean
: true
if an operator
is approved to send all tokens that belong to the owner
.
Example
kip17.isMinter
Returns true
if the given account is a minter who can issue new tokens in the current contract conforming to KIP-17.
Parameters
address
string
발행 권한을 가지고 있는지를 확인받을 계정 주소입니다.
Return Value
Promise
returns boolean
: true
if the account is a minter.
Example
kip17.paused
Returns true
if the contract is paused, and false
otherwise.
Parameters
None
Return Value
Promise
returns boolean
: true
if the contract is paused.
Example
kip17.isPauser
Returns true
if the given account is a pauser who can suspend transferring tokens.
Parameters
address
string
토큰 전송을 멈출 권한이 있는지를 확인받을 계정 주소입니다.
Return Value
Promise
returns boolean
: true
if the account is a pauser.
Example
kip17.approve
Approves another address to transfer a token of the given token id. The zero address indicates there is no approved address. There can only be one approved address per token. This method is allowed to call only by the token owner or an approved operator.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
to
string
토큰 소유자를 대신해 토큰을 사용하는 계정 주소입니다.
tokenId
BigNumber | string | number
토큰 사용자가 사용을 허락받은 토큰의 ID입니다.
sendParam
object
(선택 사항) 트랜잭션 전송을 위해 사용될 파라미터들이 정의된 객체입니다.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
The sendParam object can contain the following:
from
string
(선택 사항) 트랜잭션 발신자 주소입니다. 미입력시 kip17.options.from
에 의해 지정됩니다. sendParam
객체의 from
또는 kip17.options.from
가 주어지지 않으면 오류가 발생합니다.
gas
number | string
(선택 사항) 트랜잭션에 규정된 최대 가스입니다 (가스 제한). 미입력시 caver-js가 kip17.methods.approve(spender, tokenId).estimateGas({from})
를 호출하여 이 값을 지정합니다.
gasPrice
number | string
(optional) The gas price in peb to use for this transaction. 생략하면 caver.klay.getGasPrice
값으로 caver-js가 설정합니다.
value
number | string | BN | BigNumber
(선택 사항) peb으로 환산한 전송될 토큰 가치.
feeDelegation
boolean
(optional, default false
) Whether to use fee delegation transaction. 미입력시 kip17.options.feeDelegation
를 사용합니다. 둘 다 미입력시 수수료 위임은 사용되지 않습니다.
feePayer
string
(optional) The address of the fee payer paying the transaction fee. When feeDelegation
is true
, the value is set to the feePayer
field in the transaction. 미입력시 kip17.options.feePayer
를 사용합니다. 둘 다 미입력시 오류를 반환합니다.
feeRatio
string
(optional) The ratio of the transaction fee the fee payer will be burdened with. If feeDelegation
is true
and feeRatio
is set to a valid value, a partial fee delegation transaction is used. The valid range of this is between 1 and 99. The ratio of 0, or 100 and above are not allowed. 미입력시 kip17.options.feeRatio
를 사용합니다.
NOTE feeDelegation
, feePayer
and feeRatio
are supported since caver-js v1.6.1.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.setApprovalForAll
Approves the given operator to
, or disallow the given operator, to transfer all tokens of the owner.
Note that the setApprovalForAll method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
to
string
토큰 소유자의 모든 토큰을 전송할 권한을 받거나 전송할 권한을 잃게될 계정 주소입니다.
approved
Boolean
true
이면 이 operator는 전송할 권한을 받습니다. false
이면 이 operator는 전송할 권한을 잃습니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. sendParam에 관한 자세한 정보는 approve의 파라미터 설명을 참고하십시오.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.transferFrom
Transfers the token of the given token id, tokenId
from the token owner's balance to another address. The address that was authorized to send the token owner's token (the operator) or the token owner him/herself is expected to execute this token transfer transaction. Thus, an authorized account or the token owner should be the sender of this transaction whose address must be given at sendParam.from
or kip17Instance.options.from
. Unless both sendParam.from
and kip17Instance.options.from
are provided, an error would occur. It is recommended to use safeTransferFrom whenever possible instead of this method.
Note that sending this transaction will charge the transaction fee to the transaction sender.
Parameters
from
string
주어진 토큰 소유자 주소 또는 주어진 토큰을 전송하도록 승인받은 operator 주소입니다.
to
string
토큰을 받을 계정 주소입니다.
tokenId
BigNumber | string | number
전송하고 싶은 토큰의 토큰 ID입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.safeTransferFrom
Safely transfers the token of the given token id tokenId
from the token owner's balance to another address. The address that was authorized to send the token owner's token (the operator) or the token owner him/herself is expected to execute this token transfer transaction. Thus, an authorized address or the token owner should be the sender of this transaction whose address must be given at sendParam.from
or kip17Instance.options.from
. Unless both sendParam.from
and kip17Instance.options.from
are provided, an error would occur.
If the to
is a contract address, it must implement IKIP17Receiver.onKIP17Received. otherwise, the transfer is reverted.
Note that sending this transaction will charge the transaction fee to the transaction sender.
Parameters
from
string
The address of the owner or the approved operator of the given token.
to
string
The address of the account to receive the token.
tokenId
BigNumber | string | number
The id of the token you want to transfer.
data
Buffer | string | number
(선택 사항) 호출 시 함께 보낼 데이터입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.addMinter
Adds an account as a minter, who are permitted to mint tokens.
Note that the addMinter method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
account
string
발행자에 추가될 계정 주소입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE If sendParam.from
or kip17.options.from
were given, it should be a minter.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.renounceMinter
Renounces the right to mint tokens. Only a minter address can renounce the minting right.
Note that the renounceMinter method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
If sendParam.from
or kip17.options.from
were given, it should be a minter with MinterRole.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.mintWithTokenURI
Creates a token with the given uri and assigns them to the given account. This method increases the total supply of this token.
Note that the mintWithTokenURI method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
to
string
토큰이 발행될 계정 주소입니다.
tokenId
BigNumber | string | number
발행될 토큰 ID입니다.
tokenURI
string
발행될 토큰 URI입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
NOTE If sendParam.from
or kip17.options.from
were given, it should be a minter with MinterRole.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.burn
Destroys the token of the given token id. Without sendParam.from
nor kip17.options.from
being provided, an error would occur.
Note that the burn method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
tokenId
BigNumber | string | number
제거할 토큰 ID입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE The tokenId
parameter accepts number
type but if the fed value were out of the range capped by number.MAX_SAFE_INTEGER, it might cause an unexpected result or error. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.pause
Suspends functions related to sending tokens.
Note that the pause method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE If sendParam.from
or kip17.options.from
were given, it should be a pauser with PauserRole.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.unpause
Resumes the paused contract.
Note that the unpause method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE If sendParam.from
or kip17.options.from
were given, it should be a pauser with PauserRole.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.addPauser
Adds an account as a pauser that has the right to suspend the contract.
Note that the addPauser method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
account
string
컨트랙트 중지 권한을 가질 계정 주소입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE If sendParam.from
or kip17.options.from
were given, it should be a pauser with PauserRole.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
kip17.renouncePauser
Renounces the right to pause the contract. Only a pauser address can renounce its own pausing right.
Note that the renouncePauser method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
NOTE If sendParam.from
or kip17.options.from
were given, it should be a pauser with PauserRole.
Return Value
Promise
returns object
- The receipt containing the result of the transaction execution. If you want to know about the properties inside the receipt object, see the description of getTransactionReceipt. Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Last updated