Account Update
Import the web3 and @kaiachain/web3js-ext packages to add kaia features on web3
Define sender address, sender private key and new private key to be changed
Define fee payer address and private key
Set up the provider with the specified kaia Baobab testnet URL. A provider in web3 is a read-only abstraction to access the blockchain data.
Also, you can change the provider URL from baobab to allthatnode
Create a sender's wallet with the private key using web3.eth.accounts.privateKeyToAccount
Create a fee payer's wallet with the private key using web3.eth.accounts.privateKeyToAccount
Generating the public key from the new private key using getPublicKeyFromPrivate
Creating a transaction object with type: TxType.FeeDelegatedAccountUpdate
and key
contains new public key
Sign the transaction with the sender account
Use fee payer account to sign the transaction with signTransactionAsFeePayer
Send the signed transaction to blockchain with web3.eth.sendSignedTransaction
. It will return the transaction receipt