Constructor
new KASWallet(walletAPI)
Creates a wallet instance that uses the KAS Wallet API.
This will be used in caver.wallet
with CaverExtKAS.
Example
caver.wallet // `caver.wallet` is the KASWallet instance.
Parameters:
Name | Type | Description |
---|---|---|
walletAPI |
Wallet | An instance of KAS Wallet api to use. |
Methods
(async) generate(numberOfAccounts) → {Array.<string>}
Generates accounts in the KAS wallet api service with randomly generated key pairs.
Example
const result = await caver.wallet.generate() // Create one account
const result = await caver.wallet.generate(3)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
numberOfAccounts |
number |
1
|
The number of accounts to create. |
Returns:
- Type
- Array.<string>
(async) getAccount(address) → {AccountCountByAccountID}
Get the account in KAS Wallet API Service corresponding to the address
Example
const result = await caver.wallet.getAccount('0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549')
Parameters:
Name | Type | Description |
---|---|---|
address |
string | The address of account to query. |
Returns:
(async) isExisted(address) → {boolean}
Returns whether the account corresponding to the address exists
Example
const result = await caver.wallet.isExisted('0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549')
Parameters:
Name | Type | Description |
---|---|---|
address |
string | The address of account to check existence. |
Returns:
- Type
- boolean
(async) remove(address) → {boolean}
Deletes the account that associates with the given address from KAS Wallet API service.
Example
const result = await caver.wallet.remove('0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549')
Parameters:
Name | Type | Description |
---|---|---|
address |
string | An address of the account to be deleted in KAS Wallet API service. |
Returns:
- Type
- boolean
(async) disableAccount(address) → {AccountSummary}
Deactivates account in KAS Wallet API Service
Example
const result = await caver.wallet.disableAccount('0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549')
Parameters:
Name | Type | Description |
---|---|---|
address |
string | The address of Klaytn account to disable from KAS Wallet API service. |
Returns:
- Type
- AccountSummary
(async) enableAccount(address) → {AccountSummary}
Activates account in KAS Wallet API Service
Example
const result = await caver.wallet.enableAccount('0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549')
Parameters:
Name | Type | Description |
---|---|---|
address |
string | The address of Klaytn account to enable from KAS Wallet API service. |
Returns:
- Type
- AccountSummary
(async) sign(address, transaction) → {AbstractTransaction}
- See:
Signs the transaction using one key and return the signed transaction
Example
const from = '0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549'
const tx = new caver.transaction.valueTransfer({
from,
to: '0x5ad2ee923fb1bf71b570d8be15b86b1ae0a7e7f3',
value: 1,
gas: 25000,
})
const result = await caver.wallet.sign(from, tx)
Parameters:
Name | Type | Description |
---|---|---|
address |
string | An address of account in KAS Wallet API Service. |
transaction |
AbstractTransaction | A transaction object of caver-js. See Klaytn Docs - Transaction for details. |
Returns:
- Type
- AbstractTransaction
(async) signAsFeePayer(address, transaction) → {AbstractFeeDelegatedTransaction}
- See:
Signs the transaction as a fee payer using one key and return the signed transaction
Example
const tx = new caver.transaction.feeDelegatedValueTransfer({
from: '0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549',
to: '0x5ad2ee923fb1bf71b570d8be15b86b1ae0a7e7f3',
value: 1,
gas: 25000,
})
const feePayer = '0x3b1522890efa7322591baa3ff126de79b9c6d009'
const result = await caver.wallet.signAsFeePayer(feePayer, tx)
Parameters:
Name | Type | Description |
---|---|---|
address |
string | An address of account in KAS Wallet API Service. |
transaction |
AbstractFeeDelegatedTransaction | A fee delegated transaction object of caver-js. See Klaytn Docs - Fee Delegation Transaction and https://docs.klaytn.com/bapp/sdk/caver-js/api-references/caver.transaction/partial-fee-delegation for details. |
Returns:
- Type
- AbstractFeeDelegatedTransaction
(async) signAsGlobalFeePayer(transaction) → {AbstractFeeDelegatedTransaction}
- See:
Signs the transaction with the global fee payer using one key and return the signed transactionHash
Example
const tx = new caver.transaction.feeDelegatedValueTransfer({
from: '0x3ee2ef77ad56ade0b86fcc3bccc7f278f9983549',
to: '0x5ad2ee923fb1bf71b570d8be15b86b1ae0a7e7f3',
value: 1,
gas: 25000,
})
const result = await caver.wallet.signAsGlobalFeePayer(tx)
Parameters:
Name | Type | Description |
---|---|---|
transaction |
AbstractFeeDelegatedTransaction | A fee delegated transaction object of caver-js. See Klaytn Docs - Fee Delegation Transaction and Klaytn Docs - Partial Fee Delegation Transaction for details. |
Returns:
- Type
- AbstractFeeDelegatedTransaction