JSON-RPC API
이 페이지는 Node API로 Klaytn Endpoint Node가 제공하는 JSON-RPC 함수들을 호출하는 법을 안내합니다.
튜토리얼에 앞서
API 호출에 사용되는
x-chain-id
값은 8217(Cypress) 또는 1001(Baobab)입니다.API 호출에 필요한 필수 파라미터는 각 예시에 설명됩니다.
API 호출 시 사용자가 입력해야 하는 값은 중괄호 1개({}
)로 표시합니다. 사용자가 입력해야 하는 값은 아래 테이블과 같습니다.
항목 | 값 | 비고 |
chain-id | 8217 또는 1001 | Cypress(Klaytn 메인넷) 또는 Baobab(Klaytn 테스트넷) |
access-key-id | 인증 아이디 | KAS 콘솔 - Security - Credential에서 발급받은 |
secret-access-key | 인증 비밀번호 | KAS 콘솔 - Security - Credential에서 발급받은 |
krn | (optional) 계정 저장소의 ID | 기본 계정 저장소 사용 시 불필요 |
API 인증 키가 있으면 모든 KAS 서비스를 사용할 수 있으며 Wallet API를 호출해 만든 Klaytn 계정에 대한 모든 권한을 소유합니다. 모든 권한에는 Klaytn 계정의 자산(KLAY 등) 이동이나 트랜잭션 전송 및 실행 권한이 포함됩니다. 만약 API 인증 키에 타인이 접근한다면 Klaytn 계정 권한을 탈취당해 원치 않는 트랜잭션이 발생할 수 있습니다.
KAS/Klaytn 계정 보안을 위해 KAS API 인증 키(Secret Access Key)를 타인과 함부로 공유하지 말고 주의해 관리하십시오.
KAS SDK(caver-js/caver-java extension) 설치, 실행에 관한 자세한 내용은 KAS SDK를 확인하십시오. Klaytn Node에서 Klaytn 계정 정보를 확인하려면 계정 저장소와 계정을 생성하고 사용할 계정을 선택해야 합니다. 계정 저장소 생성, 계정 생성, 계정 선택에 관한 자세한 내용은 Getting Started를 확인하십시오.
Klaytn Node에서 Klaytn 계정 정보 확인하기
가장 최근에 생성된 블록 번호 확인하기
Node API로 여러분 계정의 잔고, 계정 키 타입 등 계정에 관한 가장 최신 정보를 확인하려면 클레이튼상에 있는 가장 최신 블록의 블록 번호를 알아야합니다. 이를 위해 JSON-RPC 요청 { "method": "klay_blockNumber", "id": 1 }
을 보내고 최신의 블록 번호를 요청합니다.
Node API에 관한 더 자세한 내용은 다음을 확인하십시오.
API 호출
id
는 임의의 값입니다.params
,jsonrpc
는 생략 가능합니다.
API 호출에 관한 더 자세한 내용은 다음을 확인하십시오.
Node API는 매번 다른 클레이튼 엔드포인트 노드를 호출하며 블록 번호에 pending
을 입력할 경우 결과값이 기대와 다를 수 있습니다.
API 응답
API가 성공적으로 실행되면 다음과 같은 응답을 받습니다.
result
는 16진수로 표현된 블록 번호값입니다.
Klaytn JSON-RPC API에 관한 더 자세한 내용은 다음을 확인하십시오. 이 API에 관한 자세한 내용은 다음을 확인하십시오. 이 문서 혹은 KAS에 관한 문의는 개발자 포럼을 방문해 도움을 받으십시오.
EOA로 Klaytn 계정 정보 확인하기
API 호출
블록 번호와 클레이튼 계정 주소(EOA)를 입력하고 계정 정보를 조회하는 JSON-RPC 함수 klay_getAccount
를 실행합니다. klay_getAccount
는 주소(필수)와 블록번호/태그(필수 또는 선택) 파라미터를 받습니다. curl 등 HTTP 방식으로 직접 RPC를 호출할 경우 블록번호/태그는 필수 파라미터입니다.
id
는 임의의 값입니다.jsonrpc
는 생략 가능합니다.클레이튼 계정 주소값
0x3111a0577f322e8fb54f78d9982a26ae7ca0f722
은 예시값입니다.SDK(caver-js, caver-java)는 구현에 따라 블록번호/태그를 생략 가능합니다. 이 경우
"latest"
태그가 사용됩니다.
API 호출에 관한 더 자세한 내용은 다음을 확인하십시오.
Node API는 매번 다른 클레이튼 엔드포인트 노드를 호출하며 블록 번호에 pending
을 입력할 경우 결과값이 기대와 다를 수 있습니다.
API 응답
API가 성공적으로 실행되면 다음과 같이 입력한 EOA를 가지고 있는 클레이튼 계정 정보를 나타내는 응답을 받습니다.
Klaytn JSON-RPC API에 관한 더 자세한 내용은 다음을 확인하십시오. 이 API에 관한 자세한 내용은 다음을 확인하십시오. 이 문서 혹은 KAS에 관한 문의는 개발자 포럼을 방문해 도움을 받으십시오.
KAS에서 현재 지원하는 Node API 목록
위에서 안내한 방식으로 Klaytn의 다른 JSON-RPC API도 KAS에서 호출할 수 있습니다. 단, 현재 KAS는 일부 Node API만을 지원합니다. 현재 KAS에서 지원하는 Node API 목록은 아래와 같습니다.
Category | Module | Method | Support |
Platform | Account | klay_isContractAccount | O |
Platform | Account | klay_getTransactionCount | O |
Platform | Account | klay_getCode | O |
Platform | Account | klay_getBalance | O |
Platform | Account | klay_getAccountKey | O |
Platform | Account | klay_getAccount | O |
Platform | Account | klay_accountCreated | O |
Platform | Account | klay_encodeAccountKey | O |
Platform | Account | klay_decodeAccountKey | O |
Platform | Block | klay_syncing | O |
Platform | Block | klay_getStorageAt | O |
Platform | Block | klay_getCouncilSize | O |
Platform | Block | klay_getCouncil | O |
Platform | Block | klay_getCommitteeSize | O |
Platform | Block | klay_getCommittee | O |
Platform | Block | klay_getBlockWithConsensusInfoByNumber | O |
Platform | Block | klay_getBlockWithConsensusInfoByHash | O |
Platform | Block | klay_getBlockTransactionCountByNumber | O |
Platform | Block | klay_getBlockTransactionCountByHash | O |
Platform | Block | klay_getBlockReceipts | O |
Platform | Block | klay_getBlockByNumber | O |
Platform | Block | klay_getBlockByHash | O |
Platform | Block | klay_blockNumber | O |
Platform | Configuration | klay_protocolVersion | O |
Platform | Configuration | klay_gasPriceAt | O |
Platform | Configuration | klay_gasPrice | O |
Platform | Configuration | klay_clientVersion | O |
Platform | Configuration | klay_chainID | O |
Platform | Filter | klay_getLogs | O |
Platform | Miscellaneous | klay_sha3 | O |
Platform | Transaction | klay_sendRawTransaction | O |
Platform | Transaction | klay_getTransactionReceipt | O |
Platform | Transaction | klay_getTransactionByHash | O |
Platform | Transaction | klay_getTransactionByBlockNumberAndIndex | O |
Platform | Transaction | klay_getTransactionByBlockHashAndIndex | O |
Platform | Transaction | klay_estimateGas | O |
Platform | Transaction | klay_estimateComputationCost | O |
Platform | Transaction | klay_call | O |
Network | net | net_peerCountByType | O |
Network | net | net_peerCount | O |
Network | net | net_networkID | O |
Network | net | net_listening | O |
Platform | Account | klay_sign | X |
Platform | Account | klay_accounts | X |
Platform | Block | klay_mining | X |
Platform | Filter | klay_uninstallFilter | X |
Platform | Filter | klay_newPendingTransactionFilter | X |
Platform | Filter | klay_newFilter | X |
Platform | Filter | klay_newBlockFilter | X |
Platform | Filter | klay_getFilterLogs | X |
Platform | Filter | klay_getFilterChanges | X |
Debug | Blockchain Inspection | debug_setHead | X |
Debug | Blockchain Inspection | debug_printBlock | X |
Debug | Blockchain Inspection | debug_preimage | X |
Debug | Blockchain Inspection | debug_getModifiedAccountsByNumber | X |
Debug | Blockchain Inspection | debug_getModifiedAccountsByHash | X |
Debug | Blockchain Inspection | debug_getBlockRlp | X |
Debug | Blockchain Inspection | debug_dumpBlock | X |
Platform | Configuration | klay_writeThroughCaching | X |
Platform | Configuration | klay_rewardbase | X |
Platform | Configuration | klay_isSenderTxHashIndexingEnabled | X |
Platform | Configuration | klay_isParallelDBWrite | X |
Governance | Governance | governance_vote | X |
Governance | Governance | governance_totalVotingPower | X |
Governance | Governance | governance_showTally | X |
Governance | Governance | governance_nodeAddress | X |
Governance | Governance | governance_myVotingPower | X |
Governance | Governance | governance_myVotes | X |
Governance | Governance | governance_itemsAt | X |
Governance | Governance | governance_chainConfig | X |
Debug | Logging | debug_vmodule | X |
Debug | Logging | debug_verbosity | X |
Debug | Logging | debug_setVMLogTarget | X |
Debug | Logging | debug_backtraceAt | X |
service chain | Main-bridge | convertServiceChainBlockHashToMainChainTxHash | X |
Debug | Profiling | debug_writeMemProfile | X |
Debug | Profiling | debug_writeBlockProfile | X |
Debug | Profiling | debug_stopPProf | X |
Debug | Profiling | debug_stopCPUProfile | X |
Debug | Profiling | debug_startPProf | X |
Debug | Profiling | debug_startCPUProfile | X |
Debug | Profiling | debug_setBlockProfileRate | X |
Debug | Profiling | debug_isPProfRunning | X |
Debug | Profiling | debug_cpuProfile | X |
Debug | Profiling | debug_blockProfile | X |
Debug | Runtime Debugging | debug_stacks | X |
Debug | Runtime Debugging | debug_setGCPercent | X |
Debug | Runtime Debugging | debug_metrics | X |
Debug | Runtime Debugging | debug_memStats | X |
Debug | Runtime Debugging | debug_gcStats | X |
Debug | Runtime Debugging | debug_freeOSMemory | X |
Debug | Runtime Tracing | debug_stopGoTrace | X |
Debug | Runtime Tracing | debug_startGoTrace | X |
Debug | Runtime Tracing | debug_goTrace | X |
service chain | Sub-bridge | sendChainTxslimit | X |
service chain | Sub-bridge | latestAnchoredBlockNumber | X |
service chain | Sub-bridge | anchoring | X |
Platform | Transaction | klay_signTransaction | X |
Platform | Transaction | klay_sendTransaction | X |
Platform | Transaction | klay_getTransactionReceiptBySenderTxHash | X |
Platform | Transaction | klay_getTransactionBySenderTxHash | X |
Debug | VM Standard Tracing | debug_standardTraceBlockToFile | X |
Debug | VM Standard Tracing | debug_standardTraceBadBlockToFile | X |
Debug | VM Tracing | debug_traceTransaction | X |
Debug | VM Tracing | debug_traceBlockFromFile | X |
Debug | VM Tracing | debug_traceBlockByNumber | X |
Debug | VM Tracing | debug_traceBlockByHash | X |
Debug | VM Tracing | debug_traceBlock | X |
Debug | VM Tracing | debug_traceBadBlock | X |
Management | admin | admin_stopWS | X |
Management | admin | admin_stopRPC | X |
Management | admin | admin_startWS | X |
Management | admin | admin_startRPC | X |
Management | admin | admin_removePeer | X |
Management | admin | admin_peers | X |
Management | admin | admin_nodeInfo | X |
Management | admin | admin_importChain | X |
Management | admin | admin_exportChain | X |
Management | admin | admin_datadir | X |
Management | admin | admin_addPeer | X |
service chain | service chain | removePeer | X |
service chain | service chain | nodeInfo | X |
service chain | service chain | addPeer | X |
Management | personal | personal_unlockAccount | X |
Management | personal | personal_sign | X |
Management | personal | personal_sendValueTransfer | X |
Management | personal | personal_sendTransaction | X |
Management | personal | personal_sendAccountUpdate | X |
Management | personal | personal_replaceRawKey | X |
Management | personal | personal_newAccount | X |
Management | personal | personal_lockAccount | X |
Management | personal | personal_listAccounts | X |
Management | personal | personal_importRawKey | X |
Management | personal | personal_ecRecover | X |
Management | txpool | txpool_status | X |
Management | txpool | txpool_inspect | X |
Management | txpool | txpool_content | X |
이 문서 혹은 KAS에 관한 문의는 개발자 포럼을 방문해 도움을 받으십시오.
Last updated