Account Update
sendTransaction (ACCOUNT_UPDATE)
Sends an Account Update transaction to the network.
Parameters
The parameters of sendTransaction are a transaction object and a callback function.
transactionObject
Object
The transaction object to send.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
A transaction object of type ACCOUNT_UPDATE
has the following structure: Note that when you provide the new key, you should provide just one of the below depending on the key type. If more than one are given, you will receive a 'duplicated key' error. From caver-js v1.2.0, using key
with AccountForUpdate
instance is recommended.
key
legacyKey
publicKey
multisig
roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey
failKey
type
String
Transaction type. "ACCOUNT_UPDATE"
from
String
Address of this transaction sender. This account will be updated by this transaction.
gas
Number
The maximum amount of gas willing to pay for the transaction (unused gas is refunded).
gasPrice
Number
(optional) Gas price provided by the sender in peb. The gasPrice must be the same as the unitPrice set in the Klaytn node.
nonce
Number
(optional) Integer of a nonce. If omitted, it will be set by caver-js via calling caver.klay.getTransactionCount
.
key
Object
(optional) An AccountForUpdate
instance containing the address and key to be used when updating the account. For instructions on how to create an AccountForUpdate instance for each key type, see caver.klay.accounts.createAccountForUpdate.
legacyKey
Bool
(optional) if updating the account to have a legacy key, set this true.
publicKey
String
(optional) if updating the account to have a public key, write down the 64 bytes public key.
multisig
Object
(optional) if updating the account to have a multisig key, write down the list of weighted public keys that make up the multisig. multisig also defines the threshold. When signing a transaction, the sum of the weights of the signatures must be larger than or equal to the threshold.
roleTransactionKey
Object
(optional) if updating the account to have a role-based key, write down roleTransactionKey. roleTransactionKey can be a public key or a multisig key. This roleTransactionKey will be used when signing a transaction.
roleAccountUpdateKey
Object
(optional) if updating the account to have a role-based key, write down roleAccountUpdateKey. roleAccountUpdateKey can be a public key or a multisig key. This roleAccountUpdateKey will be used when signing an AccountUpdate transaction.
roleFeePayerKey
Object
(optional) if updating the account to have a role-based key, write down roleFeePayerKey. roleFeePayerKey can be a public key or a multisig key. This roleFeePayerKey will be used when signing a transaction as a feePayer.
failKey
Bool
(optional) if updating the account to have a fail key, set this true.
If you call caver.klay.sendTransaction
with a transaction object of type ACCOUNT_UPDATE
as in the above, caver-js will send it to the network after signing with the key of the sender account (from
) inside the in-memory wallet.
Return Value
The callback
will return the 32-byte transaction hash.
PromiEvent
: A promise combined event emitter. Will be resolved when the transaction receipt is available. Additionally the following events are available:
"transactionHash"
returnsString
: Is fired right after the transaction is sent and a transaction hash is available."receipt"
returnsObject
: Is fired when the transaction receipt is available."error"
returnsError
: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
Example
sendTransaction (FEE_DELEGATED_ACCOUNT_UPDATE)
Sends a Fee Delegated Account Update transaction to the network.
There are two ways for a fee payer to sign a transaction and send it to the network.
Call
caver.klay.sendTransaction
with an object,{senderRawTransaction: rawTransaction, feePayer: feePayerAddress}
, a transaction format used for fee payers. In this case, the fee payer account must exist in the in-memory caver-js wallet.Sign with caver.klay.accounts.feePayerSignTransaction and send to network via caver.klay.sendSignedTransaction
The example here only describes how to use caver.klay.sendTransaction
.
For information on how to send using caver.klay.accounts.feePayerSignTransaction
and caver.klay.sendSignedTransaction
, see caver.klay.accounts.feePayerSignTransaction and Sending a Transaction with multiple signer.
Parameters
The parameters of sendTransaction are a transaction object and a callback function.
transactionObject
Object
The transaction object to send.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
A transaction object of type FEE_DELEGATED_ACCOUNT_UPDATE
has the following structure:
type
String
Transaction Type. "FEE_DELEGATED_ACCOUNT_UPDATE"
from
String
Address of this transaction sender. This account will be updated by this transaction.
gas
Number
The maximum amount of gas willing to pay for the transaction (unused gas is refunded).
gasPrice
Number
(optional) Gas price provided by the sender in peb. The gasPrice must be the same as the unitPrice set in the Klaytn node.
nonce
Number
(optional) Integer of a nonce. If omitted, it will be set by caver-js via calling caver.klay.getTransactionCount
.
key
Object
(optional) An AccountForUpdate
instance containing the address and key to be used when updating the account. For instructions on how to create an AccountForUpdate instance for each key type, see caver.klay.accounts.createAccountForUpdate.
legacyKey
Bool
(optional) if updating the account to have a legacy key, set this true.
publicKey
String
(optional) if updating the account to have a public key, write down the 64 bytes public key.
multisig
Object
(optional) if updating the account to have a multisig key, write down the list of weighted public keys that make up the multisig. multisig also defines the threshold. When signing a transaction, the sum of the weights of the signatures must be larger than or equal to the threshold.
roleTransactionKey
Object
(optional) if updating the account to have a role-based key, write down roleTransactionKey. roleTransactionKey can be a public key or a multisig key. This roleTransactionKey will be used when signing a transaction.
roleAccountUpdateKey
Object
(optional) if updating the account to have a role-based key, write down roleAccountUpdateKey. roleAccountUpdateKey can be a public key or a multisig key. This roleAccountUpdateKey will be used when signing an AccountUpdate transaction.
roleFeePayerKey
Object
(optional) if updating the account to have a role-based key, write down roleFeePayerKey. roleFeePayerKey can be a public key or a multisig key. This roleFeePayerKey will be used when signing a transaction as a feePayer.
failKey
Bool
(optional) if updating the account to have a fail key, set this true.
A transaction object of type FEE_DELEGATED_ACCOUNT_UPDATE
with the above structure or an RLP-encoded transaction
of type FEE_DELEGATED_ACCOUNT_UPDATE
can be used as a parameter in caver.klay.accounts.signTransaction for sender and in caver.klay.accounts.feePayerSignTransaction for fee payer.
In order for the fee payer to sign an RLP encoded transaction signed by the sender and send it to the network, define an object with the following structure and call caver.klay.sendTransaction
.
feePayer
String
The fee payer address of the transaction.
senderRawTransaction
String
The RLP-encoded transaction signed by sender.
Return Value
The callback
will return the 32-byte transaction hash.
PromiEvent
: A promise combined event emitter. Will be resolved when the transaction receipt is available. Additionally the following events are available:
"transactionHash"
returnsString
: Is fired right after the transaction is sent and a transaction hash is available."receipt"
returnsObject
: Is fired when the transaction receipt is available."error"
returnsError
: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
Example
sendTransaction (FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO)
Sends a Fee Delegated Account Update With Ratio transaction to the network.
There are in two ways fee payer sign a transaction and send it to the network.
Call
caver.klay.sendTransaction
with fee payer transaction format (An object that definessenderRawTransaction
andfeepayer
). In this case, a fee payer account must exist in the in-memory wallet of caver-js.Sign with caver.klay.accounts.feePayerSignTransaction and send to network via caver.klay.sendSignedTransaction
The example here only describes how to use caver.klay.sendTransaction
.
For information on how to send using caver.klay.accounts.feePayerSignTransaction
and caver.klay.sendSignedTransaction
, see caver.klay.accounts.feePayerSignTransaction and Sending a Transaction with multiple signer.
Parameters
The parameters of sendTransaction are transaction object and callback function.
transactionObject
Object
The transaction object to send.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
The plain transaction object type of a FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO
transaction has the following structure:
type
String
The type of "FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO" transaction.
from
String
Address of this transaction sender. This account will be updated by this transaction.
gas
Number
The maximum amount of gas willing to pay for the transaction (unused gas is refunded).
gasPrice
Number
(optional) Gas price provided by the sender in peb. The gasPrice must be the same as the unitPrice set in the Klaytn node.
nonce
Number
(optional) Integer of a nonce. If omitted, it will be set by caver-js via calling caver.klay.getTransactionCount
.
key
Object
(optional) An AccountForUpdate
instance containing the address and key to be used when updating the account. For instructions on how to create an AccountForUpdate instance for each key type, see caver.klay.accounts.createAccountForUpdate.
legacyKey
Bool
(optional) if updating the account to have a legacy key, set this true.
publicKey
String
(optional) if updating the account to have a public key, write down the 64 bytes public key.
multisig
Object
(optional) if updating the account to have a multisig key, write down the list of weighted public keys that make up the multisig. multisig also defines the threshold. When signing a transaction, the sum of the weights of the signatures must be larger than or equal to the threshold.
roleTransactionKey
Object
(optional) if updating the account to have a role-based key, write down roleTransactionKey. roleTransactionKey can be a public key or a multisig key. This roleTransactionKey will be used when signing a transaction.
roleAccountUpdateKey
Object
(optional) if updating the account to have a role-based key, write down roleAccountUpdateKey. roleAccountUpdateKey can be a public key or a multisig key. This roleAccountUpdateKey will be used when signing an AccountUpdate transaction.
roleFeePayerKey
Object
(optional) if updating the account to have a role-based key, write down roleFeePayerKey. roleFeePayerKey can be a public key or a multisig key. This roleFeePayerKey will be used when signing a transaction as a feePayer.
failKey
Bool
(optional) if updating the account to have a fail key, set this true.
A transaction object of type FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO
with the above structure or an RLP-encoded transaction
of type FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO
can be used as a parameter in caver.klay.accounts.signTransaction for sender and in caver.klay.accounts.feePayerSignTransaction for fee payer.
In order for the fee payer to sign an RLP encoded transaction signed by the sender and send it to the network, define an object with the following structure and call caver.klay.sendTransaction
.
feePayer
String
The fee payer address of the transaction.
senderRawTransaction
String
The RLP-encoded transaction signed by sender.
Return Value
The callback
will return the 32-byte transaction hash.
PromiEvent
: A promise combined event emitter. Will be resolved when the transaction receipt is available. Additionally the following events are available:
"transactionHash"
returnsString
: Is fired right after the transaction is sent and a transaction hash is available."receipt"
returnsObject
: Is fired when the transaction receipt is available."error"
returnsError
: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
Example
Last updated