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 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 private key which is the transaction role key
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