caver.kct.kip17
Last updated
Last updated
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.
KIP-17 토큰 컨트랙트를 Klaytn 블록체인에 배포합니다. caver.kct.kip17.deploy를 사용해 배포한 컨트랙트는 KIP-17 표준을 따르는 대체 불가 토큰입니다.
성공적으로 배포된 후, 프로미스는 새로운 KIP17 인스턴스를 반환할 것입니다.
Parameters
Name | Type | Description |
---|---|---|
tokenInfo 객체는 다음을 반드시 포함해야 합니다:
Name | Type | Description |
---|---|---|
Return Value
PromiEvent
: 이벤트 이미터와 결합된 프로미스이며 새로운 KIP17 인스턴스를 반환합니다. 추가로 다음 이벤트가 발생할 수 있습니다.
Name | Type | Description |
---|---|---|
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
Returns the information of the interface implemented by the token contract. This static function will use kip17.detectInterface.
Parameters
Return Value
Promise
returns an object
containing the result with boolean values whether each KIP-17 interface is implemented.
Example
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
Creates a new KIP17 instance with its bound methods and events.
Parameters
Return Value
Example
Clones the current KIP17 instance.
Parameters
Return Value
Example
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
Returns true
if this contract implements the interface defined by interfaceId
.
Parameters
Return Value
Promise
returns boolean
: true
if this contract implements the interface defined by interfaceId
.
Example
Returns the name of the token.
Parameters
None
Return Value
Promise
returns string
: The name of the token.
Example
Returns the symbol of the token.
Parameters
None
Return Value
Promise
returns string
: The symbol of the token.
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:
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
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