caver.kct.kip37
Last updated
Last updated
caver.kct.kip37
은 JavaScript의 객체로서 KIP-37을 구현하는 스마트 컨트랙트를 Klaytn 블록체인 플랫폼에서 쉽게 다룰 수 있도록 도와줍니다.
caver.kct.kip37
는 KIP-37 토큰 컨트랙트를 구현하기 위해 caver.contract를 상속합니다. caver.kct.kip37
은 caver.contract
와 동일한 속성값들을 가지며, 추가 기능 구현을 위한 메서드를 더 가지고 있습니다. 이 장은 caver.kct.kip37
메서드들 중 오직 새롭게 추가된 것만을 소개합니다.
The code that implements KIP-37 for caver-js is available on the Klaytn Contracts Github Repo. KIP-37 for caver-js supports Ownable interface. Using this, you can designate a contract owner when deploying a contract
For more information about KIP-37, see Klaytn Improvement Proposals.
참고 caver.kct.kip37
는 caver-js v1.5.7부터 지원됩니다.
KIP-37 토큰 컨트랙트를 Klaytn 블록체인에 배포합니다. caver.kct.kip37.deploy를 사용해 배포한 컨트랙트는 KIP-37 표준을 따르는 멀티 토큰입니다.
성공적으로 배포된 후, 프로미스는 새로운 KIP37 인스턴스를 반환할 것입니다.
Parameters
Name | Type | Description |
---|---|---|
The tokenInfo object must contain the following:
Name | Type | Description |
---|---|---|
Return Value
PromiEvent
: 이벤트 이미터와 결합된 프로미스이며 새로운 KIP37 인스턴스를 반환합니다. 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: KIP37 Contracts Github Link.
ABI-encoded Value: kip37JsonInterface at dev · klaytn/caver-js · GitHub
Example
Returns the information of the interface implemented by the token contract. This static function will use kip37.detectInterface.
Parameters
Return Value
Promise
returns an object
containing the result with boolean values whether each KIP-37 interface is implemented.
Example
Creates a new KIP37 instance with its bound methods and events. This function works the same as new KIP37.
NOTE caver.kct.kip37.create
is supported since caver-js v1.6.1.
Parameters
See the new KIP37.
Return Value
See the new KIP37.
Example
Creates a new KIP37 instance with its bound methods and events.
Parameters
Return Value
Example
Clones the current KIP37 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-37 interface is implemented.
Example
Return 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 distinct Uniform Resource Identifier (URI) of the given token.
If the string "{id}" exists in any URI, this function will replace this with the actual token ID in hexadecimal form. Please refer to KIP-34 Metadata.
Parameters
NOTE The id
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 token.
Example
Returns the total token supply of the specific token.
Parameters
NOTE The id
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 total number of tokens.
Example
Returns the amount of tokens of token type id
owned by account
.
Parameters
NOTE The id
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 amount of token that account has.
Example
Returns the balance of multiple account/token pairs. balanceOfBatch
is a batch operation of balanceOf, and the length of arrays with accounts
and ids
must be the same.
Parameters
Return Value
Promise
returns Array
: The balance of multiple account/token pairs.
Example
Returns true
if the given account is a minter who can issue new KIP37 tokens.
Parameters
Return Value
Promise
returns boolean
: true
if the account is a minter.
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
Returns whether or not the token contract's transaction (or specific token) is paused.
If id parameter is not defined, return whether the token contract's transaction is paused. If id parameter is defined, return whether the specific token is paused.
Parameters
NOTE The id
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 boolean
: true
if the contract (or specific token) is paused.
Example
Queries the approval status of an operator for a given owner. Returns true
if an operator is approved by a given owner.
Parameters
Return Value
Promise
returns boolean
: True if the operator is approved, false if not
Example
Creates a new token type and assigns initialSupply
to the minter.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE The id
, initialSupply
parameters accept 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 contains 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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Approves the given operator, or disallow the given operator, to transfer all tokens of the owner.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction 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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Safely transfers the given amount
tokens of specific token type id
from from
to the recipient
.
The address that was authorized to send the 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 kip37.options.from
. Unless both sendParam.from
and kip37.options.from
are provided, an error would occur.
If the recipient was a contract address, it should implement IKIP37Receiver.onKIP37Received. Otherwise, the transfer is reverted.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE The id
and amount
parameters accept 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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Safely batch transfers of multiple token ids and values from from
to the recipient
.
The address that was approved to send the owner's token (the operator) or the token owner him/herself is expected to execute this token transfer transaction. Thus, an approved address or the token owner should be the sender of this transaction whose address must be given at sendParam.from
or kip37.options.from
. Unless both sendParam.from
and kip37.options.from
are provided, an error would occur.
If the recipient was a contract address, it should implement IKIP37Receiver.onKIP37Received. Otherwise, the transfer is reverted.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE The ids
and amounts
array parameters accept number
type as an element in array, 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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Mints the token of the specific token type id
and assigns the tokens according to the variables to
and value
. The mint function allows you to mint specific token to multiple accounts at once by passing arrays to to
and value
as parameters.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE The id
and value
parameters accept 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 kip37.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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Mints the multiple KIP-37 tokens of the specific token types ids
in a batch and assigns the tokens according to the variables to
and values
.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE The ids
and values
array parameters accept number
type as an element in array, 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 kip37.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 KIP37 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 this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE If sendParam.from
or kip37.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 KIP37 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 this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE If sendParam.from
or kip37.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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Burns specific KIP-37 tokens.
The address that was approved to operate the 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 kip37.options.from
. Unless both sendParam.from
and kip37.options.from
are provided, an error would occur.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE The id
and amount
parameters accept 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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Burns the multiple KIP-37 tokens.
The address that was authorized to operate the owner's token (the operator) or the token owner him/herself is expected to execute this token transfer transaction. Thus, the authorized one or the token owner should be the sender of this transaction whose address must be given at sendParam.from
or kip37.options.from
. Unless both sendParam.from
and kip37.options.from
are provided, an error would occur.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE The ids
and values
array parameters accept number
type as an element in array, 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 KIP37 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 this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE If sendParam.from
or kip37.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 KIP37 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 the pausing right.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE If sendParam.from
or kip37.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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Suspends functions related to token operation. If id
parameter is defined, pause the specific token. Otherwise pause the token contract.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE If sendParam.from
or kip37.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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Resumes the paused contract or specific token. If id
parameter is defined, unpause the specific token. Otherwise unpause the token contract.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the transaction sender.
Parameters
NOTE If sendParam.from
or kip37.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 KIP37 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
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 |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
tokenInfo
object
Klaytn 블록체인에 KIP-37 토큰 컨트랙트를 배포하는 데 필요한 정보입니다. See the below table for the details.
deployer
string | object
uri
string
The URI for all token types, by relying on the token type ID substitution mechanism.
transactionHash
string
Fired right after the transaction is sent and a transaction hash is available.
receipt
object
Fired when the transaction receipt is available. If you want to know about the properties inside the receipt object, see getTransactionReceipt. KIP37 인스턴스의 영수증은 'logs' 속성 대신에 ABI로 파싱된 'events' 속성을 가지고 있습니다.
error
Error
Fired if an error occurs during sending.
contractAddress
string
KIP-37 토큰 컨트랙트의 주소입니다.
tokenAddress
string
(선택 사항) KIP-37 토큰 컨트랙트 주소이며 나중에 kip37.options.address = '0x1234..'
로 값을 설정할 수 있습니다.
object
인스턴스 메소드와 이벤트들을 갖고 있는 KIP37 인스턴스입니다.
tokenAddress
string
(선택 사항) 다른 KIP37 토큰을 배포했던 스마트 컨트랙트 주소입니다. If omitted, it will be set to the contract address in the original instance.
object
원본 KIP37 인스턴스를 복제한 인스턴스입니다.
interfaceId
string
The interfaceId to be checked.
id
BigNumber | string | number
URI를 받을 토큰 ID입니다.
id
BigNumber | string | number
총 발행량을 확인할 토큰의 ID입니다.
account
string
잔액을 확인할 계정 주소입니다.
id
BigNumber | string | number
잔액을 확인할 토큰의 ID입니다.
accounts
Array
The address of the account for which you want to see balance.
ids
Array
잔액을 확인할 토큰 ID의 배열입니다.
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.
id
BigNumber | string | number
(선택 사항) 중단 여부 확인을 위한 토큰 ID입니다. 해당 파라미터 미입력시 paused
함수는 컨트랙트가 중단 상태에 있는지 여부를 반환합니다.
owner
string
소유자의 주소입니다.
operator
string
Operator의 주소입니다.
id
BigNumber | string | number
생성할 토큰 ID입니다.
initialSupply
BigNumber | string | number
발행할 토큰의 양입니다.
uri
string
(선택 사항) 생성된 토큰의 URI입니다.
sendParam
object
(선택 사항) 트랜잭션을 보내는 데 필요한 파라미터들을 가지고 있는 객체입니다.
from
string
(optional) The address from which the transaction should be sent. 미입력시 kip37.options.from
에 의해 지정됩니다. sendParam
객체의 from
또는 kip37.options.from
가 주어지지 않으면 오류가 발생합니다.
gas
number | string
(선택 사항) 이 트랜잭션이 쓸 수 있는 최대 가스량 (가스 제한) 입니다. 미입력시 caver-js가 kip37.methods.approve(spender, amount).estimateGas({from})
를 호출하여 이 값을 지정합니다.
gasPrice
number | string
(선택 사항) 이 트랜잭션에 사용할 peb 단위의 가스 가격. If omitted, it will be set by caver-js via calling caver.klay.getGasPrice
.
value
number | string | BN | BigNumber
(optional) The value to be transferred in peb.
feeDelegation
boolean
(optional, default false
) Whether to use fee delegation transaction. 미입력시 kip37.options.feeDelegation
를 사용합니다. If both omitted, fee delegation is not used.
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. 미입력시 kip37.options.feePayer
를 사용합니다. If both omitted, throws an error.
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. 미입력시 kip37.options.feeRatio
를 사용합니다.
operator
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. sendParam에 관한 자세한 정보는 kip37.create의 파라미터 설명을 참고하십시오.
from
string
토큰을 소유한 계정 주소입니다. 이 계정 주소 잔액에서 allowance(kip7Instance.approve)를 사용해 토큰이 보내집니다.
recipient
string
The address of the account to receive the token.
id
BigNumber | string | number
전송할 토큰 ID입니다.
amount
BigNumber | string | number
전송할 토큰 수량입니다.
data
Buffer | string | number
(optional) The optional data to send along with the call.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of kip37.create.
from
string
The address of the account that owns the token to be sent with allowance mechanism.
recipient
string
The address of the account to receive the token.
ids
Array
전송할 토큰 ID의 배열입니다.
amounts
Array
전송하고자 하는 토큰 수량의 배열입니다.
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 kip37.create.
to
string | Array
토큰이 발행될 계정의 주소 또는 주소들의 배열입니다.
id
BigNumber | string | number
발행할 토큰 ID입니다.
value
BigNumber | string | number | Array
발행될 토큰 수량입니다. 다수의 주소를 포함한 배열은 배열 형식으로 to
파라미터에 전달되어야 합니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of kip37.create.
to
string
토큰들이 발행될 계정 주소입니다.
ids
Array
발행할 토큰 ID들의 배열입니다.
values
Array
발행할 토큰 수량들의 배열입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of kip37.create.
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 kip37.create.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of kip37.create.
account
string
제거될 토큰을 소유하는 계정의 주소입니다.
id
BigNumber | string | number
제거할 토큰 ID입니다.
value
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 kip37.create.
account
string
The address of the account that owns the token to be destroyed.
ids
Array
소각할 토큰 ID들의 배열입니다.
values
Array
소각할 토큰 수량들의 배열입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of kip37.create.
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 kip37.create.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of kip37.create.
id
BigNumber | string | number
(선택 사항) 중지시킬 토큰 ID입니다. 해당 파라미터 미입력시 pause
함수는 컨트랙트를 중지시킵니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of kip37.create.
id
BigNumber | string | number
(선택 사항) 중지 해제할 토큰 ID입니다. 해당 파라미터 미입력시 unpause
함수는 토큰 컨트랙트의 중지를 해제합니다.