caver.klay.KIP17
KIP-17 표준을 구현한 스마트 컨트랙트와 상호작용하는 데 사용되는 caver-js 객체입니다.
Last updated
KIP-17 표준을 구현한 스마트 컨트랙트와 상호작용하는 데 사용되는 caver-js 객체입니다.
Last updated
caver.klay.KIP17
은 KIP-17 표준을 구현한 스마트 컨트랙트를 JavaScript 객체 형태로 Klaytn 블록체인에서 손쉽게 다룰 수 있도록 돕습니다.
caver.klay.KIP17
는 KIP-17 토큰 컨트랙트를 구현하기 위해 caver.klay.Contract를 상속합니다. caver.klay.KIP17
은 caver.klay.Contract
와 동일한 속성값들을 가지며, 추가 기능 구현을 위해 메서드를 더 가지고 있습니다. 이 장은 caver.klay.KIP17
메서드들 중 오직 새롭게 추가된 것만을 소개합니다.
caver-js에서 KIP-17을 구현한 예시는 Klaytn Contracts Github Repo에서 확인할 수 있습니다.
KIP-17에 관한 더 자세한 정보는 Klaytn Improvement Proposals를 참조하십시오.
참고 caver.klay.KIP17
은 caver-js v1.4.1부터 지원됩니다.
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
프로미스
는 Object
를 반환 - 트랜잭션 실행 결과를 담고 있는 영수증입니다. 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
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
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
주어진 토큰 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 safeTransferFrom whenever possible instead of this method.
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
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
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
이름 | 타입 | 설명 |
---|---|---|
이름 | 타입 | 설명 |
---|---|---|
타입 | 설명 |
---|---|
이름 | 타입 | 설명 |
---|---|---|
타입 | 설명 |
---|---|
이름 | 타입 | 설명 |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
tokenInfo
Object
Klaytn 블록체인에 KIP-17 토큰 컨트랙트를 배포하는 데 필요한 정보입니다. 자세한 내용은 아래 표를 참조하세요.
deployer
String
KIP-17 토큰 컨트랙트를 배포하는 계정 주소입니다. 이 계정은 반드시 배포를 위해 충분한 KLAY를 가지고 있어야 합니다.
name
String
토큰 이름입니다.
symbol
String
토큰 심볼입니다.
transactionHash
String
트랜잭션이 전송된 직후 및 트랜잭션 해시를 사용할 수 있을 때 발생합니다.
receipt
Object
트랜잭션 영수증을 사용할 수 있을 때 발생합니다. 영수증 객체 속성값들에 관한 자세한 정보는 getTransactionReceipt를 참고하십시오. KIP17 인스턴스의 영수증은 'logs' 속성 대신에 ABI로 파싱된 'events' 속성을 가지고 있습니다.
error
Error
전송 중 오류가 나타나면 발생합니다.
tokenAddress
String
(선택 사항) KIP-17 토큰 컨트랙트 주소이며 나중에 kip17Instance.options.address = '0x1234..'
로 값을 설정할 수 있습니다.
Object
인스턴스 메소드와 이벤트들을 갖고 있는 KIP17 인스턴스입니다.
tokenAddress
String
(선택 사항) 다른 KIP-17 토큰을 배포했던 스마트 컨트랙트 주소입니다. 미입력시 원본 인스턴스의 컨트랙트 주소로 설정됩니다.
Object
원본 KIP17 인스턴스를 복제한 인스턴스입니다.
interfaceId
String
확인할 interfaceId입니다.
tokenId
BigNumber \
String | Number
owner
String
The address of the account who owns tokens.
index
BigNumber \
String | Number
index
BigNumber \
String | Number
address
String
The address of the account to be checked for its balance.
tokenId
BigNumber \
String | Number
tokenId
BigNumber \
String | Number
owner
String
The address of an account that owns tokens and has allowed the operator to send all its tokens.
operator
String
The address of the account approved to send owner's all tokens in place of the owner.
address
String
The address of the account to be checked for having the minting right.
address
String
The address of the account to be checked for having the right to suspend transferring tokens.
to
String
The address of the account who spends tokens in place of the owner.
tokenId
BigNumber \
String | Number
sendParam
Object
(optional) An object with defined parameters for sending a transaction.
from
String
(optional) The address from which the transaction should be sent. 생략되면, this.options.from
에 의해 지정됩니다. sendParam
객체의 from
또는 this.options.from
가 주어지지 않으면, 에러가 발생합니다.
gas
Number \
String
gasPrice
Number \
String
value
Number \
String | BN | BigNumber
to
String
The address of an account to be approved/prohibited to transfer the owner's all tokens.
approved
Boolean
This operator will be approved if true
. The operator will be disallowed if false
.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
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
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
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
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.
account
String
The address of the account to be added as a minter.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
to
String
The address of the account to which the minted token will be issued.
tokenId
BigNumber \
String | Number
tokenURI
String
The uri string of the token to be minted.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
tokenId
BigNumber \
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.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
account
String
The address of the account to be a new pauser.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
sendParam
Object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.