제가 해당 doc을 보고 visual studio code를 받아서 caver-js를 설치(?)하고 1클레이를 전송하는 코드를 실행하는데서부터 에러가 나고, 에러 내용을 파악할 수가 없어 막혀있는 상태인데, 혹시 어떤게 문제인지 봐주실수 있으실까요?
실행코드입니다
const Caver = require(‘caver-js’)
const caver = new Caver(‘https://your.en.url:8651/’) // Boabob testnet
async function testFunction() {
// Create a keyring with an address and a private key
const keyring = caver.wallet.keyring.createWithSingleKey(address, private)
caver.wallet.add(keyring)
console.log(caver.wallet.getKeyring(keyring.address))
// Create a value transfer transaction
const valueTransfer = caver.transaction.valueTransfer.create({
from: keyring.address,
to: to_address,
value: 1,
gas: 8000000,
})
console.log("from: ", keyring.address, "to: ", to_address)
// Sign the transaction via transaction.sign
await valueTransfer.sign(keyring)
console.log(1)
// Send the transaction to the Klaytn using `caver.rpc.klay.sendRawTransaction`.
const receipt = await caver.rpc.klay.sendRawTransaction(valueTransfer)
console.log(receipt)
}
testFunction()
에러메세지는 아래와 같습니다.
(node:48544) UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response: “”
at Object.InvalidResponse (d:\Nodejs\Kaikas2\kaikas-tutorial\node_modules\caver-js\packages\caver-core-helpers\src\errors.js:92:16)
at XMLHttpRequest.request.onreadystatechange (d:\Nodejs\Kaikas2\kaikas-tutorial\node_modules\caver-js\packages\caver-core-requestmanager\caver-providers-http\src\index.js:118:32)
at XMLHttpRequestEventTarget.dispatchEvent (d:\Nodejs\Kaikas2\kaikas-tutorial\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (d:\Nodejs\Kaikas2\kaikas-tutorial\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
at XMLHttpRequest._onHttpRequestError (d:\Nodejs\Kaikas2\kaikas-tutorial\node_modules\xhr2-cookies\dist\xml-http-request.js:349:14)
at ClientRequest. (d:\Nodejs\Kaikas2\kaikas-tutorial\node_modules\xhr2-cookies\dist\xml-http-request.js:252:61)
at ClientRequest.emit (events.js:400:28)
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
(Use node --trace-warnings ... to show where the warning was created)
<node_internals>/internal/process/warning.js:45
(node:48544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line API | Node.js v17.5.0 Documentation). (rejection id: 1)
<node_internals>/internal/process/warning.js:45
(node:48544) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.