personal
APIs to manage accounts and private keys in the node.
Last updated
APIs to manage accounts and private keys in the node.
Last updated
The namespace personal
manages private keys in the key store.
Imports the given unencrypted private key (hex string without leading '0x') or a Klaytn wallet key into the key store, encrypting it with the passphrase.
Returns the address of the imported account.
Client | Method invocation |
---|---|
Parameters
Name | Type | Description |
---|---|---|
Return Value
Name | Type | Description |
---|---|---|
Example
Console
HTTP RPC
Returns all the Klaytn account addresses of all keys in the key store.
Parameters
None
Return Value
None
Example
Console
HTTP RPC
Returns a list of wallets this node manages.
Parameters
None
Return Value
Example
Console
HTTP RPC
Initiates a hardware wallet opening procedure, establishing a USB connection and attempting to authenticate via the provided passphrase.
NOTE: The method may return an extra challenge requiring a second open (e.g., the Trezor PIN matrix challenge).
Parameters
Return Value
Example
Console
HTTP RPC
Requests a HD wallet to derive a new account, optionally pinning it for later reuse.
Parameters
Return Value
Example
Console
HTTP RPC
Generates a new private key and stores it in the key store directory. The key file is encrypted with the given passphrase. Returns the address of the new account.
At the Klaytn console, newAccount
will prompt for a passphrase when it is not supplied as the argument.
Parameters
Return Value
Example
Console
The passphrase can also be supplied as a string.
HTTP RPC
Removes the private key with a given address from memory. The account can no longer be used to send transactions.
Parameters
Return Value
Example
Console
HTTP RPC
Decrypts the key with the given address from the key store.
Both passphrase and unlock duration are optional when using the JavaScript console. If the passphrase is not supplied as an argument, the console will prompt for the passphrase interactively.
The unencrypted key will be held in memory until the unlock duration expires. If the unlock duration defaults to 300 seconds. An explicit duration of zero seconds unlocks the key until the Klaytn local node exits.
The account can be used with klay_sign
and klay_sendTransaction
while it is unlocked.
Parameters
Return Value
Example
Console
Supplying the passphrase and unlock duration as arguments:
If you want to type in the passphrase and still override the default unlock duration, pass null
as the passphrase.
HTTP RPC
Replaces the encrypted key file in the key store with the given unencrypted private key (hex string without leading '0x') or a Klaytn wallet key, encrypting it with the new passphrase. It also receives the old passphrase to decrypt the old private key before replacement. If it is failed to decrypt, or can not find the matching account, it throws an error.
Returns the address of the replaced account if successful.
Parameters
Return Value
Example
Console
HTTP RPC
Validates the given passphrase and submits a TxTypeAccountUpdate transaction. The transaction object must have fields from
and key
. Other fields such as gas
, gasPrice
, and nonce
are se internally if unspecified. If the passphrase is able to decrypt the private key belonging to tx.from
and the transaction is verified, the transaction is signed and submitted onto the network. The account is not unlocked globally in the node and cannot be used in other RPC calls.
Parameters
Return Value
Example
Console
HTTP RPC
NOTE: The function klay.toPeb()
is not executable in HTTP RPC.
Validates the given passphrase and submits a TxTypeLegacy transaction. The transaction object must have from
and to
except the case of contract deployment. to
should be omitted if the transaction deploys a smart contract. If value
is not specified, it will be set to zero internally. Other fields such as gas
, gasPrice
, and nonce
are set to appropriate values internally if unspecified. If the passphrase is able to decrypt the private key belonging to tx.from
and the transaction is verified, the transaction is signed and submitted onto the network. The account is not unlocked globally in the node and cannot be used in other RPC calls.
Parameters
Return Value
Example
Console
HTTP RPC
NOTE: The function klay.toPeb()
is not executable in HTTP RPC.
Validates the given passphrase and submits a TxTypeValueTransfer transaction. The transaction object must have fields from
, to
, and value
. Other fields such as gas
, gasPrice
, and nonce
are set internally if unspecified. If the passphrase is able to decrypt the private key belonging to tx.from
and the transaction is verified, the transaction is signed and submitted onto the network. The account is not unlocked globally in the node and cannot be used in other RPC calls.
Parameters
Return Value
Example
Console
HTTP RPC
NOTE: The function klay.toPeb()
is not executable in HTTP RPC.
The sign
method calculates a Klaytn-specific signature with: sign(keccak256("\x19Klaytn Signed Message:\n" + len(message) + message)))
Adding a prefix to the message makes the calculated signature recognizable as a Klaytn-specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g., transaction) and use the signature to impersonate the victim.
See personal_ecRecover
to verify the signature.
Parameters
Return Value
Example
Console
HTTP RPC
Sets default configuration and signs the given transaction.
NOTE: Sending your account password over an unsecured HTTP RPC connection is highly unsecure. Use klay_signTransaction.
Parameters
The required parameters depend on the transaction type. Check the proper parameters in Working with Klaytn Transaction Types.
Return Value
ecRecover
returns the address associated with the private key that was used to calculate the signature in personal_sign
.
Parameters
Return Value
Example
Console
HTTP RPC
Client | Method invocation |
---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Type | Description |
---|---|
Client | Method invocation |
---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Console
personal.importRawKey(keydata, passphrase)
RPC
{"method": "personal_importRawKey", "params": [keydata, passphrase]}
keydata
string
The unencrypted private key (hex string without leading '0x') or a Klaytn wallet key.
passphrase
string
The pass phrase for encryption.
address
string
The address of the imported account.
Console
personal.listAccounts
RPC
{"method": "personal_listAccounts", "params": []}
string
The list of all the Klaytn account addresses
Console
personal.listWallets
RPC
{"method": "personal_listWallets", "params": []}
URL
string
Wallet url
Status
string
Locking status
Failure
string
Error condition
Accounts
string
The list of account addresses.
Console
personal.openWallet(url, passhrase)
RPC
{"method": "personal_openWallet", "params": [url, passphrase]}
URL
string
Wallet url
Passphrase
string
passphrase for wallet
Error
error
Error condition
Console
personal.deriveAccount(url, path, pin)
RPC
{"method": "personal_deriveAccount", "params": [url, path, pin]}
URL
string
Wallet url
path
string
derivation path
pin
boolean
optionally pinning
Account
string
The address of the new account.
Error
error
Error condition
Console
personal.newAccount(passphrase)
RPC
{"method": "personal_newAccount", "params": [passphrase]}
passphrase
string
(optional) the pass phrase used for encryption.
string
The address of the new account.
Console
personal.lockAccount(address)
RPC
{"method": "personal_lockAccount", "params": [address]}
address
string
The account address to lock.
bool
true
if the account was successfully locked, false
otherwise.
Console
personal.unlockAccount(address, passphrase, duration)
RPC
{"method": "personal_unlockAccount", "params": [address, passphrase, duration]}
address
string
The account address to unlock.
passphrase
string
the passphrase used for the encryption.
duration
int
(optional) the unlock duration (default to 300 seconds).
bool
true
if unlocked, false
otherwise
Console
personal.replaceRawKey(keydata, oldPassphrase, newPassphrase)
RPC
{"method": "personal_replaceRawKey", "params": [keydata, oldPassphrase, newPassphrase]}
keydata
string
The unencrypted private key (hex string without leading '0x') or a Klaytn wallet key.
oldPassphrase
string
The passphrase to decrypt the old private key.
newPassphrase
string
The passphrase to encrypt the new private key.
address
string
The address of the replaced account.
Console
personal.sendAccountUpdate(tx, passphrase)
RPC
{"method": "personal_sendAccountUpdate", "params": [tx, passphrase]}
tx
string
A transaction object. from
and key
must be specified.
passphrase
string
The passphrase to decrypt the private key of tx.from
.
32-byte string
a transaction hash if succeeded. Otherwise, an error is raised.
Console
personal.sendTransaction(tx, passphrase)
RPC
{"method": "personal_sendTransaction", "params": [tx, passphrase]}
tx
string
A transaction object. from
is a required field. to
, value
, gas
, gasPrice
and nonce
are optional fields.
passphrase
string
The passphrase to decrypt the private key of tx.from
.
32-byte string
a transaction hash if succeeded. Otherwise, an error is raised.
Console
personal.sendValueTransfer(tx, passphrase)
RPC
{"method": "personal_sendValueTransfer", "params": [tx, passphrase]}
tx
string
A transaction object. from
, to
, and value
must be specified.
passphrase
string
The passphrase to decrypt the private key of tx.from
.
32-byte string
a transaction hash if succeeded. Otherwise, an error is raised.
Console
personal.sign(message, account, password)
RPC
{"method": "personal_sign", "params": [message, account, password]}
message
string
A message to sign.
account
string
The account address.
password
string
The pass phrase used for signing.
string
A signature.
raw
Signed raw transaction
tx
Transaction object
password
Sender's password
Console
personal.ecRecover(message, signature)
RPC
{"method": "personal_ecRecover", "params": [message, signature]}
message
string
A message.
signature
string
The signature.
string
The account address.