The parameters of sendTransaction are a transaction object and a callback function.
Name
Type
Description
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 SMART_CONTRACT_DEPLOY has the following structure:
Name
Type
Description
type
String
Transaction Type. "SMART_CONTRACT_DEPLOY"
from
String
Address of this transaction sender.
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.
data
String
A bytecode of smart contract to be deployed. If you need to pass an argument to the constructor of the smart contract, you must set data in the format of "compiled byte code + arguments". If the compiled bytecode is '0x123 ... 321' and you need to pass 1 to the constructor, you must set '0x123 ... 321' + '00000000000000000000000000000000000000000000000000000000000001'. Use caver.klay.abi.encodeContractDeploy to get the encoded value of the byte code with the parameters.
value
Number | String | BN | BigNumber
The value that will be transferred to the contract with this deployment. To accept the value transfer, the contract constructor must be 'payable'. If the contract constructor is not payable, value must be zero.
codeFormat
String
(optional, default: "EVM") The code format of smart contract.
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" returns String: Is fired right after the transaction is sent and a transaction hash is available.
"receipt" returns Object: Is fired when the transaction receipt is available.
"error" returns Error: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
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.
data
String
A bytecode of smart contract to be deployed. If you need to pass an argument to the constructor of the smart contract, you must set data in the format of "compiled byte code + arguments". If the compiled bytecode is '0x123 ... 321' and you need to pass 1 to the constructor, you must set '0x123 ... 321' + '00000000000000000000000000000000000000000000000000000000000001'. Use caver.klay.abi.encodeContractDeploy to get the encoded value of the byte code with the parameters.
value
Number | String | BN | BigNumber
The value that will be transferred to the contract with this deployment. To accept the value transfer, the contract constructor must be 'payable'. If the contract constructor is not payable, value must be zero.
codeFormat
String
(optional, default: "EVM") The code format of smart contract.
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.
Name
Type
Description
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" returns String: Is fired right after the transaction is sent and a transaction hash is available.
"receipt" returns Object: Is fired when the transaction receipt is available.
"error" returns Error: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
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.
data
String
A bytecode of smart contract to be deployed. If you need to pass an argument to the constructor of the smart contract, you must set data in the format of "compiled byte code + arguments". If the compiled bytecode is '0x123 ... 321' and you need to pass 1 to the constructor, you must set '0x123 ... 321' + '00000000000000000000000000000000000000000000000000000000000001'. Use caver.klay.abi.encodeContractDeploy to get the encoded value of the byte code with the parameters.
value
Number | String | BN | BigNumber
The value that will be transferred to the contract with this deployment. To accept the value transfer, the contract constructor must be 'payable'. If the contract constructor is not payable, value must be zero.
codeFormat
String
(optional, default: "EVM") The code format of smart contract.
feeRatio
Number
Fee ratio of the fee payer. If it is 30, 30% of the fee will be paid by the fee payer. 70% will be paid by the sender. The range of fee ratio is 1 ~ 99, if it is out of range, the transaction will not be accepted.
A transaction object of type FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO with the above structure or an RLP-encoded transaction of type FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO can be used as a parameters 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.
Name
Type
Description
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" returns String: Is fired right after the transaction is sent and a transaction hash is available.
"receipt" returns Object: Is fired when the transaction receipt is available.
"error" returns Error: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.