Constructor
new KIP7(client, accessOptions)
Creates an instance of KIP7 api.
Parameters:
| Name | Type | Description |
|---|---|---|
client |
ApiClient | The Api client to use to connect with KAS. |
accessOptions |
AccessOptions | An instance of AccessOptions including |
Members
auth :string
Type:
- string
accessKeyId :string
Type:
- string
secretAccessKey :string
Type:
- string
chainId :string
Type:
- string
accessOptions :AccessOptions
Type:
apiInstances :object
Type:
- object
client :object
Type:
- object
kip7ContractApi :Kip7ContractApi
Type:
kip7TokenApi :Kip7TokenApi
Type:
deployerApi :Kip7DeployerApi
Type:
Methods
deploy(name, symbol, decimals, initialSupply, alias, optionsopt, callbackopt) → {Kip7DeployResponse}
Deploy KIP-7 token contract with a Klaytn account in KAS.
POST /v1/contract
Example
const ret = await caver.kas.kip7.deploy('Jasmine', 'JAS', 18, '1000000000000000000', 'jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | The name of KIP-7 token. |
|
symbol |
string | The symbol of KIP-7 token. |
|
decimals |
number | The number of decimal places the token uses. |
|
initialSupply |
string | number | BigNumber | The total amount of token to be supplied initially. |
|
alias |
string | The alias of KIP-7 token. Your |
|
options |
KIP7FeePayerOptions | object |
<optional> |
Options for paying the transaction fee. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
- Type
- Kip7DeployResponse
updateContractOptions(addressOrAlias, optionsopt, callbackopt) → {Kip7ContractMetadataResponse}
Edits the information of a contract.
PUT /v1/contract/{contract-address-or-alias}
Example
const ret = await caver.kas.kip7.updateContractOptions('0x{address in hex}', { enableGlobalFeePayer: true })
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
options |
KIP7FeePayerOptions | object |
<optional> |
Options for paying the transaction fee. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
getContract(addressOrAlias, callbackopt) → {Kip7ContractMetadataResponse}
Retrieves KIP-7 contract information by either contract address or alias.
GET /v1/contract/{contract-address-or-alias}
Example
// with contract address
const ret = await caver.kas.kip7.getContract('0x{address in hex}')
// with contract alias
const ret = await caver.kas.kip7.getContract('jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
getContractList(queryOptionsopt, callbackopt) → {Kip7ContractListResponse}
Search the list of deployed KIP-7 contracts using the Klaytn account in KAS.
GET /v1/contract
Example
// without query parameter
const ret = await caver.kas.kip7.getContractList()
// with query parameter
const ret = await caver.kas.kip7.getContractList({
size: 1,
cursor: 'eyJjc...',
status: caver.kas.kip7.queryOptions.status.ALL
})
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
queryOptions |
KIP7QueryOptions |
<optional> |
Filters required when retrieving data. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
allowance(addressOrAlias, owner, spender, callbackopt) → {Kip7TokenBalanceResponse}
Shows the amount of tokens approved to the spender by the owner.
GET /v1/contract/{contract-address-or-alias}/account/{owner}/allowance/{spender}
Example
const owner = '0x{address in hex}'
const spender = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.allowance('0x{contract address}', owner, spender)
// with contract alias
const ret = await caver.kas.kip7.allowance('jasmine-alias', owner, spender)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
owner |
string | Token owner's Klaytn account address. |
|
spender |
string | Klaytn account address to search the amount of tokens approved by the owner. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
balance(addressOrAlias, owner, callbackopt) → {Kip7TokenBalanceResponse}
Shows the {owner}'s balance for the given KIP-7 contract.
GET /v1/contract/{contract-address-or-alias}/account/{owner}/balance
Example
const owner = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.allowance('0x{contract address}', owner)
// with contract alias
const ret = await caver.kas.kip7.allowance('jasmine-alias', owner)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
owner |
string | Token owner's Klaytn account address. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
approve(addressOrAlias, owneropt, spender, amount, callbackopt) → {Kip7TransactionStatusResponse}
Authorizes the spender to send a certain amount of tokens on behalf of the owner.
POST /v1/contract/{contract-address-or-alias}/approve
Example
const owner = '0x{address in hex}'
const spender = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.approve('0x{contract address}', owner, spender, 10)
// with contract alias
const ret = await caver.kas.kip7.approve('jasmine-alias', owner, spender, '0x1')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
owner |
string |
<optional> |
Klaytn account address of the owner delegating the token tranfer. The default is the contract deployer account. |
spender |
string | Klaytn account address to approve delegated token transfer. |
|
amount |
string | number | BigNumber | Klaytn account address to approve delegated token transfer. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
transfer(addressOrAlias, fromopt, to, amount, callbackopt) → {Kip7TransactionStatusResponse}
Sends tokens of the contract.
POST /v1/contract/{contract-address-or-alias}/transfer
Example
const from = '0x{address in hex}'
const to = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.transfer('0x{contract address}', from, to, 10)
// with contract alias
const ret = await caver.kas.kip7.transfer('jasmine-alias', from, to, '0x1')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
from |
string |
<optional> |
Token owner's Klaytn account address. The default value is the contract deployer account. |
to |
string | Klaytn account address to receive tokens. |
|
amount |
string | number | BigNumber | Transfer amount. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
transferFrom(addressOrAlias, spender, owner, to, amount, callbackopt) → {Kip7TransactionStatusResponse}
Sends tokens on behalf of the owner.
You need to approve token transfers via caver.kas.kip7.approve.
POST /v1/contract/{contract-address-or-alias}/transfer-from
Example
const spender = '0x{address in hex}'
const owner = '0x{address in hex}'
const to = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.transferFrom('0x{contract address}', spender, owner, to, 10)
// with contract alias
const ret = await caver.kas.kip7.transferFrom('jasmine-alias', spender, owner, to, '0x1')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
spender |
string | Klaytn account address to send tokens by delegated token. |
|
owner |
string | Klaytn account address of the owner delegating the token transfer. |
|
to |
string | Klaytn account address to receive tokens. |
|
amount |
string | number | BigNumber | Transfer amount. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
mint(addressOrAlias, to, amount, minteropt, callbackopt) → {Kip7TransactionStatusResponse}
Mints a new token for a given user.
POST /v1/contract/{contract-address-or-alias}/mint
Example
const to = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.mint('0x{contract address}', to, 10)
// with contract alias
const ret = await caver.kas.kip7.mint('jasmine-alias', to, '0x1')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
to |
string | Klaytn account address to receive the newly created token. |
|
amount |
string | number | BigNumber | Amount of tokens to create. |
|
minter |
string |
<optional> |
The Klaytn account address to mint the tokens. The default value is the |
callback |
function |
<optional> |
The callback function to call. |
Returns:
burn(addressOrAlias, fromopt, amount, callbackopt) → {Kip7TransactionStatusResponse}
Burns tokens.
POST /v1/contract/{contract-address-or-alias}/burn
Example
const from = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.burn('0x{contract address}', from, 10)
// with contract alias
const ret = await caver.kas.kip7.burn('jasmine-alias', from, '0x1')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
from |
string |
<optional> |
Klaytn account address on which the tokens will be burned. The default value is the contract deployer account. |
amount |
string | number | BigNumber | The amount of tokens to burn. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
burnFrom(addressOrAlias, spender, owner, amount, callbackopt) → {Kip7TransactionStatusResponse}
spender burns owner's tokens on the owner's behalf.
POST /v1/contract/{contract-address-or-alias}/burn-from
Example
const spender = '0x{address in hex}'
const owner = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip7.burnFrom('0x{contract address}', spender, owner, 10)
// with contract alias
const ret = await caver.kas.kip7.burnFrom('jasmine-alias', spender, owner, '0x1')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
spender |
string | Klaytn account address on which the tokens will be burned. |
|
owner |
string | Klaytn account address of the owner of the tokens to be burned. |
|
amount |
string | number | BigNumber | The amount of tokens to burn. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
pause(addressOrAlias, pauseropt, callbackopt) → {Kip7TransactionStatusResponse}
Pauses all token transfers and validations for a given contract.
POST /v1/contract/{contract-address-or-alias}/pause
Example
// with contract address
const ret = await caver.kas.kip7.pause('0x{contract address}')
// with contract alias
const ret = await caver.kas.kip7.pause('jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
pauser |
string |
<optional> |
The Klaytn account address whose authority to send contracts will be removed. The default value is the |
callback |
function |
<optional> |
The callback function to call. |
Returns:
unpause(addressOrAlias, pauseropt, callbackopt) → {Kip7TransactionStatusResponse}
Resumes token transfers and validations for a given contract.
POST /v1/contract/{contract-address-or-alias}/unpause
Example
// with contract address
const ret = await caver.kas.kip7.unpause('0x{contract address}')
// with contract alias
const ret = await caver.kas.kip7.unpause('jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
pauser |
string |
<optional> |
The Klaytn account address whose authority to send contracts will be removed. The default value is the |
callback |
function |
<optional> |
The callback function to call. |
Returns:
addMinter(addressOrAlias, accountToBeMinter, minteropt, callbackopt) → {Kip7TransactionStatusResponse}
Grants a specified account the authority to mint and burn tokens from a contract.
You can remove the authority by using caver.kas.kip7.renonuceMinter.
POST v1/contract/{contract-address-or-alias}/minter
Example
const minterToBe = '0x{addree in hex}'
const minter = '0x{minter address}' // should have authority to mint
// with contract address
const ret = await caver.kas.kip7.addMinter('0x{address in hex}', minterToBe)
// with contract alias
const ret = await caver.kas.kip7.addMinter('jasmine-alias', minterToBe, minter)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
accountToBeMinter |
string | The Klaytn account address to be granted authority to mint and burn tokens. |
|
minter |
string |
<optional> |
The Klaytn account address that grants authority to mint and burn a token. The default value is the |
callback |
function |
<optional> |
The callback function to call. |
Returns:
renounceMinter(addressOrAlias, minter, callbackopt) → {Kip7TransactionStatusResponse}
Removes the authority granted to a specifed account to mint and burn tokens from a contract.
The address whose authority to mint and burn tokens will be removed.
DELETE v1/contract/{contract-address-or-alias}/minter
Example
const minter = '0x{minter address}' // should have authority to mint
// with contract address
const ret = await caver.kas.kip7.addMinter('0x{address in hex}', minter)
// with contract alias
const ret = await caver.kas.kip7.addMinter('jasmine-alias', minter)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
minter |
string | Klaytn account address that grants authority to mint and burn a token. The default value is the |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
addPauser(addressOrAlias, accountToBePauser, pauseropt, callbackopt) → {Kip7TransactionStatusResponse}
Grants a specified account the authority to pause the actions of a contract.
The actions of a contract here refer to sending tokens and sending tokens on the owner's behalf.
To remove the authority, use caver.kas.kip7.renouncePauser.
POST v1/contract/{contract-address-or-alias}/pauser
Example
const pauserToBe = '0x{addree in hex}'
const pauser = '0x{pauser address}' // should have authority to pause
// with contract address
const ret = await caver.kas.kip7.addPauser('0x{address in hex}', pauserToBe)
// with contract alias
const ret = await caver.kas.kip7.addPauser('jasmine-alias', pauserToBe, pauser)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
accountToBePauser |
string | The Klaytn account address to be granted authority to send and pause a contract. |
|
pauser |
string |
<optional> |
The Klaytn account address that grants to be granted authority to send and pause a contract. The default value is the |
callback |
function |
<optional> |
The callback function to call. |
Returns:
renouncePauser(addressOrAlias, pauser, callbackopt) → {Kip7TransactionStatusResponse}
Removes the authority given to a certain account to pause the actions of specified contract.
The actions of a contract here refer to sending tokens and sending tokens on the owner's behalf.
DELETE /v1/contract/{contract-address-or-alias}/pauser/{pauser-address}
Example
const pauser = '0x{pauser address}' // should have authority to pause
// with contract address
const ret = await caver.kas.kip7.renouncePauser('0x{address in hex}', pauser)
// with contract alias
const ret = await caver.kas.kip7.renouncePauser('jasmine-alias', pauser)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
pauser |
string | Klaytn account address that grants authority to mint and burn a token. The default value is the |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
getDeployer(callbackopt) → {Kip7DeployerResponse}
Queries the account that deploys and manages the KIP-7 contracts.
GET /v1/deployer/default
Example
const ret = await caver.kas.kip7.getDeployer()
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
function |
<optional> |
The callback function to call. |
Returns:
- Type
- Kip7DeployerResponse