caver.rpc.klay
caver.rpc.klay
는 klay
네임 스페이스를 가진 JSON-RPC API를 호출합니다.
caver.rpc.klay.accountCreated
입력된 주소의 계정이 Klaytn 블록체인 플랫폼(Klaytn)에 존재하는 경우 true
를 반환합니다. It returns false
otherwise.
Parameters
address
string
네트워크에 존재하는지 확인하고 싶은 계정 주소입니다.
blockNumber
number \
string
callback
function
(선택 사항) 선택적 콜백(callback)은 오류 객체를 첫 번째 매개 변수로, 결과를 두 번째 매개 변수로 반환합니다.
Return Value
Promise
는 boolean
을 반환합니다.
boolean
입력으로 받은 주소가 Klaytn에 존재하는지 여부를 반환합니다.
Example
caver.rpc.klay.getAccount
입력으로 받은 Klaytn 계정 주소의 계정 정보를 반환합니다. Klaytn 계정 타입에 관한 자세한 내용은 Klaytn Account Types를 확인하십시오.
참고 caver.rpc.klay.getAccount
는 계정이 Klaytn에 있는 경우에만 계정을 반환하므로 주소와 일치하는 계정이 Klaytn 상에 존재하지 않으면 null
이 반환됩니다.
Parameters
address
string
계정 정보를 알고 싶은 계정 주소입니다.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
계정 정보를 담고 있는 객체입니다. Each account type has different attributes.
Example
caver.rpc.klay.getAccountKey
주어진 주소의 AccountKey를 반환합니다. 입력으로 받은 주소 계정이 AccountKeyLegacy를 AccountKey로 갖고 있거나 계정이 스마트 컨트랙트 계정이면 빈 키 값을 반환합니다. 더 자세한 내용은 Account Key를 확인하십시오.
참고 caver.rpc.klay.getAccountKey
는 각 AccountKey 타입에 따라 다른 객체를 반환합니다. 주어진 주소를 가진 계정이 Klaytn에 존재하지 않는다면 null
을 반환합니다.
Parameters
address
string
Klaytn 계정 주소입니다. 이 메서드를 실행하면 이 계정 주소의 AccountKey 정보가 담긴 객체를 얻습니다.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
AccountKey 정보를 담고 있는 객체입니다. AccountKey 유형에 따라 다른 속성을 반환합니다.
Example
caver.rpc.klay.encodeAccountKey
AccountKey 정보를 담고 있는 객체를 RLP(Recursive Length Prefix)로 인코딩합니다. account.getRLPEncodingAccountKey를 사용해도 RLP 인코딩된 AccountKey를 얻습니다.
Parameters
accountKey
object
An object defines keyType
and key
inside or an instance of AccountKey
(AccountKeyLegacy, AccountKeyPublic, AccountKeyFail, AccountKeyWeightedMultiSig or AccountKeyRoleBased).
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
RLP로 인코딩된 AccountKey.
Example
caver.rpc.klay.decodeAccountKey
RLP 인코딩된 AccountKey를 디코딩 합니다. caver.account.accountKey.decode를 사용해도 RLP 인코딩된 AccountKey를 디코딩합니다.
Parameters
encodedKey
string
A RLP-encoded AccountKey.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
내부에 keyType
과 key
가 정의된 객체입니다.
Example
caver.rpc.klay.getBalance
입력으로 받은 Klaytn 계정 주소의 잔액을 반환합니다.
Parameters
address
string
잔액을 확인할 계정 주소입니다.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
주어진 주소의 peb 단위 현재 잔액입니다.
Example
caver.rpc.klay.getCode
Returns code at a given address.
Parameters
address
string
코드를 알고 싶은 주소입니다.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The code from the given address.
Example
caver.rpc.klay.getTransactionCount
어떤 주소의 계정에서 발신된 트랜잭션의 총 개수를 반환합니다.
Parameters
address
string
발신한 트랜잭션 개수를 확인할 주소입니다.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
주어진 주소에서 발신된 트랜잭션의 개수입니다. 이 값은 16진수입니다.
Example
caver.rpc.klay.isContractAccount
Returns true
if an input account has a non-empty codeHash at the time of a specific block number. It returns false
if the account is an EOA or a smart contract account which doesn't have codeHash. 더 자세한 내용은 Smart Contract Account를 확인하십시오.
Parameters
address
string
isContractAccount로 확인할 주소입니다.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns boolean
boolean
true면 파라미터가 스마트 컨트랙트 계정의 주소입니다.
Example
caver.rpc.klay.sign
Klaytn에서 사용하는 서명된 데이터를 생성합니다. Refer to Klaytn Platform API - klay_sign to know how the signature is generated.
NOTE: This API provides the function to sign a message using an imported account in your Klaytn node. The imported account in your node must be unlocked to sign the message. To sign a transaction with imported account in your Klaytn node, use caver.rpc.klay.signTransaction.
Parameters
address
String
메시지에 서명할 불러온 계정 주소입니다.
message
String
서명하려는 메시지입니다.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
노드에 불러온 계정이 만든 서명입니다.
Example
caver.rpc.klay.getAccounts
Klaytn 노드가 가진 주소 목록을 반환합니다.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
Array
Klaytn 노드가 가진 주소 목록입니다.
Example
caver.rpc.klay.getBlockNumber
Returns the number of the most recent block.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
가장 최근의 블록 번호입니다. 이 값은 16진수 값입니다.
Example
caver.rpc.klay.getHeader
Returns a block header by block hash or block number. If the user passes the block hash as a parameter, caver.rpc.klay.getHeaderByHash is called, and if the block number is called as a parameter, caver.rpc.klay.getHeaderByNumber is called.
Parameters
blockNumberOrHash
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
A block header object. For a detailed description of the return value, please refer to caver.rpc.klay.getHeaderByHash.
Example
caver.rpc.klay.getHeaderByNumber
Returns a block header by block number.
Parameters
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
A block header object. For a detailed description of the return value, please refer to caver.rpc.klay.getHeaderByHash.
Example
caver.rpc.klay.getHeaderByHash
blockHash
를 사용해 가장 최근의 블록 번호를 반환합니다.
Parameters
blockHash
string
블록 해시입니다.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
- An object includes the block header:
baseFeePerGas
string
The base fee per gas. This value is returned only when EthTxTypeCompatibleBlock is activated for that block number.
blockScore
string
블록체인 네트워크의 채굴 난이도입니다. blockScore
사용은 네트워크 합의에 따라 다릅니다. BFT 합의 엔진에서는 항상 1입니다.
extraData
string
The "extra data" field of this block.
gasUsed
string
이 블록에 있는 모든 트랜잭션에서 사용된 가스양의 총합입니다.
governanceData
string
RLP encoded governance configuration
hash
string
Hash of the block. null
when it is a pending block.
logsBloom
string
The bloom filter for the logs of the block. null
when it is a pending block.
number
string
The block number. null
when it is a pending block.
parentHash
string
Hash of the parent block.
receiptsRoot
string
The root of the receipts trie of the block.
reward
string
The address of the beneficiary to whom the block rewards were given.
stateRoot
string
The root of the final state trie of the block.
timestamp
string
블록이 생성되었을 때의 Unix 타임스탬프입니다.
timestampFoS
string
The fraction of a second of the timestamp for when the block was collated.
transactionsRoot
string
The root of the transaction trie of the block.
Example
caver.rpc.klay.getBlock
Returns information about a block by block hash or block number. If the user passes the block hash as a parameter, caver.rpc.klay.getBlockByHash is called, and if the block number is called as a parameter, caver.rpc.klay.getBlockByNumber is called.
Parameters
blockNumberOrHash
number \
string
returnTransactionObjects
boolean
(선택 사항, 기본값은 false
) true
이면, 반환된 블록은 모든 트랜잭션 객체를 가집니다. false
이면, 반환된 블록은 트랜잭션 해시만을 가집니다.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
블록 객체입니다. For a detailed description of the return value, please refer to caver.rpc.klay.getBlockByHash.
Example
caver.rpc.klay.getBlockByNumber
Returns information about a block by block number.
Parameters
blockNumber
number \
string
returnTransactionObjects
boolean
(optional, default false
) If true
, the returned block will contain all transactions as objects, and if false
, it will only contain the transaction hashes.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
A block object. For detailed description of return value, please refer to caver.rpc.klay.getBlockByHash.
Example
caver.rpc.klay.getBlockByHash
Returns the block number of the most recent block by using blockHash
.
Parameters
blockHash
string
The block hash.
returnTransactionObjects
boolean
(optional, default false
) If true
, the returned block will contain all transactions as objects, and if false
, it will only contain the transaction hashes.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
는 object
를 반환 - 블록을 포함하는 객체입니다.
baseFeePerGas
string
The base fee per gas. This value is returned only when EthTxTypeCompatibleBlock is activated for that block number.
blockScore
string
The difficulty of mining in the blockchain network. The use of blockScore
differs from the consensus of the network. Always 1 in the BFT consensus engine.
extraData
string
The "extra data" field of this block.
gasUsed
string
The gas in total that was used by all transactions in this block.
governanceData
string
RLP encoded governance configuration
hash
string
Hash of the block. null
when it is a pending block.
logsBloom
string
The bloom filter for the logs of the block. null
when it is a pending block.
number
string
The block number. null
when it is a pending block.
parentHash
string
Hash of the parent block.
receiptsRoot
string
The root of the receipts trie of the block.
reward
string
The address of the beneficiary to whom the block rewards were given.
size
string
Integer the size of this block in bytes.
stateRoot
string
The root of the final state trie of the block.
timestamp
string
The unix timestamp for when the block was collated.
timestampFoS
string
The fraction of a second of the timestamp for when the block was collated.
totalBlockScore
string
Integer of the total blockScore of the chain until this block.
transactions
Array
트랜잭션 객체의 배열이거나 또는 returnTransactionObjects
매개변수에 따라 32바이트 크기의 트랜잭션 해시입니다.
transactionsRoot
string
The root of the transaction trie of the block.
voteData
string
제안자의 RLP 인코딩된 거버넌스 투표입니다.
Example
caver.rpc.klay.getBlockReceipts
블록 해시로 조회한 블록에 포함된 영수증을 반환합니다.
Parameters
blockHash
string
The block hash.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
Array
조회한 블록에 포함된 트랜잭션 영수증들입니다. 조회하고자 하는 블록이 트랜잭션을 담고 있지 않으면 빈 배열 []
이 반환됩니다. For detailed description of transaction receipt, please refer to caver.rpc.klay.getTransactionReceipt.
Example
caver.rpc.klay.getBlockTransactionCountByNumber
Returns the number of transactions in a block matching the given block number.
Parameters
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
주어진 블록에 기록된 트랜잭션의 개수입니다. 이 값은 16진수 값입니다.
Example
caver.rpc.klay.getBlockTransactionCountByHash
블록 해시로 조회한 블록에 담긴 트랜잭션의 개수를 반환합니다.
Parameters
blockHash
string
The block hash.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The number of transactions in the given block in hex.
Example
caver.rpc.klay.getBlockWithConsensusInfoByNumber
블록 번호로 조회한 블록을 합의에 대한 정보와 함께 반환합니다.
Parameters
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
string
합의 정보를 포함해 블록 정보를 담고 있는 객체입니다. For detailed description of return value, please refer to caver.rpc.klay.getBlockWithConsensusInfoByHash.
Example
caver.rpc.klay.getBlockWithConsensusInfoByHash
블록 해시로 조회한 블록을 합의에 대한 정보와 함께 반환합니다.
Parameters
blockHash
string
The block hash.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
는 object
를 반환 - 합의 정보(제안자와 위원회 멤버 목록)와 블록 객체입니다. 블록을 찾지 못했다면 null을 반환합니다.
blockScore
string
Former difficulty. Always 1 in the BFT consensus engine
committee
Array
블록 생성에 관여한 위원회 멤버들의 주소의 배열입니다. 위원회란 블록 생성을 위한 합의 프로토콜에 참여한 검증자 중 일부입니다.
extraData
string
The "extra data" field of this block.
gasUsed
string
The gas in total that was used by all transactions in this block.
governanceData
string
RLP encoded governance configuration
hash
string
Hash of the block. null
when it is a pending block.
logsBloom
string
The bloom filter for the logs of the block. null
when it is a pending block.
number
string
The block number. null
when it is a pending block.
originProposer
string
동일한 블록 번호에서 0 라운드의 제안자입니다.
parentHash
string
Hash of the parent block.
proposer
string
블록 제안자의 주소입니다.
receiptsRoot
string
The root of the receipts trie of the block.
reward
string
The address of the beneficiary to whom the block rewards were given.
round
number
라운드 번호입니다.
size
string
Integer the size of this block in bytes.
stateRoot
string
The root of the final state trie of the block.
timestamp
string
The unix timestamp for when the block was collated.
timestampFoS
string
The fraction of a second of the timestamp for when the block was collated.
totalBlockScore
string
Integer of the total blockScore of the chain until this block.
transactions
Array
트랜잭션 객체의 배열입니다.
transactionsRoot
string
The root of the transaction trie of the block.
voteData
string
RLP encoded governance vote of the proposer
Example
caver.rpc.klay.getCommittee
어떤 블록 시간에서 위원회에 속한 검증자 목록을 반환합니다.
Parameters
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
Array
주어진 블록에서 위원회에 속한 모든 검증자의 주소들입니다.
Example
caver.rpc.klay.getCommitteeSize
어떤 블록 시간에서 위원회의 구성원 수를 반환합니다.
Parameters
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns number
number
블록의 위원회 구성원 수입니다.
Example
caver.rpc.klay.getCouncil
어떤 블록 시간에서 council에 속한 검증자 목록을 반환합니다.
Parameters
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
Array
주어진 블록에서 카운슬에 속한 검증자들의 주소가 담긴 배열입니다. 카운슬을 찾을 수 없는 경우 null을 반환합니다.
Example
caver.rpc.klay.getCouncilSize
어떤 블록 시간에서 council의 구성원 수를 반환합니다.
Parameters
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns number
number
주어진 블록의 카운슬 구성원 수입니다.
Example
caver.rpc.klay.getStorageAt
Returns the value from a storage position at a given address.
Parameters
address
string
스토리지를 얻고 싶은 주소입니다.
position
number
스토리지 인덱스 위치입니다. For more information on calculating the position
, refer to klay_getStorageAt.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The value at this storage position.
Example
caver.rpc.klay.isMinting
Returns true
if client is actively mining new blocks.
Parameters
callback
function
(optional) Optional callback, which returns an error object as the first parameter and the result as the second.
Return Value
Promise
는 boolean
을 반환합니다. 클라이언트가 블록을 채굴중이면 true
, 그렇지 않을 경우 false
를 반환합니다.
Example
caver.rpc.klay.isSyncing
동기화 상태에 대한 데이터가 있는 객체를 반환하거나 false를 반환합니다.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
는 Boolean
을 반환합니다. 계정이 발행자라면 true
를 반환합니다. 그렇지 않다면 동기화 객체를 반환합니다.
startingBlock
string
동기화가 시작된 블록의 번호로, 16진수입니다.
currentBlock
string
현재 노드가 동기화한 블록의 블록 번호로, 16진수입니다.
highestBlock
string
싱크해야 할 블록 번호 추정값으로, 16진수입니다.
knownStates
string
The estimated states in hex to download.
pulledStates
string
The already downloaded states in hex.
Example
caver.rpc.klay.call
블록체인에 트랜잭션을 전송하지 않고 즉시 새 메시지를 호출합니다. 결과 데이터를 반환하거나, 또는 에러 발생 시 JSON RPC의 에러 객체를 반환합니다.
Parameters
callObject
object
트랜잭션 호출 객체입니다. See the next table for the object's properties.
blockNumber
number \
string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
callObject
has the following properties:
to
string
(optional when testing the deployment of a new contract) The address the transaction is directed to.
from
string
(optional) The address the transaction is sent from.
gas
string
(선택 사항) 트랜잭션 실행을 위해 설정한 가스입니다. klay_call
consumes zero gas, but this parameter may be needed by some executions.
gasPrice
string
(선택 사항) 가스당 가격, 즉 gasPrice입니다.
value
string
(선택 사항) 트랜잭션에 의해 전송된 peb
단위의 값입니다.
Return Value
Promise
returns string
string
호출 결과로 리턴된 데이터입니다. e.g., the return value of a smart contract function.
Example
caver.rpc.klay.estimateGas
트랜잭션 실행을 완료하는 데에 필요한 gas
의 추정치를 생성하여 반환합니다. 이때 이 메서드가 발생시킨 트랜잭션은 블록체인에 추가되지 않습니다.
Parameters
See caver.rpc.klay.call parameters, expect that all properties are optional.
Return Value
Promise
returns string
string
The amount of gas used.
Example
caver.rpc.klay.estimateComputationCost
트랜잭션을 실행하는 데에 드는 computation cost
를 생성하여 반환합니다. 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 like caver.rpc.klay.estimateGas.
Parameters
See caver.rpc.klay.call parameters, expect that all properties are optional.
Return Value
Promise
returns string
string
The amount of computation cost used.
Example
caver.rpc.klay.getTransactionByBlockHashAndIndex
block hash
와 transaction index
로 조회한 트랜잭션의 정보를 반환합니다.
Parameters
blockHash
string
The block hash.
index
number
블록 내에 트랜잭션 인덱스 위치입니다.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
A transaction object, see caver.rpc.klay.getTransactionByHash for more detail.
Example
caver.rpc.klay.getTransactionByBlockNumberAndIndex
block number
와 transaction index
로 조회한 트랜잭션의 정보를 반환합니다.
Parameters
blockNumber
number \
string
index
number
A transaction index position inside the block.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
A transaction object, see caver.rpc.klay.getTransactionByHash for more detail.
Example
caver.rpc.klay.getTransactionByHash
Returns the information about a transaction requested by transaction hash.
Parameters
transactionHash
string
트랜잭션 해시입니다.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
는 object
를 반환합니다. 트랜잭션 객체를 반환하거나 또는 해당하는 트랜잭션을 찾을 수 없는 경우 null
을 반환합니다.
blockHash
string
Hash of the block where this transaction was in.
blockNumber
string
Block number where this transaction was in.
codeFormat
string
(optional) The code format of smart contract code.
feePayer
string
(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
string
(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
string
Address of the sender.
gas
string
Gas provided by the sender.
gasPrice
string
Gas price provided by the sender in peb.
hash
string
Hash of the transaction.
humanReadable
Boolean
(optional) true
if the address is humanReadable, false
if the address is not humanReadable.
key
string
(optional) The RLP-encoded AccountKey used to update AccountKey of an Klaytn account. See AccountKey for more details.
input
string
(optional) The data sent along with the transaction.
nonce
string
The number of transactions made by the sender prior to this one.
senderTxHash
string
(선택사항) 트랜잭션 수수료 납부자의 주소와 서명이 없는 트랜잭션 해시입니다. This value is always the same as the value of 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
string
Address of the receiver. null
when it is a contract deploying transaction.
transactionIndex
string
Integer of the transaction index position in the block.
type
string
A string representing the type of the transaction.
typeInt
number
An integer representing the type of the transaction.
value
string
Value transferred in peb.
If the transaction is in pending
status that has not yet been processed, default values for blockHash
, blockNumber
and transactionIndex
are returned. 아래 예제를 참조하세요.
Example
caver.rpc.klay.getTransactionBySenderTxHash
Returns the information about a transaction requested by the sender transaction hash.
Please note that this API returns the correct result only if the indexing feature is enabled in the node by --sendertxhashindexing
. Use caver.rpc.klay.isSenderTxHashIndexingEnabled to check if the indexing feature is enabled or not.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
A transaction object, see caver.rpc.klay.getTransactionByHash for more details.
Example
caver.rpc.klay.getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
NOTE Receipt is not available for pending
transactions whose transactions have not yet been processed.
Parameters
transactionHash
string
A transaction hash.
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:
blockHash
string
Hash of the block where this transaction was in.
blockNumber
string
Block number where this transaction was in.
codeFormat
string
(optional) The code format of smart contract code.
contractAddress
string
The contract address created, if the transaction was a contract creation, otherwise null
.
effectiveGasPrice
string
The actual value per gas deducted from the sender. Before the Magma hard fork, this value was equal to the transaction’s gas price. After the Magma hard fork, it is equal to the value of baseFee
in the block header.
feePayer
string
(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
string
(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
string
Address of the sender.
gas
string
Gas provided by the sender.
gasPrice
string
Gas price provided by the sender in peb.
gasUsed
string
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) The RLP-encoded AccountKey used to update AccountKey of a Klaytn account.
input
string
(optional) The data sent along with the transaction.
logs
Array
Array of log objects, which this transaction generated.
logsBloom
string
Bloom filter for light clients to quickly retrieve related logs.
nonce
string
The number of transactions made by the sender prior to this one.
senderTxHash
string
(optional) 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
string
0x1
if the transaction was successful, 0x0
if the Klaytn Virtual Machine reverted the transaction.
txError
string
(optional) detailed error code if status
is equal to 0x0
.
to
string
Address of the receiver. null
when it is a contract creation transaction.
transactionHash
string
Hash of the transaction.
transactionIndex
string
Integer of the transaction index position in the block.
type
string
A string representing the type of the transaction.
typeInt
number
An integer representing the type of the transaction.
value
string
Value transferred in peb.
NOTE effectiveGasPrice
is supported since caver-js v1.9.0.
Example
caver.rpc.klay.getTransactionReceiptBySenderTxHash
Returns the receipt of a transaction by sender transaction hash.
Please note that this API returns the correct result only if the indexing feature is enabled in the node by --sendertxhashindexing
. Use caver.rpc.klay.isSenderTxHashIndexingEnabled to check if the indexing feature is enabled or not.
NOTE Receipt is not available for pending
transactions whose transactions have not yet been processed.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
object
A transaction receipt object, see caver.rpc.klay.getTransactionReceipt for more detail.
Example
caver.rpc.klay.sendRawTransaction
Sends a signed transaction
to the Klaytn.
The signedTransaction
parameter can be a "RLP-encoded signed transaction." You can get the RLP-encoded transaction of a signed transaction using transaction.getRLPEncoding
. For convenience, caver.rpc.klay.sendRawTransaction
also accepts a "signed transaction instance" as parameter.
Parameters
signedTransaction
string \
object
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
PromiEvent
A promise combined event emitter. It will be resolved when a transaction receipt is available.
For PromiEvent, the following events are available:
transactionHash
는String
를 반환: 트랜잭션을 보내고 트랜잭션 해시가 준비된 직후에 발생합니다.receipt
는Object
를 반환: 트랜잭션 영수중이 중비되면 발생합니다. See caver.rpc.klay.getTransactionReceipt for more detail.error
는Error
를 반환: 전송 중 에러가 발생하면 발생합니다. On an out-of-gas error, the second parameter is the receipt.
Example
caver.rpc.klay.sendTransaction
Signs a transaction as a transaction sender
with an "imported account's private key" in your Klaytn Node and propagates the transaction to the Klaytn.
For more information about each transaction type, refer to Transaction.
NOTE: This API provides the function to sign a transaction using an imported account in your Klaytn node. The imported account in your node must be unlocked to sign a transaction.
Parameters
transaction
object
An instance of a transaction to be sent to the Klaytn.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
PromiEvent
A promise combined event emitter. It will be resolved when a transaction receipt is available.
For PromiEvent, the following events are available:
transactionHash
returnsstring
: Is fired right after a transaction is sent and a transaction hash is available.receipt
returnsobject
: Is fired when a transaction receipt is available. See caver.rpc.klay.getTransactionReceipt for more detail.error
returnsError
: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
Example
caver.rpc.klay.sendTransactionAsFeePayer
Signs a fee delegated transaction as a transaction fee payer
with an imported account's private key
in your Klaytn Node and propagates the transaction to the Klaytn.
Before using sendTransaction
as a fee payer, the transaction sender must have signed with valid signature(s) and the nonce
must have been defined.
For more information about each transaction type, refer to Transaction.
NOTE: This API provides the function to sign a transaction using an imported account in your Klaytn node. The imported account in your node must be unlocked to sign a transaction.
Parameters
transaction
object
An instance of fee delegated transaction to send to the Klaytn.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
PromiEvent
A promise combined event emitter. It will be resolved when a transaction receipt is available.
For PromiEvent, the following events are available:
transactionHash
returnsstring
: Is fired right after a transaction is sent and a transaction hash is available.receipt
returnsobject
: Is fired when a transaction receipt is available. See caver.rpc.klay.getTransactionReceipt for more detail.error
returnsError
: Is fired if an error occurs during sending. On an out-of-gas error, the second parameter is the receipt.
Example
caver.rpc.klay.signTransaction
Signs a transaction as a transaction sender with an "imported account's private key" in your Klaytn Node.
For more information about each transaction type, refer to Transaction.
NOTE: This API provides the function to sign a transaction using an imported account in your Klaytn node. The imported account in your node must be unlocked to sign a transaction.
Parameters
transaction
object
An instance of a transaction to sign.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
- An object includes signed transaction:
raw
string
A RLP-encoded signed transaction.
tx
object
The transaction object including the sender's signature.
Example
caver.rpc.klay.signTransactionAsFeePayer
Signs a transaction as a transaction fee payer with an "imported account's private key" in your Klaytn Node.
For more information about each transaction type, refer to Transaction.
NOTE: This API provides the function to sign a transaction using an imported account in your Klaytn node. The imported account in your node must be unlocked to sign a transaction.
Parameters
transaction
object
An instance of a transaction to sign.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
- An object includes signed transaction:
raw
string
A RLP-encoded signed transaction.
tx
object
The transaction object to sign as fee payer.
Example
caver.rpc.klay.getDecodedAnchoringTransactionByHash
Returns the decoded anchored data in the transaction for the given transaction hash.
Parameters
transactionHash
string
A transaction hash.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
- An object includes decoded anchored data:
BlockHash
string
Hash of the child chain block that this anchoring transaction was performed.
BlockNumber
number
The child chain block number that this anchoring transaction was performed.
ParentHash
string
Hash of the parent block.
TxHash
string
The root of the transaction trie of the block.
StateRootHash
string
The root of the final state trie of the block.
ReceiptHash
string
The root of the receipts trie of the block.
BlockCount
number
The number of blocks generated during this anchoring period. In most cases, this number is equal to the child chain's SC_TX_PERIOD
, except the case that this transaction was the first anchoring tx after turning on the anchoring.
TxCount
number
The number of transactions generated in the child chain during this anchoring period.
Example
caver.rpc.klay.getChainId
Returns the chain ID of the chain.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The chain ID of the chain.
Example
caver.rpc.klay.getClientVersion
Returns the current client version of a Klaytn node.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The current client version of a Klaytn node.
Example
caver.rpc.klay.getGasPrice
Returns the current price per gas in peb.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The current gas price in peb.
Example
caver.rpc.klay.getGasPriceAt
Returns the current price per gas in peb for the given block.
Parameters
blockNumber
number
(optional) The block number. If omitted, the latest unit price will be returned.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The current gas price in peb.
Example
caver.rpc.klay.getMaxPriorityFeePerGas
Returns a suggested gas tip cap for dynamic fee transactions in peb. Since Klaytn has a fixed gas price, this returns the gas price set by Klaytn.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The suggested gas tip cap in peb.
Example
caver.rpc.klay.getLowerBoundGasPrice
Returns the lower bound gas price in peb.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The lower bound gas price in peb.
Example
caver.rpc.klay.getUpperBoundGasPrice
Returns the upper bound gas price in peb.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The upper bound gas price in peb.
Example
caver.rpc.klay.getFeeHistory
Returns fee history for the returned block range. This can be a subsection of the requested range if not all blocks are available.
Parameters
blockCount
number\
BigNumber|BN|string
lastBlock
number\
BigNumber|BN|string
rewardPercentiles
Array
A monotonically increasing list of percentile values to sample from each block’s effective priority fees per gas in ascending order, weighted by gas used. (Example: ['0', '25', '50', '75', '100']
or ['0', '0.5', '1', '1.5', '3', '80']
)
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
- An object includes fee history:
oldestBlock
string
Lowest number block of returned range.
reward
Array
A two-dimensional array of effective priority fees per gas at the requested block percentiles.
baseFeePerGas
Array
An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.
gasUsedRatio
Array
An array of gasUsed/gasLimit in the block.
Example
caver.rpc.klay.createAccessList
This method creates an accessList based on a given Transaction. The accessList contains all storage slots and addresses read and written by the transaction, except for the sender account and the precompiles. This method uses the same transaction call object and blockNumberOrTag object as caver.rpc.klay.call
. An accessList can be used to release stuck contracts that became inaccessible due to gas cost increases. Adding an accessList to your transaction does not necessary result in lower gas usage compared to a transaction without an access list.
Parameters
blockParameter
number\
BigNumber|BN|string
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns object
- An object includes an access list:
oldestBlock
string
Lowest number block of returned range.
reward
Array
A two-dimensional array of effective priority fees per gas at the requested block percentiles.
baseFeePerGas
Array
An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.
gasUsedRatio
Array
An array of gasUsed/gasLimit in the block.
Example
caver.rpc.klay.isParallelDBWrite
Returns true
if the node is writing blockchain data in a parallel manner.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns boolean
boolean
true
means the node is writing blockchain data in a parallel manner. It is false
if the node is serially writing the data.
Example
caver.rpc.klay.isSenderTxHashIndexingEnabled
Returns true
if the node is indexing sender transaction hash to transaction hash mapping information.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns boolean
boolean
true
means the node is indexing sender transaction hash to transaction hash mapping information.
Example
caver.rpc.klay.getProtocolVersion
Returns the Klaytn protocol version of the node. The current version (as of v1.9.0) of Cypress/Baobab is istanbul/65
.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The Klaytn protocol version of the node.
Example
caver.rpc.klay.getRewardbase
Returns the rewardbase of the current node. Rewardbase is the address of the account where the block rewards go to. 컨센서스 노드(CN)의 경우에만 해당합니다.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The rewardbase address.
Example
caver.rpc.klay.getFilterChanges
Polling method for a filter, which returns an array of logs since the last poll.
Parameters
filterId
String
The filter id.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns Array
- Array of log objects, or an empty array if nothing has changed since the last poll.
For filters created with caver.rpc.klay.newBlockFilter, the returns are block hashes, e.g.,
["0x3454645634534..."]
.For filters created with caver.rpc.klay.newPendingTransactionFilter, the returns are transaction hashes, e.g.,
["0x6345343454645..."]
.For filters created with caver.rpc.klay.newFilter, logs are objects with the following parameters:
logIndex
string
The log index position in the block.
transactionIndex
string
The index position of transactions where this log was created from.
transactionHash
string
Hash of the transactions this log was created from. null
when pending.
blockHash
string
Hash of the block where this log was in. null
when pending.
blockNumber
string
The block number where this log was in. null
when pending.
address
string
Address from which this log originated.
data
string
Contains the non-indexed arguments of the log.
topics
Array
Array of 0 to 4 32-byte DATA of indexed log arguments. (In Solidity: The first topic is the hash of the signature of the event (e.g., Deposit(address,bytes32,uint256)
), except you declared the event with the anonymous
specifier.).
Example
caver.rpc.klay.getFilterLogs
Returns an array of all logs matching the filter with the given id. The filter object should be obtained by using newFilter.
Note that filter ids returned by other filter creation functions, such as caver.rpc.klay.newBlockFilter or caver.rpc.klay.newPendingTransactionFilter, cannot be used with this function.
Parameters
filterId
string
The filter id.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
See caver.rpc.klay.getFilterChanges
Example
caver.rpc.klay.getLogs
Returns an array of all logs matching a given filter object.
Parameters
options
object
필터 옵션. See the below table to find the description.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
The options object can contain the following:
fromBlock
number \
string
toBlock
number \
string
address
string \
Array
topics
Array
(선택 사항) 로그에 반드시 있어야할 값들이 담긴 배열입니다. 값들의 순서는 중요합니다. If you want to leave topics out, use null
, e.g., [null, '0x12...']
. You can also pass an array for each topic with options for that topic, e.g., [null, ['option1', 'option2']]
.
Return Value
See caver.rpc.klay.getFilterChanges
Example
caver.rpc.klay.newBlockFilter
Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call caver.rpc.klay.getFilterChanges.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
A filter id.
Example
caver.rpc.klay.newFilter
Creates a filter object using the given filter options, to receive the specific state changes (logs).
To check if the state has changed, call caver.rpc.klay.getFilterChanges.
To obtain all logs matching the filter created by
newFilter
, call caver.rpc.klay.getFilterLogs.
For detailed information about the topics in the filter object, please see Klaytn Platform API - klay_newFilter.
Parameters
options
object
The filter options. See the below table to find the description.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
The options object can contain the following:
fromBlock
number \
string
toBlock
number \
string
address
string \
Array
topics
Array
(optional) An array of values that must appear in the log entries. The order is important. If you want to leave topics out, use null
, e.g., [null, '0x12...']
. You can also pass an array for each topic with options for that topic, e.g., [null, ['option1', 'option2']]
.
Return Value
Promise
returns string
string
A filter id.
Example
caver.rpc.klay.newPendingTransactionFilter
Creates a filter in the node, to receive the information about new pending transaction arrival. To check if the state has changed, call caver.rpc.klay.getFilterChanges.
Parameters
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
A filter id.
Example
caver.rpc.klay.uninstallFilter
Uninstalls a filter with a given id. Should always be called when a watch is no longer needed. Additionally, filters time out when they are not being called with caver.rpc.klay.getFilterChanges for a period of time.
Parameters
filterId
string
The filter id.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns boolean
boolean
true
if the filter was successfully uninstalled, otherwise false
.
Example
caver.rpc.klay.sha3
Returns Keccak-256 (not the standardized SHA3-256) of the given data. You can use caver.utils.sha3 instead of this.
Parameters
data
String
The data to be converted into a SHA3 hash.
callback
function
(optional) Optional callback, returns an error object as the first parameter and the result as the second.
Return Value
Promise
returns string
string
The SHA3 result of the given data.
Example
Last updated