caver.kct.kip7
Last updated
Last updated
caver.kct.kip7
는 JavaScript의 객체로서 KIP-7을 구현하는 스마트 컨트랙트를 Klaytn 블록체인 플랫폼에서 쉽게 다룰 수 있도록 도와줍니다.
caver.kct.kip7
는 KIP-7 토큰 컨트랙트를 구현하기 위해 caver.contract를 상속합니다. caver.kct.kip7
은 caver.contract
와 동일한 속성값들을 가지며, 추가 기능 구현을 위해 메소드를 더 가지고 있습니다. 이 장은 caver.kct.kip7
메소드들 중 오직 새롭게 추가된 것들만 소개합니다.
caver.kct.kip7에서 사용된 abi와 바이트 코드는 OpenZeppelin 예시를 사용하여 구현되었습니다.
The code that implements KIP-7 for caver-js is available on the Klaytn Contracts Github Repo.
For more information about KIP-7, see Klaytn Improvement Proposals.
KIP-7 토큰 컨트랙트를 Klaytn 블록체인에 배포합니다. caver.kct.kip7.deploy를 사용해 배포한 컨트랙트는 KIP-7 표준을 따르는 대체 가능 토큰입니다.
성공적으로 배포된 후, 프로미스는 새로운 KIP7 인스턴스를 반환할 것입니다.
Parameters
Name | Type | Description |
---|---|---|
The tokenInfo object must contain the following:
Name | Type | Description |
---|---|---|
참고 initialSupply
파라미터는 number
타입을 받지만, 입력된 값이 number.MAX_SAFE_INTEGER 범위를 초과할 경우, 예상치 못한 결과나 오류가 발생할 수 있습니다. In this case, it is recommended to use the BigNumber
type, especially for a uint256
sized numeric input value.
Return Value
PromiEvent
: 이벤트 이미터와 결합된 프로미스이며 새로운 KIP7 인스턴스를 반환합니다. Additionally, the following events can occur:
Example
Returns the information of the interface implemented by the token contract. 이 정적 함수는 kip7.detectInterface를 사용합니다.
Parameters
Return Value
Promise
returns an object
containing the result with boolean values whether each KIP-7 interface is implemented.
Example
새로운 KIP7 인스턴스를 인스턴스 메소드, 이벤트들과 함께 생성합니다. 이 함수는 new KIP7과 동일하게 작동합니다.
참고 caver.kct.kip7.create
는 caver-js v1.6.1부터 지원됩니다.
Parameters
new KIP7를 참고하세요.
Return Value
See the new KIP7.
Example
Creates a new KIP7 instance with its bound methods and events.
Parameters
Return Value
Example
현재 KIP7 인스턴스를 복제합니다.
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-7 interface is implemented.
Example
Return true
if this contract implements the interface defined by interfaceId
.
Parameters
Return Value
프로미스
는 Boolean
을 반환: 이 컨트랙트가 해당 interfaceId
를 가진 인터페이스를 구현한다면 true
를 반환합니다.
Example
토큰 이름을 반환합니다.
Parameters
None
Return Value
Promise
returns string
: The name of the token.
Example
토큰 심볼을 반환합니다.
Parameters
None
Return Value
Promise
returns string
: The symbol of the token.
Example
토큰이 사용하는 소수점 자릿수를 반환합니다.
Parameters
None
Return Value
프로미스
는 Number
를 반환: 토큰이 사용하는 소수점 자릿수입니다.
Example
토큰의 총 공급량을 반환합니다.
Parameters
None
Return Value
Promise
returns BigNumber
: The total number of tokens.
Example
주어진 계정 주소의 잔액을 반환합니다.
Parameters
Return Value
Promise
returns BigNumber
: The account balance.
Example
spender
가 owner
의 잔액에서 인출하도록 허락받은 토큰 수량을 반환합니다.
Parameters
Return Value
프로미스
는 BigNumber
를 반환: 토큰 소유자를 대신해 토큰 사용자가 사용할 수 있도록 남아있는 토큰 수량입니다.
Example
주어진 계정이 새 KIP-7 토큰을 발행할 수 있는 minter라면 true
를 반환합니다.
Parameters
Return Value
프로미스
는 Boolean
을 반환: 계정이 발행자라면 true
를 반환합니다.
Example
주어진 계정이 토큰 전송을 멈출 수 있는 pauser라면 true
를 반환합니다.
Parameters
Return Value
프로미스
는 Boolean
을 반환: 이 계정이 중지 권한을 가진 계정이라면 true
를 반환합니다.
Example
컨트랙트가 작동을 멈추었다면 true
를 반환하고, 그렇지 않으면 false
를 반환합니다.
Parameters
None
Return Value
프로미스
는 Boolean
을 반환: 이 컨트랙트가 중지되었다면 true
를 반환합니다.
Example
토큰 소유자의 토큰을 spender
가 amount
만큼 사용하도록 허락합니다.
이 메서드는 토큰 소유자가 트랜잭션 발신자로서 Klaytn 네트워크에 트랜잭션을 전송하며, 트랜잭션 수수료가 트랜잭션 발신자에게 부과됩니다.
Parameters
참고 amount
파라미터는 Number
타입 값을 받지만, 입력된 값이 Number.MAX_SAFE_INTEGER 범위를 초과하면 예상치 못한 결과 또는 오류를 발생시킬 수 있습니다. 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. KIP7 인스턴스의 영수증은 'logs' 속성 대신에 ABI로 파싱된 'events' 속성을 가지고 있습니다.
Example
주어진 amount
만큼의 토큰을 토큰 소유자 잔액에서 recipient
에게 보냅니다. 토큰 소유자는 이 토큰 전송을 직접 실행해야 합니다. 따라서 토큰 소유자는 이 트랜잭션 발신자이어야 하며, 토큰 소유자의 주소는 반드시 sendParam.from
또는 kip7.options.from
에 주어져야 합니다. sendParam.from
또는 kip7.options.from
가 주어지지 않는다면 에러가 발생합니다.
Note that sending this transaction will charge the transaction fee to the transaction sender.
Parameters
NOTE The amount
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 KIP7 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
주어진 amount
만큼의 토큰을 토큰 소유자 잔액에서 recipient
에게 안전하게 보냅니다. The token owner should execute this token transfer with its own hands. Thus, the token owner should be the sender of this transaction whose address must be given at sendParam.from
or kip7.options.from
. Without sendParam.from
nor kip7.options.from
being provided, an error would occur.
If the recipient was a contract address, it should implement IKIP7Receiver.onKIP7Received. Otherwise, the transfer is reverted.
Note that sending this transaction will charge the transaction fee to the transaction sender.
Parameters
NOTE The amount
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. KIP7 인스턴스의 영수증은 'logs' 속성 대신에 ABI로 파싱된 'events' 속성을 가지고 있습니다.
Example
Transfers the given amount
of the token from the token owner's balance to the recipient
. 토큰 소유자의 토큰을 보내도록 허락받은 주소가 이 토큰 전송 트랜잭션을 실행할 수 있습니다. 따라서 토큰을 보내도록 허락받은 계정이 이 트랜잭션 발신자이어야 하며, 허락받은 계정의 주소는 반드시 sendParam.from
또는 kip7.options.from
에 주어져야 합니다. Without sendParam.from
nor kip7.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 amount
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 KIP7 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Safely transfers the given amount
of the token from the token owner's balance to the recipient
. The address who was approved to send the token owner's tokens is expected to execute this token transferring transaction. Thus, the approved one should be the sender of this transaction whose address must be given at sendParam.from
or kip7.options.from
. Without sendParam.from
nor kip7.options.from
being provided, an error would occur.
If the recipient was a contract address, it should implement IKIP7Receiver.onKIP7Received. Otherwise, the transfer is reverted.
Note that sending this transaction will charge the transaction fee to the transaction sender.
Parameters
NOTE The amount
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 KIP17 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
amount
만큼의 토큰을 만들어 account
에게 발행합니다. 이 함수는 토큰 총 공급량을 증가시킵니다.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
NOTE The amount
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.
참고 만약 sendParam.from
또는 kip7.options.from
이 주어졌다면, 이 주소는 반드시 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 KIP7 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 sender.
Parameters
참고 만약 sendParam.from
또는 kip7.options.from
이 주어졌다면, 이 주소는 반드시 발행자이어야 합니다.
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 KIP7 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 sender.
Parameters
NOTE If sendParam.from
or kip7.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 KIP7 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
amount
만큼의 토큰을 트랜잭션 발신자 잔액에서 제거합니다. Without sendParam.from
nor kip7.options.from
being 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 sender.
Parameters
NOTE The amount
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 KIP7 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
account
에서 주어진 토큰 수량을 제거합니다. sendParam.from
또는 kip7.options.from
에 허용된 토큰량은 account
계정 잔고와 함께 줄어듭니다.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
NOTE The amount
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 KIP7 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 sender.
Parameters
참고 만약 sendParam.from
또는 kip7.options.from
이 주어졌다면, 이 주소는 반드시 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 KIP7 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 sender.
Parameters
NOTE If sendParam.from
or kip7.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 KIP7 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Suspends functions related to sending tokens.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
NOTE If sendParam.from
or kip7.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 KIP7 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Resumes the paused contract.
Note that this method will submit a transaction to the Klaytn network, which will charge the transaction fee to the sender.
Parameters
NOTE If sendParam.from
or kip7.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 KIP7 instances have an 'events' attribute parsed via ABI instead of a 'logs' attribute.
Example
Name | Type | Description |
---|---|---|
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 |
---|---|---|
tokenInfo
object
Klaytn 블록체인에 KIP-7 토큰 컨트랙트를 배포하는 데 필요한 정보입니다. See the below table for the details.
deployer
string | object
KIP-7 토큰 컨트랙트를 배포하는 주소입니다. 이 주소는 keyring에 존재합니다. keyring에 있는 이 계정 주소는 반드시 배포를 위해 충분한 KLAY를 가지고 있어야 합니다. If you want to define your own fields to use when sending transactions, you can pass the object type as a parameter. KIP-7 컨트랙트 배포 시 수수료 위임을 이용하고 싶다면, 객체 내 수수료 위임과 관련된 필드를 정의할 수 있습니다. sendParam에 관한 자세한 정보는 approve의 매개변수 설명을 참고하십시오.
name
string
The name of the token.
symbol
string
The symbol of the token.
decimals
number
토큰이 사용하는 소수점 자릿수입니다.
initialSupply
BigNumber | string | number
최초 공급될 토큰 총 수량입니다.
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. KIP7 인스턴스의 영수증은 'logs' 속성 대신에 ABI로 파싱된 'events' 속성을 가지고 있습니다.
error
Error
Fired if an error occurs during sending.
contractAddress
string
The address of the KIP-7 token contract
tokenAddress
string
(선택 사항) KIP-7 토큰 컨트랙트 주소이며 나중에 kip7.options.address = '0x1234..'
로 값을 설정할 수 있습니다.
object
인스턴스 메소드와 이벤트들을 갖고 있는 KIP7 인스턴스입니다.
tokenAddress
string
(선택 사항) 다른 KIP-7 토큰을 배포했던 스마트 컨트랙트 주소입니다. If omitted, it will be set to the contract address in the original instance.
object
원본 KIP7 인스턴스를 복제한 인스턴스입니다.
interfaceId
string
The interfaceId to be checked.
address
string
The address of the account to be checked for its balance.
owner
string
토큰 소유자 계정의 주소입니다.
spender
string
토큰 소유자를 대신해 토큰을 사용하는 계정 주소입니다.
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.
spender
string
The address of the account who spends tokens in place of the owner.
amount
BigNumber | string | number
토큰 spender가 사용을 허락받은 토큰 수량입니다.
sendParam
object
(optional) An object holding parameters that are required for sending a transaction.
from
string
(optional) The address from which the transaction should be sent. 미입력 시 kip7.options.from
에 의해 지정됩니다. sendParam
객체의 from
또는 this.options.from
가 주어지지 않으면 오류가 발생합니다.
gas
number | string
(optional) The maximum number of gas provided for this transaction (gas limit). 미입력 시 caver-js가 kip7.methods.approve(spender, amount).estimateGas({from})
를 호출하여 이 값을 지정합니다.
gasPrice
number | string
(optional) The gas price in peb for this transaction. 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. 미입력 시 kip7.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. 미입력 시 kip7.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. 미입력 시 kip7.options.feeRatio
를 사용합니다.
recipient
string
The address of the account to receive the token.
amount
BigNumber | string | number
전송될 토큰 수량입니다.
sendParam
object
(optional) An object with defined parameters for sending a transaction. sendParam에 관한 자세한 정보는 approve의 파라미터 설명을 참고하십시오.
recipient
string
The address of the account to receive the token.
amount
BigNumber | string | number
The amount of token you want to transfer.
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 approve.
sender
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.
amount
BigNumber | string | number
The amount of token you want to transfer.
sendParam
object
(optional) An object with defined parameters for sending a transaction. For more information about sendParam, refer to the parameter description of approve.
sender
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.
amount
BigNumber | string | number
The amount of token you want to transfer.
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 approve.
account
string
The address of the account to which the minted token will be issued.
amount
BigNumber | string | number
The amount of 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.
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.
amount
BigNumber | string | number
The amount of token to be destroyed.
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
토큰을 소유한 계정 주소입니다. 이 계정 주소 잔액에서 allowance(kip7Instance. approve)를 사용해 토큰이 제거됩니다.
amount
BigNumber | string | number
The amount of token to be destroyed.
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.
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.