跳至主要内容
本页面使用机器翻译自英语,可能包含错误或不清楚的语言。如需最准确的信息,请参阅英文原文。由于更新频繁,部分内容可能与英文原文有出入。请加入我们在 Crowdin 上的努力,帮助我们改进本页面的翻译。 (Crowdin translation page, Contributing guide)

Implementing Transactions

This guide provides a comprehensive overview of implementing transactions on the Kaia network, covering various transaction types, encoding, signing, and network interaction.

Kaia Transaction Components

Kaia transactions generally include the following components:

ComponentsDescription
fromThe sender's address. Required for most Kaia transaction types due to the decoupling of key pairs and addresses.
toThe account address that will receive the transferred value.
valueThe amount of KAIA in kei to be transferred.
inputData attached to the transaction, used for transaction execution.
v, r, sThe cryptographic signature generated by the sender to let the receiver obtain the sender's address.
nonceA value used to uniquely identify a sender’s transaction. If two transactions with the same nonce are generated by a sender, only one is executed.
gasThe maximum amount of transaction fee the transaction is allowed to use.
gasPriceA multiplier to get how much the sender will pay in tokens. The amount of tokens the sender will pay is calculated via gas * gasPrice. For example, the sender will pay 10 KAIA for a transaction fee if gas is 10 and gasPrice is 10^18. Unit of KAIA is described here.

Signature Validation

Because Kaia decouples key pairs from addresses, signature validation differs from typical blockchains. The from field is crucial, as it identifies the sender. The AccountKey associated with the from address is used to validate the signature.

Fee Delegation and SenderTxHash

Kaia's fee delegation feature allows a third party to pay transaction fees. This requires two signatures – one from the sender and one from the fee payer. The SenderTxHash is crucial for tracking fee-delegated transactions. It's a hash of the transaction without the fee payer's information, allowing the sender to track the transaction before the fee payer signs it. The sender can use the SenderTxHash to retrieve the complete transaction via the kaia_getTransactionBySenderTxHash RPC method.

Transaction Types

While typical Blockchain platforms provide a single transaction type, Kaia provides multiple transaction types that empower transactions with new capabilities and optimizations for memory footprint and performance. The following table provides an overview of the transaction types available on Kaia:

BasicFee DelegationPartial Fee Delegation
LegacyTxTypeLegacyTransactionN/AN/A
ValueTransferTxTypeValueTransferTxTypeFeeDelegatedValueTransferTxTypeFeeDelegatedValueTransferWithRatio
ValueTransferMemoTxTypeValueTransferMemoTxTypeFeeDelegatedValueTransferMemoTxTypeFeeDelegatedValueTransferMemoWithRatio
SmartContractDeployTxTypeSmartContractDeployTxTypeFeeDelegatedSmartContractDeployTxTypeFeeDelegatedSmartContractDeployWithRatio
SmartContractExecutionTxTypeSmartContractExecutionTxTypeFeeDelegatedSmartContractExecutionTxTypeFeeDelegatedSmartContractExecutionWithRatio
AccountUpdateTxTypeAccountUpdateTxTypeFeeDelegatedAccountUpdateTxTypeFeeDelegatedAccountUpdateWithRatio
CancelTxTypeCancelTxTypeFeeDelegatedCancelTxTypeFeeDelegatedCancelWithRatio
ChainDataAnchoringTxTypeChainDataAnchoringTxTypeFeeDelegatedChainDataAnchoringTxTypeFeeDelegatedChainDataAnchoringWithRatio

Implementation Details

  • RLP Encoding: Transactions are serialized using Recursive Length Prefix (RLP) encoding before submission.
  • Signatures: Transactions are signed using [Specify signature algorithm, e.g., ECDSA] to ensure authenticity.
  • Examples and RPC Outputs: This section will provide practical examples and expected RPC outputs for each transaction type. (Note: TxTypeValueTransfer sends KAIA without any additional data, while TxTypeValueTransferMemo allows for including a short memo field along with the transfer.)

By understanding these components and implementation details, developers can effectively build applications on the Kaia network.

让这个页面变得更好