Constructor
new KIP37(client, accessOptions)
Creates an instance of KIP37 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
kip37ContractApi :Kip37ContractApi
Type:
deployerApi :Kip37DeployerApi
Type:
tokenApi :Kip37TokenApi
Type:
tokenOwnershipApi :Kip37TokenOwnershipApi
Type:
Methods
deploy(uri, alias, optionsopt, callbackopt) → {Kip37DeployResponse}
Deploys KIP-37 token contract with a Klaytn account in KAS.
POST /v1/contract
Example
const ret = await caver.kas.kip37.deploy('https://caver.example/id/{id}.json', 'jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
uri |
string | The URI for all token types, by relying on the token type ID substitution mechanism. |
|
alias |
string | The alias of KIP-37 token. Your |
|
options |
KIP37FeePayerOptions | object |
<optional> |
Options for paying the transaction fee. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
- Type
- Kip37DeployResponse
importContract(address, uri, alias, optionsopt, callbackopt) → {Kip37Contract}
Imports a contract that has already been deployed.
POST /v1/contract/import
Example
const ret = await caver.kas.kip37.importContract('0x{address in hex}', 'https://caver.example/id/{id}.json', 'jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
address |
string | The contract address to import to the KAS KIP-37 API service. |
|
uri |
string | The URI for all token types, by relying on the token type ID substitution mechanism. |
|
alias |
string | The alias of KIP-37 token. Your |
|
options |
KIP37FeePayerOptions | object |
<optional> |
Options for paying the transaction fee. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
- Type
- Kip37Contract
updateContractOptions(addressOrAlias, optionsopt, callbackopt) → {Kip37Contract}
Edits the information of a contract.
PUT /v1/contract/{contract-address-or-alias}
Example
const ret = await caver.kas.kip37.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 |
KIP37FeePayerOptions | object |
<optional> |
Options for paying the transaction fee. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
- Type
- Kip37Contract
getContract(addressOrAlias, callbackopt) → {Kip37Contract}
Retrieves KIP-37 contract information by either contract address or alias.
GET /v1/contract/{contract-address-or-alias}
Example
// with contract address
const ret = await caver.kas.kip37.getContract('0x{address in hex}')
// with contract alias
const ret = await caver.kas.kip37.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:
- Type
- Kip37Contract
getContractList(queryOptionsopt, callbackopt) → {Kip37ContractListResponse}
Searches the list of deployed KIP-37 contracts using the Klaytn account in KAS.
GET /v1/contract
Example
// without query parameter
const ret = await caver.kas.kip37.getContractList()
// with query parameter
const ret = await caver.kas.kip37.getContractList({
size: 1,
cursor: 'eyJjc...',
status: caver.kas.kip37.queryOptions.status.ALL
})
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
queryOptions |
KIP37QueryOptions |
<optional> |
Filters required when retrieving data. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
getTokenListByOwner(addressOrAlias, owner, queryOptionsopt, callbackopt) → {Kip37TokenListResponse}
Returns a list of tokens owned by a certain account.
GET /v1/contract/{contract-address-or-alias}/owner/{owner-address}/token
Example
// without query parameter
const ret = await caver.kas.kip37.getTokenListByOwner('0x{contract address}', '0x{owner address}')
// with query parameter
const ret = await caver.kas.kip37.getTokenListByOwner('jasmine-alias', '0x{owner address}', {
size: 1,
cursor: 'eyJjc...',
})
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
owner |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
queryOptions |
KIP37QueryOptions |
<optional> |
Filters required when retrieving data. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
setApprovalForAll(addressOrAlias, from, to, approvedopt, callbackopt) → {Kip37TransactionStatusResponse}
Grants/Removes Authorization for Token Transfers.
Grants/cancels authorization to a third party (to) to transfer all tokens for a specified contract.
POST /v1/contract/{contract-address-or-alias}/approveall
Example
const from = '0x{address in hex}'
const to = '0x{address in hex}'
// with contract address
const ret = await caver.kas.kip37.setApprovalForAll('0x{contract address}', from, to, true)
// with contract alias
const ret = await caver.kas.kip37.setApprovalForAll('jasmine-alias', from, to, true)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
from |
string | The Klaytn account address of the owner. |
|
to |
string | The Klaytn account address to be authrorized for token transfer. |
|
approved |
string |
<optional> |
Authorization granted/cancelled. The default value is |
callback |
function |
<optional> |
The callback function to call. |
Returns:
pause(addressOrAlias, pauseropt, callbackopt) → {Kip37TransactionStatusResponse}
Pauses all operations for a specified contract, such as minting, transfering tokens.
You can resume using caver.kas.kip37.unpause.
POST /v1/contract/{contract-address-or-alias}/pause
Example
// with contract address
const ret = await caver.kas.kip37.pause('0x{contract address}')
// with contract alias
const ret = await caver.kas.kip37.pause('jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
pauser |
string |
<optional> |
Account to execute token operations such as pause and resume. The default value is the account that deployed the contract. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
unpause(addressOrAlias, pauseropt, callbackopt) → {Kip37TransactionStatusResponse}
Resumes the operations for a paused contract.
POST /v1/contract/{contract-address-or-alias}/unpause
Example
// with contract address
const ret = await caver.kas.kip37.unpause('0x{contract address}')
// with contract alias
const ret = await caver.kas.kip37.unpause('jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
pauser |
string |
<optional> |
Account to execute token operations such as pause and resume. The default value is the account that deployed the contract. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
pauseToken(addressOrAlias, tokenId, pauseropt, callbackopt) → {Kip37TransactionStatusResponse}
Pause the operations of a specified token, such as minting and creating tokens.
You can resume using caver.kas.kip37.unpauseToken.
POST /v1/contract/{contract-address-or-alias}/token/pause/{token-id}
Example
const tokenId = 1
// with contract address
const ret = await caver.kas.kip37.pauseToken('0x{contract address}', tokenId)
// with contract alias
const ret = await caver.kas.kip37.pauseToken('jasmine-alias', tokenId, '0x{address in hex}')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
tokenId |
string | number | ID of the token to pause. |
|
pauser |
string |
<optional> |
Account to execute token operations such as pause and resume. The default value is the account that deployed the contract. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
unpauseToken(addressOrAlias, tokenId, pauseropt, callbackopt) → {Kip37TransactionStatusResponse}
Resume paused token operations for a given contract.
POST /v1/contract/{contract-address-or-alias}/token/unpause/{token-id}
Example
// with contract address
const ret = await caver.kas.kip37.unpauseToken('0x{contract address}')
// with contract alias
const ret = await caver.kas.kip37.unpauseToken('jasmine-alias')
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
tokenId |
string | number | ID of the token to resume. |
|
pauser |
string |
<optional> |
Account to execute token operations such as pause and resume. The default value is the account that deployed the contract. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
create(addressOrAlias, id, initialSupply, uri, senderopt, callbackopt) → {Kip37TransactionStatusResponse}
Creates a new token from a specified KIP-37 contract.
POST /v1/contract/{contract-address-or-alias}/token
Example
const sender = '0x{address in hex}'
const id = '0x1'
const initialSupply = '0x100'
const uri = 'https://token-cdn-domain/1.json'
// with contract address
const ret = await caver.kas.kip37.create('0x{contract address}', id, initialSupply, uri)
const ret = await caver.kas.kip37.create('0x{contract address}', id, initialSupply, uri, sender)
// with contract alias
const ret = await caver.kas.kip37.create('jasmine-alias', id, initialSupply, uri)
const ret = await caver.kas.kip37.create('jasmine-alias', id, initialSupply, uri, sender)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
id |
string | number | ID of the new token; cannot use an existing one. |
|
initialSupply |
string | number | BigNumber | Initial supply of the token. |
|
uri |
string | Token URI. |
|
sender |
string |
<optional> |
The Klaytn account address to mint the token. The default value is the address that deployed the contract. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
getTokenList(addressOrAlias, queryOptionsopt, callbackopt) → {Kip37TokenInfoListResponse}
Returns a list of KIP-37 tokens.
GET /v1/contract/{contract-address-or-alias}/token
Example
// without query parameter
const ret = await caver.kas.kip37.getTokenList('0x{contract address}')
// with query parameter
const ret = await caver.kas.kip37.getTokenList('jasmine-alias', {
size: 1,
cursor: 'eyJjc...',
})
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
queryOptions |
KIP37QueryOptions |
<optional> |
Filters required when retrieving data. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
burn(addressOrAlias, ids, amounts, fromopt, callbackopt) → {Kip37TransactionStatusResponse}
Burns KIP-37 tokens.
DELETE /v1/contract/{contract-address-or-alias}/token
Example
const from = '0x{address in hex}'
const ids = [ 0, 1, 2 ]
const amounts = [ 10, 20, 30 ]
// with contract address
const ret = await caver.kas.kip37.burn('0x{contract address}', ids, amounts)
// with contract alias
const ret = await caver.kas.kip37.burn('jasmine-alias', ids, amounts, from)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
ids |
string | number | Array.<(string|number)> | IDs of the token to burn. |
|
amounts |
string | number | BigNumber | Array.<(string|number|BigNumber)> | Number of the token to burn. |
|
from |
string |
<optional> |
The owner of the token or the Klaytn account address authorized to burn. The default value is the address that deployed the contract. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
mint(addressOrAlias, to, ids, amounts, senderopt, callbackopt) → {Kip37TransactionStatusResponse}
Mints multiple tokens for a given KIP-37 contract.
Minting is possible after having created a token with caver.kct.kip37.create.
POST /v1/contract/{contract-address-or-alias}/token/mint
Example
const from = '0x{address in hex}'
const to = '0x{address in hex}'
const ids = [ 0, 1, 2 ]
const amounts = [ 10, 20, 30 ]
// with contract address
const ret = await caver.kas.kip37.mint('0x{contract address}', to, ids, amounts)
// with contract alias
const ret = await caver.kas.kip37.mint('jasmine-alias', to, ids, amounts, from)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
to |
string | The Klaytn account address of the token owner. |
|
ids |
string | number | Array.<(string|number)> | Array of the new token IDs. |
|
amounts |
string | number | BigNumber | Array.<(string|number|BigNumber)> | Array of the new token supplies. |
|
sender |
string |
<optional> |
The Klaytn account address to mint tokens. The default value is the address that deployed the contract. |
callback |
function |
<optional> |
The callback function to call. |
Returns:
transfer(addressOrAlias, sender, owner, to, ids, amounts, callbackopt) → {Kip37TransactionStatusResponse}
Sends multiple tokens for a given KIP-37 contract.
POST /v1/contract/{contract-address-or-alias}/token/transfer
Example
const sender = '0x{address in hex}'
const owner = '0x{address in hex}'
const to = '0x{address in hex}'
const ids = [ 0, 1, 2 ]
const amounts = [ 10, 20, 30 ]
// with contract address
const ret = await caver.kas.kip37.transfer('0x{contract address}', sender, owner, to, ids, amounts)
// with contract alias
const ret = await caver.kas.kip37.transfer('jasmine-alias', sender, owner, to, ids, amounts)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
addressOrAlias |
string | Contract address (in hexadecimal with the 0x prefix) or an alias. |
|
sender |
string | The Klaytn account address to send the tokens. |
|
owner |
string | The Klaytn account address that owns the tokens. |
|
to |
string | The Klaytn account address to receive the tokens. |
|
ids |
string | number | Array.<(string|number)> | Array of IDs of the tokens to send. |
|
amounts |
string | number | BigNumber | Array.<(string|number|BigNumber)> | Array of the tokens to send. |
|
callback |
function |
<optional> |
The callback function to call. |
Returns:
getDeployer(callbackopt) → {Kip37DeployerResponse}
Queries the account that deploys and manages the KIP-37 contracts.
GET /v1/deployer/default
Example
const ret = await caver.kas.kip37.getDeployer()
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
function |
<optional> |
The callback function to call. |