Generates and returns an estimate of how much computation cost will be spent to execute the transaction. Klaytn limits the computation cost of a transaction to 100000000 currently not to take too much time by a single transaction. The transaction will not be added to the blockchain.
Parameters
Return Value
Promise returns Number - The amount of computation cost used.
Example
>caver.klay.estimateComputationCost({ to:'0xf796b2F18507Ec8F8C19e9F0c03092888093ebAc', data :'0xd14e62b80000000000000000000000000000000000000000000000000000000000000022' }).then(console.log);0x5773// With 'latest' block tag>caver.klay.estimateComputationCost({ to:'0xf796b2F18507Ec8F8C19e9F0c03092888093ebAc', data :'0xd14e62b80000000000000000000000000000000000000000000000000000000000000022' },'latest').then(console.log);0x5773
decodeTransaction
caver.klay.decodeTransaction(rawTransaction)
Returns a transaction object containing all decoded values from the given rawTransaction, an RLP-encoded transaction. Since all transaction types except for legacy transaction can have multiple signatures of sender and fee payer, the existing returned fields v, r, s and payerV, payerR, payerS are the 0th signature of sender and fee payer.
NOTE caver.klay.decodeTransaction is supported from v1.0.1-rc.8. To use this feature, please install v1.0.1-rc.8 or higher.
NOTE To support multiple signature, signatures and feePayerSignatures properties have been added since caver-js v1.2.0-rc.3.
Returns the information about the transaction identified by the given senderTxHash. Please note that this API returns correct result only if the indexing feature is enabled in the node by --sendertxhashindexing. Use isSenderTxHashIndexingEnabled to check if the indexing feature is enabled or not.
Parameters
Return Value
Promise returns Object - A transaction object, or null when no transaction was found:
Returns the receipt of a transaction identified by the given senderTxHash.
NOTE: The receipt is not available for pending transactions. Please note that this API returns correct result only if the indexing feature is enabled in the node by --sendertxhashindexing. This can be checked by calling isSenderTxHashIndexingEnabled.
Parameters
Return Value
Promise returns Object - A transaction receipt object, or null when no receipt was found:
Sends an already signed transaction, generated using caver.klay.accounts.signTransaction.
NOTEcaver.klay.sendSignedTransaction can accepts an object as a parameter since caver-js v1.2.0. The object should include an RLP-encoded transaction string or should be an unencoded transaction object with signatures/feePayerSignatures. You can pass the returning object from caver.klay.accounts.signTransaction, caver.klay.accounts.feePayerSignTransaction, caver.klay.accounts.getRawTransactionWithSignatures or caver.klay.accounts.combineSignatures.
Parameters
Return Value
For PromiEvent, 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.
Example
// sendSignedTransaction using promise with RLP encoded signed transaction stringcaver.klay.sendSignedTransaction('0xf867808505d21dba0083015f9094247f2b7e9a9c51ebcc9449c7d9e7575f9baac36e0180824e43a02e50f5c4d279e17a80c3fe98327de7e48878e9d8141d26759ef64adcf66e6aa0a02ae9e8beac1ba8d5d215d87c33f9e05263b0bad163706c9dd7a563ee1e028f41').then(function(receipt){
...})// sendSignedTransaction using promise with returning object from caver.klay.accounts.signTransactioncaver.klay.sendSignedTransaction({ messageHash:'0x2378aeb6439f43597e30df4937f59eb13c98e502bb03babcebb39bf602cd8d73', v:'0x4e43', r:'0x9fc6cfd3d7c35794ab373c8d7f15746f1f4fa94c80e31270eea31977f20aaa9a', s:'0x762343c55f7c1de87e5877887b9d10ed93b16666f4bdbc525aeee1f23fb53457', rawTransaction: '0xf867018505d21dba0083015f9094cdba9992ffd79b12ce68905db40bf5e873b1a43e0180824e43a09fc6cfd3d7c35794ab373c8d7f15746f1f4fa94c80e31270eea31977f20aaa9aa0762343c55f7c1de87e5877887b9d10ed93b16666f4bdbc525aeee1f23fb53457',
txHash:'0x3d598805e1565ba5c4a1d2b708aff9825562d903bef4301ef22564253c6779bf', senderTxHash:'0x3d598805e1565ba5c4a1d2b708aff9825562d903bef4301ef22564253c6779bf', signatures: ['0x4e43','0x9fc6cfd3d7c35794ab373c8d7f15746f1f4fa94c80e31270eea31977f20aaa9a','0x762343c55f7c1de87e5877887b9d10ed93b16666f4bdbc525aeee1f23fb53457', ],}).then(function(receipt){...})// sendSignedTransaction using promise with a transaction object that has signaturescaver.klay.sendSignedTransaction({ type:'LEGACY', from:'0x73647c5fd1a66fac0dbf2af2e5cc7f593a015441', to:'0x82c5b8f3ae5c08eeb64a1af0ce89cb5233b05c6c', value:'0x1', gas:'0x15f90', gasPrice:'0x5d21dba00', nonce:'0x2', signatures: ['0x4e43','0x077b0ec1dd5dd66ffbf7d779b08bed6166ec1b0269d85a3901dbfb55331216de','0x23b7565fa994ba3f88290de9b7f6b6b975f2ad9c19ce1ffc4752ecbc51b6c274', ],}).then(function(receipt){...})// sendSignedTransaction using promise with a fee delegated transaction object that has signatures and feePayerSignatures
caver.klay.sendSignedTransaction({ type:'FEE_DELEGATED_VALUE_TRANSFER', from:'0x73647c5fd1a66fac0dbf2af2e5cc7f593a015441', to:'0x73f9b11bd22fde3ec543f3fcbdc39fc40a942bf7', value:'0x1', gas:'0x15f90', gasPrice:'0x5d21dba00', chainId:'0x2710', nonce:'0x3', humanReadable:false, feePayer:'0xebcd0271c4f8d2a84a33e073a5c9bcdb6bafc556', signatures: [ ['0x4e44','0x41dfab76e0fdcdb5c4cd4dbe39861029d8c7f156f9dd10e8292625492943e689','0x789f1bfc42a96366ea0bdc6727410a661fe8300cdf57889316c25aa873a5b85c', ], ], feePayerSignatures: [ ['0x4e44','0x833031cb1d709a408f1c3b83cea88671d9d86f7550101e4e7221507a39dcd462','0x03f1d8003513b038195c6d798623d5bb132a93e7f2f0a2c302079b92858ea8e7', ], ],}).then(function(receipt){...})// sendSignedTransaction using event emitter with RLP encoded signed transaction string> caver.klay.sendSignedTransaction('0xf867068505d21dba0083015f90940fd7697a8b9a46b0f770a3986e8a10b6ad6fffe10180824e44a0e591e4cbf4bdada2e559ce5b9c7b604c50d3b1d7d5a29939091bcc8ad4208aa3a01ef917ec539aa79b32a043b452e81840ea012796895cd5925273fd8df139595f')
.on('transactionHash',function(hash){...}).on('receipt',function(receipt){...}).on('error',console.error)