sendRawTransaction - Invalid transaction v, r, s values of the sender

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?

It’s weird. I just checked the same code in my local environment, and it worked correctly.

The error message is returned when the “from” address is not the same as the singer of the transaction. Can you check whether you put the correct private key, and the “from” address is the same as what you intended?

It also could happen if you have updated your account key. But, I think it probably is not because the account key update is a very advanced feature.