Public Account Key
AccountKeyPublic is used for accounts having one public key. If an account has an AccountKeyPublic object, the transaction validation process is done like below:
Import necessary classes from the Web3j and kaia libraries(web3j-ext
).
Create a Web3j instance with the specified BAOBAB_URL
Also, you can change the default provider. For example, using the alchemy provider.
Create a credential from a key pair which is a public key type
Gas price and gas limit settings
Set the sender address equal to the loaded credential's address
Get chain ID from the network
Set the receiver address equal to any valid address
Get the nonce for the sender's address
Set the value to transfer
Set transaction type as VALUE_TRANSFER
Create a raw transaction for value transfer
Sign the transaction
Send the signed transaction to kaia network
Recover the sender address from signed transaction and compare it to the from address
Shut down the Web3j instance