caver.wallet
Last updated
Last updated
caver.wallet
is a package that manages Keyring instances in in-memory wallet. caver.wallet
accepts all SingleKeyring, MultipleKeyring, and RoleBasedKeyring, and manages them by address.
KeyringContainer
is a class that manages SingleKeyring, MultipleKeyring, and RoleBasedKeyring instances. Caver가 초기화될 때 caver.wallet
안에 KeyringContainer 인스턴스를 생성합니다. caver.wallet
를 통해 인메모리 지갑에 키링 인스턴스를 저장하고 관리할 수 있습니다.
properties
Name | Type | Description |
---|---|---|
Generates instances of SingleKeyring in the keyringContainer with randomly generated private keys.
Parameters
Name | Type | Description |
---|---|---|
Return Value
Type | Description |
---|---|
Example
주어진 파라미터로 키링 인스턴스를 생성하며 caver.wallet
에 추가한다.
If key
is a private key string, a SingleKeyring instance that uses a single private key is created. If key
is an array containing private key strings, a MultipleKeyring instance that use multiple private keys is created. If key
is a 2D array of which each element contains the private key(s) to be used for each role, a RoleBasedKeyring instance is created. 사용할 키링은 caver.wallet
에 추가해야 합니다.
Parameters
Return Value
Example
caver.wallet
안에 있는 키링을 업데이트합니다. When a new keyring
instance (SingleKeyring, MultipleKeyring or RoleBasedKeyring) is passed as a parameter, the existing keyring stored in the caver.wallet
that matches the address
property of the given keyring
instance is found and replaced with the given one. 일치하는 키링을 찾을 수 없는 경우 에러가 발생합니다.
Parameters
Return Value
Example
caver.wallet
주소에 일치하는 키링 인스턴스를 반환합니다.
Parameters
Return Value
Example
Returns true
if there is a keyring matching the address.
Parameters
Return Value
Example
Adds an instance of keyring to the caver.wallet
. If the newly given keyring has the same address with one of the keyrings that already exist in caver.wallet
, an error is returned. In this case, use updateKeyring to update the existing keyring in caver.wallet
.
Parameters
Return Value
Example
Deletes the keyring from caver.wallet
whose address matches the address of the given keyring.
Parameters
Return Value
Example
Signs the message with Klaytn-specific prefix using keyring stored in caver.wallet. 다음 메서드는 Klaytn 고유의 서명을 계산합니다.
If the user has not provided the index parameter, caver.wallet.signMessage
signs message using all the private keys used by the role. If the index parameter is given, caver.wallet.signMessage
signs message using only one private key at the given index. The role used in caver-js can be found from caver.wallet.keyring.role
.
Parameters
Return Value
반환된 객체는 다음을 포함합니다.
Example
Signs the transaction as a sender
of the transaction and appends signatures
in the transaction object using the keyring in caver.wallet
.
For Account Update transaction, use roleTransactionKey, otherwise, use roleTransactionKey. If the user has not defined an index
, caver.wallet.sign
signs the transaction using all the private keys used by the role. If index
is defined, the caver.wallet.sign
signs the transaction using only one private key at the given index.
Parameters
Return Value
Promise
returning object
: The signed transaction.
For more information about fields by transaction type, see caver.transaction.
Example
Signs the transaction as fee payer
of the transaction and appends feePayerSignatures
in the transaction object using the keyring in caver.wallet
.
For signing a transaction as a fee payer, use roleFeePayerKey. If the user has not defined an index
, caver.wallet.signAsFeePayer
signs the transaction using all the private keys used by the role. If index
is defined, the caver.wallet.signAsFeePayer
signs the transaction using only one private key at the given index.
If the transaction.feePayer
is not defined, the address of keyring which is founded from caver.wallet
is assigned.
Parameters
Return Value
Promise
returning object
: The signed transaction.
For more information about fields by transaction type, see caver.transaction.
Example
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
length
number
keyringContainer에 포함된 키링의 수입니다.
numberOfKeyrings
number
The number of SingleKeyring instances to create.
entropy
string
(선택 사항) 엔트로피를 증가시키는 임의의 문자열입니다.
Array
생성된 인스턴스의 주소를 포함하는 배열입니다.
address
string
주소 문자열입니다.
key
string \
Array
object
The keyring instance (SingleKeyring, MultipleKeyring or RoleBasedKeyring) added to caver.wallet is returned.
keyring
object
The new keyring (SingleKeyring, MultipleKeyring or RoleBasedKeyring) to be stored in caver.wallet
.
object
The updated keyring (SingleKeyring, MultipleKeyring or RoleBasedKeyring) stored in caver.wallet
.
address
string
조회할 키링의 주소입니다.
object
The found keyring instance (SingleKeyring, MultipleKeyring or RoleBasedKeyring) stored in caver.wallet
.
address
string
The address of keyring to check existence.
boolean
true
means a keyring matching with the address is existed in the caver.wallet
.
keyring
object
A keyring instance (SingleKeyring, MultipleKeyring or RoleBasedKeyring) to add to caver.wallet
.
object
The added keyring (SingleKeyring, MultipleKeyring or RoleBasedKeyring) in caver.wallet
.
address
string
An address of the keyring to be deleted in caver.wallet
.
boolean
true
if keyring is removed from caver.wallet
.
address
string
사용될 키링의 주소입니다.
message
string
서명할 메시지입니다.
role
number
키의 역할을 나타내는 숫자입니다. caver.wallet.keyring.role
를 사용할 수 있습니다.
index
number
(optional) The index of the private key you want to use. The index must be less than the length of the array of the private keys defined for each role. If an index is not defined, this method will use all the private keys.
object
서명 결과를 포함하는 객체입니다.
messageHash
string
Klaytn 고유의 접두사를 가진 메시지의 해시입니다.
signatures
Array
An array of SignatureData.
message
string
The message to sign.
address
string
An address of the keyring to be used.
transaction
object
An instance of Transaction.
index
number
(optional) The index of the private key you want to use. The index must be less than the length of the array of the private keys defined for each role. If an index is not defined, this method will use all the private keys.
hasher
function
(optional) A hash function to get the transaction hash. If hasher
is given as a parameter, it calculates the transaction hash instead of the default method for calculating transaction hash implemented in caver-js. See Basic for details about the default method for transaction hash generation.
object
서명된 트랜잭션 데이터입니다. The sign(s) is added to the transaction.signatures
.
address
string
An address of the keyring to be used.
transaction
object
An instance of FeeDelegatedTransaction.
index
number
(optional) The index of the private key you want to use. The index must be less than the length of the array of the private keys defined for each role. If an index is not defined, this method will use all the private keys.
hasher
function
(optional) A function to get the transaction hash. If hasher is defined as a parameter, this is used to get the transaction hash instead of a default implementation in caver-js.
object
A signed transaction instance. The signing result is appended to the transaction.feePayerSignatures
.