Last updated
Last updated
caver.klay.KIP17
은 표준을 구현한 스마트 컨트랙트를 JavaScript 객체 형태로 Klaytn 블록체인에서 손쉽게 다룰 수 있도록 돕습니다.
caver.klay.KIP17
는 KIP-17 토큰 컨트랙트를 구현하기 위해 를 상속합니다. caver.klay.KIP17
은 caver.klay.Contract
와 동일한 속성값들을 가지며, 추가 기능 구현을 위해 메서드를 더 가지고 있습니다. 이 장은 caver.klay.KIP17
메서드들 중 오직 새롭게 추가된 것만을 소개합니다.
caver-js에서 KIP-17을 구현한 예시는 에서 확인할 수 있습니다.
KIP-17에 관한 더 자세한 정보는 를 참조하십시오.
참고 caver.klay.KIP17
은 caver-js 부터 지원됩니다.
KIP-17 토큰 컨트랙트를 Klaytn 블록체인에 배포합니다. caver.klay.KIP17.deploy를 사용해 배포한 컨트랙트는 KIP-17 표준을 따르는 대체 불가 토큰입니다.
성공적으로 배포된 후, 프로미스는 새로운 KIP17 인스턴스를 반환할 것입니다.
파라미터
tokenInfo 객체는 다음을 반드시 포함해야 합니다:
리턴값
PromiEvent
: 이벤트 이미터와 결합된 프로미스이며 새로운 KIP17 인스턴스를 반환합니다. 추가로 다음 이벤트가 발생할 수 있습니다.
예시
새로운 KIP17 인스턴스를 인스턴스 메서드, 이벤트들과 함께 생성합니다.
파라미터
리턴값
예시
현재 KIP17 인스턴스를 복제합니다.
파라미터
리턴값
예시
이 컨트랙트가 interfaceId
로 정의된 인터페이스를 구현한다면 true
를 반환합니다.
파라미터
리턴값
프로미스
는 Boolean
을 반환: 이 컨트랙트가 해당 interfaceId
를 가진 인터페이스를 구현한다면 true
를 반환합니다.
예시
Returns the name of the token.
Parameters
None
Return Value
프로미스
는 String
을 반환: 토큰의 이름입니다.
Example
Returns the symbol of the token.
Parameters
None
Return Value
프로미스
는 String
을 반환: 토큰의 심볼입니다.
Example
Returns the total number of tokens minted by the contract.
Parameters
None
Return Value
Promise
returns BigNumber
: The total number of tokens.
Example
Returns the URI for a given token id.
Parameters
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
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
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
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
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
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
Return Value
Promise
returns BigNumber
: The account balance.
Example
Returns the address of the owner of the specified token id.
Parameters
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
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
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
Returns true
if an operator
is approved to transfer all tokens that belong to the owner
.
Parameters
Return Value
Promise
returns Boolean
: true
if an operator
is approved to send all tokens that belong to the owner
.
Example
Returns true
if the given account is a minter who can issue new tokens in the current contract conforming to KIP-17.
Parameters
Return Value
Promise
returns Boolean
: true
if the account is a minter.
Example
Returns true
if the contract is paused, and false
otherwise.
Parameters
None
Return Value
Promise
returns Boolean
: true
if the contract is paused.
Example
Returns true
if the given account is a pauser who can suspend transferring tokens.
Parameters
Return Value
Promise
returns Boolean
: true
if the account is a pauser.
Example
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
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:
Return Value
Example
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
Return Value
Example
Note that sending this transaction will charge the transaction fee to the transaction sender.
Parameters
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
Example
Safely transfers the token of the given token id tokenId
from the token owner's balance to another address. The address who was approved to send the token owner's token (the operator) or the token owner itself is expected to execute this token transferring transaction. Thus, the approved one or the token owner should be the sender of this transaction whose address must be given at sendParam.from
or kip7Instance.options.from
. Without sendParam.from
nor kip7Instance.options.from
being provided, an error would occur.
Note that sending this transaction will charge the transaction fee to the transaction sender.
Parameters
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
Example
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
NOTE If sendParam.from
or KIP17Instance.options.from
were given, it should be a minter.
Return Value
Example
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
If sendParam.from
or KIP17Instance.options.from
were given, it should be a minter with MinterRole.
Return Value
Example
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
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 KIP17Instance.options.from
were given, it should be a minter with MinterRole.
Return Value
Example
Destroys the token of the given token id. Without sendParam.from
nor KIP17Instance.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
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
Example
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
NOTE If sendParam.from
or KIP17Instance.options.from
were given, it should be a pauser with PauserRole.
Return Value
Example
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
NOTE If sendParam.from
or KIP17Instance.options.from
were given, it should be a pauser with PauserRole.
Return Value
Example
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
NOTE If sendParam.from
or KIP17Instance.options.from
were given, it should be a pauser with PauserRole.
Return Value
Example
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
NOTE If sendParam.from
or KIP17Instance.options.from
were given, it should be a pauser with PauserRole.
Return Value
Example
프로미스
는 Object
를 반환 - 트랜잭션 실행 결과를 담고 있는 영수증입니다. If you want to know about the properties inside the receipt object, see the description of . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
주어진 토큰 ID tokenId
를 가진 토큰을 토큰 소유자 잔액에서 다른 계정으로 전송합니다. The address who was approved to send the token owner's token (the operator) or the token owner itself is expected to execute this token transferring transaction. 따라서 토큰을 보내도록 허락받은 계정 또는 토큰 소유자가 이 트랜잭션 발신자이어야 하며, 허락받은 계정의 주소는 반드시 sendParam.from
또는 kip7Instance.options.from
에 주어져야 합니다. sendParam.from
또는 kip7Instance.options.from
가 주어지지 않는다면 에러가 발생합니다. It is recommended to use whenever possible instead of this method.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
If the to
is a contract address, it must implement . otherwise, the transfer is reverted.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
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 . Receipts from KIP-17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.