Value Transfer
TxTypeValueTransfer is used when a user wants to send KAIA.
- As kaia provides multiple transaction types to make each transaction type serve a single purpose, TxTypeValueTransfer is limited to send KAIA to an externally owned account (EOA).
Import the web3 and @kaiachain/web3js-ext packages to add kaia features on web3
Define sender, fee payer addresses and private keys
Set up the provider with the specified kairos testnet URL. A provider in web3 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 private key using web3.eth.accounts.privateKeyToAccount
Create a fee payer's wallet with the private key using web3.eth.accounts.privateKeyToAccount
Define the transaction object.
Set type: TxType.FeeDelegatedValueTransfer
for transaction to send a value transfer with a fee payer
Set value: toPeb("0.01")
to define the value to be transfered, use toPeb
to convert Klay to Peb
Set others params like from, to
Sign the transaction with sender account using signTransaction
Sign the transaction with fee payer account using signTransactionAsFeePayer
Send the transaction to blockchain. It will return the transaction receipt