caver.account
caver.account
is a package that provides functionality related to Account that is used when updating an account.
Class
Account
Account
is a class that contains information needed to update the AccountKey of the account in the Klaytn blockchain platform (Klaytn). This is the default class for the caver.account
package. To create an Account instance with public key string(s), please refer to caver.account.create.
properties
address
string
The address of account to be updated.
accountKey
object
The new accountKey to be used in account. This can be an instance of AccountKeyLegacy, AccountKeyPublic, AccountKeyFail, AccountKeyWeightedMultiSig or AccountKeyRoleBased. When the transaction is executed, the accountKey of the account stored in the Klaytn is changed to this.
AccountKeyLegacy
AccountKeyLegacy
is used to update the AccountKey of an account in the Klaytn with AccountKeyLegacy. To create an Account instance with AccountKeyLegacy
, please refer to caver.account.createWithAccountKeyLegacy.
AccountKeyPublic
AccountKeyPublic
is used to update the AccountKey of an account in the Klaytn with AccountKeyPublic. By updating AccountKey to AccountKeyPublic
, you can change your existing AccountKey into the new public key, which will be used to validate a transaction in Klaytn. This change is necessary when you decouple your private key from the address of your account. See AccountUpdate and AccountKey for details.
To create an Account instance with AccountKeyPublic
, please refer to caver.account.create or caver.account.createWithAccountKeyPublic.
properties
publicKey
string
The public key string.
AccountKeyFail
AccountKeyFail
is used to update AccountKey of an account in the Klaytn with AccountKeyFail. To create an Account instance with AccountKeyFail
, please refer to caver.account.createWithAccountKeyFail.
AccountKeyWeightedMultiSig
AccountKeyWeightedMultiSig
is used to update AccountKey of an account in the Klaytn with AccountKeyWeightedMultiSig. By updating your AccountKey to AccountKeyWeightedMultiSig
, you can change your existing AccountKey into the new public key, which will be used to validate a transaction in Klaytn. This change is necessary when you decouple your private key from the address of your account. See AccountUpdate and AccountKey for details.
To create an Account instance with AccountKeyWeightedMultiSig
, please refer to caver.account.create or caver.account.createWithAccountKeyWeightedMultiSig.
properties
threshold
number
The validation threshold.
AccountKeyRoleBased
AccountKeyRoleBased
is used to update AccountKey of an account in the Klaytn with AccountKeyRoleBased. By updating your AccountKey to AccountKeyRoleBased
, you can change the AccountKey(s) assigned for each role, all of which are used to validate a transaction in Klaytn. See AccountUpdate and AccountKey for more details.
To create an Account instance with AccountKeyRoleBased
, please refer to caver.account.create or caver.account.createWithAccountKeyRoleBased.
properties
accountKeyArray
Array
The array defining accountKey to be used for each role. Each role can be defined with AccountKeyLegacy, AccountKeyPublic, AccountKeyFail, or AccountKeyWeightedMultiSig.
WeightedPublicKey
WeightedPublicKey
contains a public key and its weight. WeightedPublicKey
is a class that contains the public key and the weight of the key, and it is used in AccountKeyWeightedMultiSig.
properties
weight
number
The weight of public key. The weight is used to check whether the weighted sum of public keys is larger than the threshold of the AccountKeyWeightedMultiSig object.
publicKey
string
The public key string.
WeightedMultiSigOptions
WeightedMultiSigOptions
contains a threshold and weights. WeightedMultiSigOptions
is a class for defining the options of AccountKeyWeightedMultiSig.
properties
threshold
number
The validation threshold.
weights
Array
An array of weights of keys.
caver.account.create
Generates an Account instance with an address and an accountKey.
If accountKey is a public key string, an Account instance with AccountKeyPublic as accountKey is created. If accountKey is an array containing public key strings, an Account instance with AccountKeyWeightedMultiSig as accountKey is created. If options are not defined as the last parameter, it is created using a default option with a threshold of 1 and a weight of 1 for each key. If accountKey is an array containing accountKeys that are used for each role, an Account instance with AccountKeyRoleBased is created. Options must be defined for each role with WeightedMultiSigOptions. If options are not defined, the default option is used for roles that use multiple public keys. Please refer to the example below for how to use it.
Parameters
address
string
The address of account to be updated.
accountKey
string | Array
A public key string, an array of public keys, or a 2D array of which each element contains an array of key(s) to be used for each role.
Return Value
The account instance is returned.
Example
caver.account.createFromRLPEncoding
Creates an Account instance from RLP-encoded AccountKey.
Parameters
address
string
The address of an account to be updated.
rlpEncodedKey
string
The RLP-encoded string of AccountKey.
Return Value
The account instance is returned.
Example
caver.account.createWithAccountKeyLegacy
Creates an Account instance which has AccountKeyLegacy as an accountKey.
Parameters
address
string
The address of an account to be updated.
Return Value
The account instance is returned.
Example
caver.account.createWithAccountKeyPublic
Creates an Account instance which has AccountKeyPublic as an accountKey.
Parameters
address
string
The address of an account to be updated.
publicKey
string
The public key string.
Return Value
The account instance is returned.
Example
caver.account.createWithAccountKeyFail
Creates an Account instance which has AccountKeyFail as an accountKey.
Parameters
address
string
The address of an account to be updated.
Return Value
The account instance is returned.
Example
caver.account.createWithAccountKeyWeightedMultiSig
Creates an Account instance which has AccountKeyWeightedMultiSig as an accountKey.
Parameters
address
string
The address of an account to be updated.
publicKeyArray
Array
The array that includes multiple public key strings.
options
(optional) The WeightedMultiSigOptions instance that defines threshold and weight array.
Return Value
The account instance is returned.
Example
caver.account.createWithAccountKeyRoleBased
Creates an Account instance which has AccountKeyRoleBased as an accountKey.
Parameters
address
string
The address of an account to be updated.
roledBasedPublicKeyArray
Array
A two-dimensional array containing arrays of public key strings for each role.
Return Value
The account instance is returned.
Example
caver.account.accountKey.decode
Decodes an RLP-encoded string of AccountKey and returns an AccountKeyLegacy, AccountKeyPublic, AccountKeyFail, AccountKeyWeightedMultiSig or AccountKeyRoleBased instance.
Parameters
rlpEncodedAccountKey
string
An RLP-encoded string of AccountKey.
Return Value
The AccountKey instance is returned.
Example
account.getRLPEncodingAccountKey
Return RLP-encoded string of AccountKey.
Return Value
string
A RLP-encoded string of AccountKey .
Example
Last updated