caver.transaction
caver.transaction는 트랜잭션 관련 기능을 제공하는 패키지입니다.
Class
각 트랜잭션 클래스에 대한 자세한 설명이 있습니다:
ValueTransferMemo
SmartContractDeploy
SmartContractExecution
ChainDataAnchoring
caver.transaction.decode
caver.transaction.decode(rlpEncoded)Decodes RLP-encoded transaction string, a raw transaction, and returns a Transaction instance.
Parameters
rlpEncoded
string
디코딩할 RLP 인코딩된 트랜잭션 문자열입니다.
Return Value
object
An instance of Transaction. For details of each transaction, refer to Transaction.
Example
caver.transaction.getTransactionByHash
Queries a transaction from Klaytn and converts to a caver transaction instance.
NOTE caver.transaction.getTransactionByHash is supported since caver-js v1.6.3.
Parameters
transactionHash
string
The transaction hash string to query from Klaytn.
Return Value
Promise returning object: An instance of Transaction. If it fails to receive a transaction object from Klaytn, an error occurs.
object
An instance of Transaction. For details of each transaction, refer to Transaction.
Example
caver.transaction.recoverPublicKeys
Recovers the public key strings from signatures field of the given transaction.
NOTE caver.transaction.recoverPublicKeys is supported since caver-js v1.6.3.
Parameters
rawTx
string
The RLP-encoded transaction string to recover public keys from signatures.
Return Value
Array
An array containing public keys recovered from signatures.
Example
caver.transaction.recoverFeePayerPublicKeys
Recovers the public key strings from feePayerSignatures field of the given transaction.
NOTE caver.transaction.recoverFeePayerPublicKeys is supported since caver-js v1.6.3.
Parameters
rawTx
string
The RLP-encoded transaction string to recover public keys from feePayerSignatures. To recover fee payer's public keys, the transaction should be a fee-delegated transaction with the feePayerSignatures field inside.
Return Value
Array
An array containing public keys recovered from feePayerSignatures.
Example
transaction.sign
Signs the transaction as a transaction sender with the private key(s) in the keyring and appends signatures in the transaction object.
For Account Update transaction, use roleAccountUpdateKey, or otherwise, use roleTransactionKey in RoleBasedKeyring. If the user has not defined an index, transaction.sign signs the transaction using all the private keys used by the role. If index is defined, the transaction.sign signs the transaction using only one private key at the given index.
Parameters
keyring
object \
string
index
number
(선택 사항) 사용하고자 하는 개인키의 인덱스입니다. 인덱스는 각각의 역할에 정의된 개인키들의 배열 길이보다 작아야 합니다. 인덱스가 정의되지 않았을 경우, 이 메서드는 모든 개인키를 사용합니다.
hasher
Function
(optional) The hash function to get the hash of the transaction.
Return Value
Promise는 객체를 반환: 서명된 트랜잭션입니다.
object
An instance of signed Transaction. The signature is appended to the transaction.signatures.
Example
transaction.signAsFeePayer
트랜잭션 fee payer로서 서명하며, keyring 내 개인키를 사용하여 트랜잭션 객체에 feePayerSignatures를 첨부합니다.
For signing a transaction as a fee payer, use roleFeePayerKey in keyring. 사용자가 index를 정의하지 않았다면, transaction.signAsFeePayer이 해당 역할에 의해 사용되는 모든 개인키를 가지고 트랜잭션에 서명합니다. index가 정의되어 있다면, transaction.signAsFeePayer이 주어진 인덱스에 대응하는 하나의 개인키를 가지고 트랜잭션에 서명합니다.
transaction.feePayer가 정의되어 있지 않은 경우, 주어진 keyring의 주소는 transaction.feePayer로 설정됩니다.
If the keyring to be used for signing the transaction was added to caver.wallet, you can use caver.wallet.signAsFeePayer.
참고 이 함수는 "수수료 대납" 트랜잭션 또는 "수수료 부분 대납" 트랜잭션에서만 작동합니다.
Parameters
keyring
object \
string
index
number
(optional) The index of the private key you want to use. The index must be less than the length of the array of the private keys defined for each role. If an index is not defined, this method will use all the private keys.
hasher
Function
(optional) The hash function to get the hash of the transaction.
Return Value
Promise returning object: The signed transaction.
object
An instance of signed Transaction. The signature is appended to the transaction.feePayerSignatures.
Example
transaction.appendSignatures
Appends signatures to the transaction.
Parameters
signatures
object \
Array
Example
transaction.appendFeePayerSignatures
Appends feePayerSignatures to the transaction.
NOTE This function works only for "fee-delegated" transactions or "fee-delegated with ratio" transactions.
Parameters
feePayerSignatures
object \
Array
Example
transaction.combineSignedRawTransactions
Collects signs in each RLP-encoded transaction string in the given array, combines them with the transaction instance, and returns a RLP-encoded transaction string which includes all signs. Note that the transaction instance doesn't necessarily be signed in advance. If the transaction is either a type of "fee-delegated" or "fee-delegated with ratio", feePayerSignatures is also merged and included in the output RLP-encoded transaction string.
Parameters
rlpEncodedTxs
Array
An array of signed RLP-encoded transaction strings.
Return Value
string
A RLP-encoded transaction string which includes all signatures (and feePayerSignatures if transaction is a type of either "fee-delgated" or "fee-delegated with ratio").
Example
transaction.getRLPEncoding
RLP 인코딩된 트랜잭션 문자열을 반환합니다.
For information on how to make the RLP-encoded string for each transaction type, see Klaytn Design - Transactions.
Return Value
string
RLP 인코딩된 트랜잭션 문자열입니다.
Example
transaction.getRawTransaction
rawTransaction 문자열을 반환합니다(RLP 인코딩된 트랜잭션 문자열). This function is same with transaction.getRLPEncoding.
Return Value
string
A RLP-encoded transaction string.
Example
transaction.getTransactionHash
transactionHash를 반환합니다.
For information on how to make the transaction hash for each transaction type, see Klaytn Design - Transactions.
Return Value
string
트랜잭션 해시입니다.
Example
transaction.getSenderTxHash
Returns a senderTxHash of transaction.
The senderTxHash is a hash of the transaction except for the fee payer's address and signature, so transactionHash and senderTxHash are the same for basic transactions.
For information on how to make the senderTxHash for each transaction type, see Klaytn Design - Transactions.
Return Value
string
전송자의 트랜잭션 해시(senderTxHash) 입니다.
Example
transaction.getRLPEncodingForSignature
트랜잭션 전송자의 서명을 만들기 위한 RLP 인코딩된 트랜잭션 문자열을 반환합니다. 반환된 RLP 인코딩된 트랜잭션 문자열은 서명에 추가되는 것이 아니라, 이 서명을 생성하는 데 사용된다는 점을 참고하세요.
For information on how to make a RLP-encoded transaction string to generate the transaction sender's signature for each transaction type, see Klaytn Design - Transactions.
Return Value
string
서명이 첨부되지 않은 RLP 인코딩된 트랜잭션 문자열입니다.
Example
transaction.getRLPEncodingForFeePayerSignature
수수료 납부자의 서명을 생성하기 위한 RLP 인코딩된 트랜잭션 문자열을 반환합니다. Note that the returned RLP-encoded transaction string is not added with the signature and rather is used to generate this signature.
For information on how to make a RLP-encoded transaction string to generate the fee payer's signature for each transaction type, see Klaytn Design - Transactions.
NOTE This function works only for "fee-delegated" transactions or "fee-delegated with ratio" transactions.
Return Value
string
A RLP-encoded transaction string without any signature attached.
Example
transaction.fillTransaction
트랜잭션의 선택 사항 변수들을 기입해 줍니다.
이 메서드는 트랜잭션의 선택 변수 gasPrice, nonce, 또는 chainId가 정의되지 않은 경우, 각각의 기본값을 조회하여 연결된 Klaytn Node에 JSON RPC 호출을 함으로서 이 값들을 지정시킵니다.
Use caver.rpc.klay.getGasPrice to get gasPrice, caver.rpc.klay.getTransactionCount to get nonce and caver.rpc.klay.getChainId call to get chainId.
Return Value
Promise는 void을 반환합니다.
Example
transaction.recoverPublicKeys
signatures에서 공개키 스트링을 복구합니다.
참고 transaction.recoverPublicKeys는 caver-js v1.6.3부터 지원됩니다.
Return Value
Array
An array containing public keys recovered from signatures.
Example
transaction.recoverFeePayerPublicKeys
feePayerSignatures 필드에서 공개키 문자열을 복구합니다.
참고 transaction.recoverFeePayerPublicKeys는 caver-js v1.6.3부터 지원됩니다.
Return Value
Array
An array containing public keys recovered from feePayerSignatures.
Example
transaction.suggestGasPrice
Returns suggested gas price. This function is used to set gasPrice field in the fillTransaction.
Before the Magma hard fork, suggestGasPrice returns the unit price of the network. After the Magma hard fork, suggestGasPrice returns baseFee * 2 which is recommended to use as gasPrice.
NOTE transaction.suggestGasPrice is supported since caver-js v1.9.0.
Return Value
Promise returning string: The suggested gas price in hexadecimal string.
string
The suggested gas price.
Example
Last updated
Was this helpful?