Role-based Account Key
AccountKeyRoleBased represents a role-based key. If an account has an AccountKeyRoleBased object and the transaction type is one except account update, the validation process is done according to each roles like below:
Import the ethers and @kaiachain/ethers-ext packages to add kaia features on ethers.js
Define sender address, sender private key and new role-based private keys to be changed
Set up the provider with the specified Kairos testnet URL. A provider in ethers is a read-only abstraction to access the blockchain data.
Also, you can change the provider URL from kairos to quicknode
Create a sender's wallet with the updater role private key and provider
Compute the public keys from the new role-based private keys
Declare a transaction in the keys field with the computed role-based public keys
Send the tx to the blockchain. Function sendTransaction
internally signs with the private key of the account and then transmits it to the blockchain network.
The wait function returns the tx receipt if it is completed in the blockchain.