Legacy
sendTransaction (Legacy)
Sends a transaction to the network.
Note: Only the account having AccountKeyLegacy
can send this transaction.
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 LEGACY
has the following structure:
from
String
Address of this transaction sender.
to
String
(optional) The destination address of the message, left undefined for a contract-creation transaction.
value
Number | String | BN | BigNumber
(optional) The value transferred for the transaction in peb, also the endowment if it's a contract-creation 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.
data
String
(optional) Either an ABI byte string containing the data of the function call on a contract, or in the case of a contract-creation transaction the initialization code.
nonce
Number
(optional) Integer of a nonce. If omitted, it will be set by caver-js via calling caver.klay.getTransactionCount
.
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