Hello, I am trying to send a transaction and I am using the code specified in the official documentation.
Here is my code:
const Caver = require('caver-js')
const caver = new Caver('https://public-en-cypress.klaytn.net/')
async function testFunction() {
// Add a keyring to caver.wallet
const keyring = caver.wallet.keyring.createFromPrivateKey(
'0x...' //just replaced for the example
)
caver.wallet.add(keyring)
// Create a value transfer transaction
const tx = caver.transaction.valueTransfer.create({
from: keyring.address,
to: '0x...', //just replaced for the example
value: caver.utils.toPeb(1, caver.utils.klayUnit.KLAY.unit),
gas: 30000,
})
// Sign the transaction via caver.wallet.sign
await caver.wallet.sign(keyring.address, tx)
// Send the transaction using caver.rpc.klay.sendRawTransaction.
const receipt = await caver.rpc.klay.sendRawTransaction(tx)
console.log(receipt)
}
testFunction()
But I receive the following error:
Error: Returned error: invalid transaction v, r, s values of the sender
Why? How can I fix it?