Account Update
Fee Delegation
Import the ethers and @kaiachain/viem-ext packages to add kaia features on web3
Set up sender and fee payer wallets using createWalletClient, configured with the Kairos chain, an HTTP transport, and the sender’s private key converted to an account.
Uses the ethers library to compute the compressed public key from the sender’s private key. This public key will be used to update the sender’s account key on the Kaia blockchain.
Create a transaction request for a value transfer using prepareTransactionRequest, specifying the sender’s account, recipient address, value to transfer (0 KLAY in this example), transaction type (TxType.FeeDelegatedAccountUpdate) and the key field specifies the new public key with type AccountKeyType.Public.
Signing the transaction with the wallet client’s signTransaction method, and log the transaction hash.
The fee payer signs the already-signed transaction from the sender with function signTransactionAsFeePayer
, agreeing to pay the transaction fees.
Sends the fully signed, fee-delegated transaction (signed by both sender and fee payer) to the Kairos blockchain network using the kaia_sendRawTransaction
method, returning the transaction hash or response from the network.