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.
The caver.kct.kip17
inherits caver.contract to implement the KIP-17 token contract. The caver.kct.kip17
holds the same properties of caver.contract
whereas there are additional methods to implement extra features. This section only introduces the newly added bound methods of the 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.
Deploys the KIP-17 token contract to the Klaytn blockchain. A contract deployed using caver.kct.kip17.deploy is a non-fungible token that follows the KIP-17 standard.
After successful deployment, the promise will be resolved with a new KIP17 instance.
Parameters
Name | Type | Description |
---|---|---|
The tokenInfo object must contain the following:
Name | Type | Description |
---|---|---|
Return Value
PromiEvent
: A promise combined event emitter, which is resolved with a new KIP17 instance. Additionally, the following events can occur:
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