跳至主要內容
本頁面使用機器翻譯自英語,可能包含錯誤或不清楚的語言。如需最準確的信息,請參閱英文原文。由於更新頻繁,部分內容可能與英文原文有出入。請加入我們在 Crowdin 上的努力,幫助我們改進本頁面的翻譯。 (Crowdin translation page, Contributing guide)

實作交易

本指南提供在 Kaia 網路上實作交易的全面概觀,涵蓋各種交易類型、編碼、簽章和網路互動。

Kaia 交易元件

Kaia 交易一般包括下列元件:

組件說明
from寄件者的地址。 由於 key 對和位址的解耦,對於大多數 Kaia 交易類型是必需的。
to接收轉賬金額的賬戶地址。
valuekei 為單位的 KAIA 轉賬金額。
input附屬於事務的數據,用於執行事務。
v, r, s發送方為讓接收方獲取發送方地址而生成的加密簽名。
nonce用於唯一標識發件人交易的值。 如果一個發送方生成了兩個具有相同 nonce 的交易,則只執行其中一個。
gas交易允許使用的最高交易費金額。
gasPrice一個乘數,用於計算發件人將支付多少代幣。 發送方將支付的代幣數量通過 gas * gasPrice 計算得出。 例如,如果 gas 為 10,gasPrice 為 10^18,發件人將支付 10 KAIA 的交易費。 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

典型的區塊鏈平臺只提供一種交易類型,而 Kaia 則提供多種交易類型,為交易提供了新的功能,並優化了內存佔用和性能。 The following table provides an overview of the transaction types available on Kaia:

基礎收費代表團部分費用授權
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.

讓這個頁面變得更好