A transaction object with the difference that for calls the from property is optional as well. An encoded function call must be set in the data field of the transaction object.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise returns Number - the used gas for the simulated call/transaction.
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
Name
Type
Description
callObject
Object
A transaction object with the difference that for calls the from property is optional as well. An encoded function call must be set in the data field of the transaction object.
defaultBlock
Number | String
(optional) If you don't pass this parameter, the default block set by caver.klay.defaultBlock will be used.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
프로미스는 Number를 반환합니다 - 사용된 연산 비용(Computation Cost)의 양입니다.
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)
RLP-encoded 트랜잭션인 주어진 rawTransaction의 모든 값을 디코딩한 트랜잭션 객체를 반환합니다. 레거시 트랜잭션을 제외한 모든 트랜잭션 타입이 트랜잭션 발신자와 트랜잭션 수수료 납부자의 다중 서명을 가질 수 있으므로, 기존에 리턴된 v, r, s 필드들과 payerV, payerR, payerS는 발신자외 트랜잭션 수수료 납부자의 0번째 서명입니다.
참고 caver.klay.decodeTransaction는 v1.0.1-rc.8에서 지원됩니다. 이 기능을 사용하려면 v1.0.1-rc.8 또는 그 이상을 설치하세요.
참고 다중 서명을 지원하기 위해 signatures 및 feePayerSignatures 속성이 caver-js v1.2.0-rc.3 부터 추가되었습니다.
Parameters
Name
Type
Description
rawTransaction
String
RLP 인코딩된 트랜잭션 데이터.
Return Value
Type
Description
Object
A transaction object. 반환되는 트랜잭션 객체가 가지는 속성은 트랜잭션 타입에 따라 다릅니다. 각 트랜잭션 타입의 속성은 SendTransaction을 참조하세요.
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
프로미스는 객체를 반환합니다 - 트랜잭션 객체를 반환하거나 또는 해당하는 트랜잭션을 찾을 수 없는 경우 null을 반환합니다.
Name
Type
Description
blockHash
32-byte DATA
Hash of the block where this transaction was in. null when it is pending.
blockNumber
QUANTITY
Block number where this transaction was in. null when it is pending.
codeFormat
String
(optional) The code format of smart contract code.
feePayer
20-byte DATA
(optional) Address of the fee payer.
feePayerSignatures
Array
(optional) An array of fee payer's signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
feeRatio
QUANTITY
(optional) 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.
from
20-byte DATA
Address of the sender.
gas
QUANTITY
Gas provided by the sender.
gasPrice
QUANTITY
Gas price provided by the sender in peb.
hash
32-byte DATA
Hash of the transaction.
humanReadable
Boolean
(optional) true if the address is humanReadable, false if the address is not humanReadable.
key
String
(optional) Key of the newly created account.
input
DATA
(optional) The data sent along with the transaction.
nonce
QUANTITY
The number of transactions made by the sender prior to this one.
senderTxHash
32-byte DATA
(optional) Hash of the tx without the fee payer's address and signature. 이 값은 수수료를 위임하지 않은 트랜잭션의 hash 값과 항상 동일합니다.
signatures
Array
An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
to
20-byte DATA
Address of the receiver. null when it is a contract creation transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block. null when it is pending.
type
String
A string representing the type of the transaction.
typeInt
QUANTITY
An integer representing the type of the transaction.
주어진 senderTxHash에 대응하는 트랜잭션의 정보를 반환합니다. 이 API는 --sendertxhashindexing에 의해 인덱싱 기능이 노드에서 활성화되어 있을 때만 올바른 결과를 반환합니다. isSenderTxHashIndexingEnabled을 사용해 인덱싱 기능이 활성화되었는지 아닌지를 확인합니다.
Parameters
Name
Type
Description
senderTxHash
String
Hash of a transaction that is signed only by the sender. 이에 대한 자세한 내용은 SenderTxHash를 참고하세요.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise returns Object - A transaction object, or null when no transaction was found:
Name
Type
Description
blockHash
32-byte DATA
Hash of the block where this transaction was in. null when it is pending.
blockNumber
QUANTITY
Block number where this transaction was in. null when it is pending.
codeFormat
String
(optional) The code format of smart contract code.
feePayer
20-byte DATA
Address of the fee payer.
feePayerSignatures
Array
An array of fee payer's signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
feeRatio
QUANTITY
(optional) 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.
from
20-byte DATA
Address of the sender.
gas
QUANTITY
Gas provided by the sender.
gasPrice
QUANTITY
Gas price provided by the sender in peb.
hash
32-byte DATA
Hash of the transaction.
humanReadable
Boolean
(optional) true if the address is humanReadable, false if the address is not humanReadable.
key
String
(optional) Key of the newly created account.
input
DATA
(optional) The data sent along with the transaction.
nonce
QUANTITY
The number of transactions made by the sender prior to this one.
senderTxHash
32-byte DATA
Hash of a transaction that is signed only by the sender. See SenderTxHash. This value is always the same as hash for non fee-delegated transactions.
signatures
Array
An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
to
20-byte DATA
Address of the receiver. null when it is a contract creation transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block. null when it is pending.
type
String
A string representing the type of the transaction.
typeInt
QUANTITY
An integer representing the type of the transaction.
Returns the receipt of a transaction by transaction hash.
Parameters
Name
Type
Description
transactionHash
String
The transaction hash
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
프로미스는 Object를 반환합니다 - 트랜잭션 영수증 객체를 반환하거나 영수증을 찾을 수 없는 경우 null을 반환합니다.
Name
Type
Description
blockHash
32-byte String
Hash of the block where this transaction was in.
blockNumber
Number
Block number where this transaction was in.
codeFormat
String
(optional) The code format of smart contract code.
contractAddress
DATA
The contract address created, if the transaction was a contract creation, otherwise null.
feePayer
20-byte DATA
(optional) Address of the fee payer.
feePayerSignatures
Array
(optional) An array of fee payer's signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
feeRatio
QUANTITY
(optional) 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.
from
20-byte DATA
Address of the sender.
gas
QUANTITY
Gas provided by the sender.
gasPrice
QUANTITY
Gas price provided by the sender in peb.
gasUsed
QUANTITY
The amount of gas used by this specific transaction alone.
humanReadable
Boolean
(optional) true if the address is humanReadable, false if the address is not humanReadable.
key
String
(optional) Key of the newly created account.
input
DATA
(optional) The data sent along with the transaction.
logs
Array
Array of log objects, which this transaction generated.
logsBloom
256-byte DATA
Bloom filter for light clients to quickly retrieve related logs.
nonce
QUANTITY
The number of transactions made by the sender prior to this one.
senderTxHash
32-byte DATA
(선택사항) 발신자만 서명한 트랜잭션 해시. See SenderTxHash. 이 값은 수수료를 위임하지 않은 트랜잭션의 transactionHash 값과 항상 동일합니다.
signatures
Array
An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
status
Boolean
트랜잭션이 성공적으로 실행되면 true를 반환하며, 만약 Klaytn 가상머신이 트랜잭션을 거부하면 false를 반환합니다.
txError
QUANTITY
(optional) detailed error code if status is equal to zero.
to
20-byte DATA
Address of the receiver. null when it is a contract creation transaction.
transactionHash
32-byte DATA
Hash of the transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block.
type
String
A string representing the type of the transaction.
typeInt
QUANTITY
An integer representing the type of the transaction.
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. isSenderTxHashIndexingEnabled를 호출하여 인덱싱 기능이 활성화되어 있는지 확인할 수 있습니다.
Parameters
Name
Type
Description
senderTxHash
String
Hash of a transaction that is signed only by the sender. See SenderTxHash.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise returns Object - A transaction receipt object, or null when no receipt was found:
Name
Type
Description
blockHash
32-byte String
Hash of the block where this transaction was in.
blockNumber
Number
Block number where this transaction was in.
codeFormat
String
(optional) The code format of smart contract code.
contractAddress
DATA
The contract address created, if the transaction was a contract creation, otherwise null.
feePayer
20-byte DATA
Address of the fee payer.
feePayerSignatures
Array
An array of fee payer's signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
feeRatio
QUANTITY
(optional) 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.
from
20-byte DATA
Address of the sender.
gas
QUANTITY
Gas provided by the sender.
gasPrice
QUANTITY
Gas price provided by the sender in peb.
gasUsed
QUANTITY
The amount of gas used by this specific transaction alone.
humanReadable
Boolean
(optional) true if the address is humanReadable, false if the address is not humanReadable.
key
String
(optional) Key of the newly created account.
input
DATA
(optional) The data sent along with the transaction.
logs
Array
Array of log objects, which this transaction generated.
logsBloom
256-byte DATA
Bloom filter for light clients to quickly retrieve related logs.
nonce
QUANTITY
The number of transactions made by the sender prior to this one.
senderTxHash
32-byte DATA
Hash of a transaction that is signed only by the sender. See SenderTxHash. This value is always the same as transactionHash for non fee-delegated transactions.
signatures
Array
An array of signature objects. A signature object contains three fields (V, R, and S). V contains ECDSA recovery id. R contains ECDSA signature r while S contains ECDSA signature s.
status
Boolean
true if the transaction was successful, false if the Klaytn Virtual Machine reverted the transaction.
txError
QUANTITY
(optional) detailed error code if status is equal to zero.
to
20-byte DATA
Address of the receiver. null when it is a contract creation transaction.
transactionHash
32-byte DATA
Hash of the transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block.
type
String
A string representing the type of the transaction.
typeInt
QUANTITY
An integer representing the type of the transaction.
caver.klay.accounts.signTransaction으로 생성된 이미 서명받은 트랜잭션을 보냅니다.
참고caver.klay.sendSignedTransaction는 caver-js v1.2.0부터 객체를 파라미터로 받을 수 있습니다. 객체는 반드시 RLP 인코딩된 트랜잭션 문자열을 포함하거나 반드시 서명(트랜잭션 발신자 서명 혹은 트랜잭션 수수료 납부자 서명)을 받았으며 인코딩되지 않은 트랜잭션 객체이어야 합니다. caver.klay.accounts.signTransaction, caver.klay.accounts.feePayerSignTransaction, caver.klay.accounts.getRawTransactionWithSignatures 또는 caver.klay.accounts.combineSignatures의 리턴값으로 받는 객체를 전달해도 됩니다.
Parameters
Name
Type
Description
signedTransactionData
String | Object
RLP 인코딩된 서명받은 트랜잭션 문자열, 또는 RLP 인코딩된 서명받은 트랜잭션 문자열을 rawTransaction 속성값안에 가진 객체, 또는 서명(트랜잭션 발신자 서명 혹은 트랜잭션 수수료 납부자 서명)이 첨부된 인코딩되지 않은 트랜잭션 객체이어야 합니다.
callback
Function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Type
Description
PromiEvent
A promise combined event emitter. Will be resolved when the transaction receipt is available.
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)