Fee Delegation

TxTypeFeeDelegatedValueTransfer

TxTypeFeeDelegatedValueTransfer is used when a user wants to send KLAY. As Klaytn provides multiple transaction types to make each transaction type serve a single purpose, TxTypeFeeDelegatedValueTransfer is limited to send KLAY to an externally owned account. Therefore, TxTypeFeeDelegatedValueTransfer is accepted only if to is an externally owned account. To transfer KLAY to a smart contract account, use TxTypeFeeDelegatedSmartContractExecution instead. The following changes will be made by this transaction type.

  1. The fee payer's balance decreases by the amount of the transaction fee.

  2. The sender's nonce increases by one.

  3. value KLAY is transferred from the sender to the recipient.

Attributes

Attribute
Type
Description

type

uint8 (Go)

The type of TxTypeFeeDelegatedValueTransfer. This must be 0x09.

nonce

uint64 (Go)

A 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.

gasPrice

*big.Int (Go)

A unit price of gas in peb the sender will pay for a transaction fee. The amount of transaction fee is calculated as gas * gasPrice. For example, if the transaction consumes 10 units of gas and gasPrice is 10^18, the transaction fee will be 10 KLAY. See Unit of KLAY.

gas

uint64 (Go)

The maximum amount of gas the transaction is allowed to use.

to

common.Address (Go)

The account address that will receive the transferred value.

value

*big.Int (Go)

The amount of KLAY in peb to be transferred.

from

common.Address (Go)

The address of the sender. For more details, see Signature Validation of Transactions.

txSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The sender's signatures. For more details, see Signature Validation of Transactions.

feePayer

common.Address (Go)

The address of the fee payer.

feePayerSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The fee payer's signatures.

RLP Encoding for Signature of the Sender

To make a signature of the sender, RLP serialization should be done like the following:

RLP Encoding for Signature of the Fee Payer

To make a signature of the fee payer, RLP serialization should be done like the following:

RLP Encoding for SenderTxHash

To make a SenderTxHash, RLP serialization should be done like the following:

RLP Encoding for Transaction Hash

To make a transaction hash, RLP serialization should be done like the following:

RLP Encoding (Example)

The following shows the result of RLP serialization and the transaction object:

RPC Output (Example)

The following shows a transaction object returned via JSON RPC.

TxTypeFeeDelegatedValueTransferMemo

TxTypeFeeDelegatedValueTransferMemo is used when a user wants to send KLAY with a specific message. TxTypeFeeDelegatedValueTransferMemo is accepted only if to is an externally owned account. To transfer KLAY to a smart contract account, use TxTypeFeeDelegatedSmartContractExecution instead. The following changes will be made by this transaction type.

  1. The fee payer's balance decreases by the amount of the transaction fee.

  2. The sender's nonce increases by one.

  3. value KLAY is transferred from the sender to the recipient.

Attributes

Attribute
Description
Type
An example value

type

uint8 (Go)

The type of TxTypeFeeDelegatedValueTransferMemo. This must be 0x11.

nonce

uint64 (Go)

A 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.

gasPrice

*big.Int (Go)

A unit price of gas in peb the sender will pay for a transaction fee. The amount of transaction fee is calculated as gas * gasPrice. For example, if the transaction consumes 10 units of gas and gasPrice is 10^18, the transaction fee will be 10 KLAY. See Unit of KLAY.

gas

uint64 (Go)

The maximum amount of gas the transaction is allowed to use.

to

common.Address (Go)

The account address that will receive the transferred value.

value

*big.Int (Go)

The amount of KLAY in peb to be transferred.

from

common.Address (Go)

The address of the sender. For more details, see Signature Validation of Transactions.

input

[]byte (Go)

Data attached to the transaction. The message should be passed to this attribute.

txSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The sender's signatures. For more details, see Signature Validation of Transactions.

feePayer

common.Address (Go)

The address of the fee payer.

feePayerSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The fee payer's signatures.

RLP Encoding for Signature of the Sender

To make a signature of the sender, RLP serialization should be done like the following:

RLP Encoding for Signature of the Fee Payer

To make a signature of the fee payer, RLP serialization should be done like the following:

RLP Encoding for SenderTxHash

To make a SenderTxHash, RLP serialization should be done like the following:

RLP Encoding for Transaction Hash

To make a transaction hash, RLP serialization should be done like the following:

RLP Encoding (Example)

The following shows the result of RLP serialization and the transaction object:

RPC Output (Example)

The following shows a transaction object returned via JSON RPC.

TxTypeFeeDelegatedSmartContractDeploy

TxTypeFeeDelegatedSmartContractDeploy deploys a smart contract with fee delegation. The following changes will be made by this transaction type.

  1. The fee payer's balance decreases by the amount of the transaction fee.

  2. The sender's nonce increases by one.

  3. A smart contract is deployed with the code in input. The deployed address will be returned via contractAddress in the receipt.

  4. value KLAY is transferred from the sender to the recipient.

Attributes

Attribute
Type
Description

type

uint8 (Go)

The type of TxTypeFeeDelegatedSmartContractDeploy. This must be 0x29.

nonce

uint64 (Go)

A 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.

gasPrice

*big.Int (Go)

A unit price of gas in peb the sender will pay for a transaction fee. The amount of transaction fee is calculated as gas * gasPrice. For example, if the transaction consumes 10 units of gas and gasPrice is 10^18, the transaction fee will be 10 KLAY. See Unit of KLAY.

gas

uint64 (Go)

The maximum amount of gas the transaction is allowed to use.

to

*common.Address (Go)

The account address that will receive the transferred value. Currently, this value must be nil. Specifying the address will be supported in the future.

value

*big.Int (Go)

The amount of KLAY in peb to be transferred.

from

common.Address (Go)

The address of the sender. For more details, see Signature Validation of Transactions.

input

[]byte (Go)

Data attached to the transaction, used for transaction execution.

humanReadable

bool (Go)

This must be false since human-readable address is not supported yet. If true, the transaction will be rejected.

codeFormat

uint8 (Go)

The code format of smart contract code. The supported value for now is EVM(0x00) only.

txSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The sender's signatures. For more details, see Signature Validation of Transactions.

feePayer

common.Address (Go)

The address of the fee payer.

feePayerSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The fee payer's signatures.

RLP Encoding for Signature of the Sender

To make a signature of the sender, RLP serialization should be done like the following:

RLP Encoding for Signature of the Fee Payer

To make a signature of the fee payer, RLP serialization should be done like the following:

RLP Encoding for SenderTxHash

To make a SenderTxHash, RLP serialization should be done like the following:

RLP Encoding for Transaction Hash

To make a transaction hash, RLP serialization should be done like the following:

RLP Encoding (Example)

The following shows the result of RLP serialization and the transaction object:

RPC Output (Example)

The following shows a transaction object returned via JSON RPC.

TxTypeFeeDelegatedSmartContractExecution

TxTypeFeeDelegatedSmartContractExecution executes a smart contract with the given data in input. Fee will be paid by the given fee payer. TxTypeFeeDelegatedSmartContractExecution is accepted only if to is a smart contract account. To transfer KLAY to an externally owned account, use TxTypeFeeDelegatedValueTransfer instead. The following changes will be made by this transaction type.

  1. If to is a smart contract account, the code is executed based on input. Otherwise, this transaction will be rejected.

  2. The fee payer's balance decreases by the amount of the transaction fee.

  3. The sender's nonce increases by one.

  4. If value was provided, value KLAY is transferred from the sender to the to smart contract. The contract should have a payable fallback function to receive KLAY.

Attributes

Attribute
Type
Description

type

uint8 (Go)

The type of TxTypeFeeDelegatedSmartContractExecution. This must be 0x31.

nonce

uint64 (Go)

A 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.

gasPrice

*big.Int (Go)

A unit price of gas in peb the sender will pay for a transaction fee. The amount of transaction fee is calculated as gas * gasPrice. For example, if the transaction consumes 10 units of gas and gasPrice is 10^18, the transaction fee will be 10 KLAY. See Unit of KLAY.

gas

uint64 (Go)

The maximum amount of gas the transaction is allowed to use.

to

common.Address (Go)

The address of the smart contract account to be executed.

value

*big.Int (Go)

The amount of KLAY in peb to be transferred.

from

common.Address (Go)

The address of the sender. For more details, see Signature Validation of Transactions.

input

[]byte (Go)

Data attached to the transaction, used for transaction execution.

txSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The sender's signatures. For more details, see Signature Validation of Transactions.

feePayer

common.Address (Go)

The address of the fee payer.

feePayerSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The fee payer's signatures.

RLP Encoding for Signature of the Sender

To make a signature of the sender, RLP serialization should be done like the following:

RLP Encoding for Signature of the Fee Payer

To make a signature of the fee payer, RLP serialization should be done like the following:

RLP Encoding for SenderTxHash

To make a SenderTxHash, RLP serialization should be done like the following:

RLP Encoding for Transaction Hash

To make a transaction hash, RLP serialization should be done like the following:

RLP Encoding (Example)

The following shows the result of RLP serialization and the transaction object:

RPC Output (Example)

The following shows a transaction object returned via JSON RPC.

TxTypeFeeDelegatedAccountUpdate

TxTypeFeeDelegatedAccountUpdate updates the key of the given account. The transaction fee is paid by the fee payer. The following changes will take place by this transaction type.

  1. The fee payer's balance decreases by the amount of the transaction fee.

  2. The sender's nonce increases by one.

  3. The account's key is updated with key.

  4. Once this type of transaction is executed, transactions sent from the account afterward will be validated with the new key.

  5. The transaction fee is paid by the fee payer.

Attributes

Attribute
Type
Description

type

uint8 (Go)

The type of TxTypeAccountUpdate. This must be 0x21.

nonce

uint64 (Go)

A 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.

gasPrice

*big.Int (Go)

A 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 KLAY for a transaction fee if gas is 10 and gasPrice is 10^18. See Unit of KLAY.

gas

uint64 (Go)

The maximum amount of transaction fee the transaction is allowed to use.

from

common.Address (Go)

The address of the sender. For more details, see Signature Validation of Transactions.

key

AccountKey (Go)

AccountKey to be updated to the account.

txSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The sender's signatures. For more details, see Signature Validation of Transactions.

feePayer

common.Address (Go)

The address of the fee payer.

feePayerSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The fee payer's signatures.

RLP Encoding for Signature of the Sender

To make a signature of the sender, RLP serialization should be done like the following:

RLP Encoding for Signature of the Fee Payer

To make a signature of the fee payer, RLP serialization should be done like the following:

RLP Encoding for SenderTxHash

To make a SenderTxHash, RLP serialization should be done like the following:

RLP Encoding for Transaction Hash

To make a transaction hash, RLP serialization should be done like the following:

RLP Encoding (Example)

The following shows the result of RLP serialization and the transaction object:

RPC Output (Example)

The following shows a transaction object returned via JSON RPC.

TxTypeFeeDelegatedCancel

TxTypeFeeDelegatedCancel cancels the execution of the transaction with the same nonce in the transaction pool. For more details, see TxTypeCancel.

The following changes will apply by this transaction type. 1. The fee payer's balance decreases by the amount of the transaction fee. 2. The sender's nonce increases by one.

Attributes

Attribute
Type
Description

type

uint8 (Go)

The type of TxTypeCancel. This must be 0x39.

nonce

uint64 (Go)

A 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.

gasPrice

*big.Int (Go)

A unit price of gas in peb the sender will pay for a transaction fee. The amount of transaction fee is calculated as gas * gasPrice. For example, if the transaction consumes 10 units of gas and gasPrice is 10^18, the transaction fee will be 10 KLAY. See Unit of KLAY.

gas

uint64 (Go)

The maximum amount of transaction fee the transaction is allowed to use.

from

common.Address (Go)

The address of the sender. For more details, see Signature Validation of Transactions.

txSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The sender's signatures. For more details, see Signature Validation of Transactions.

feePayer

common.Address (Go)

The address of the fee payer.

feePayerSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The fee payer's signatures.

RLP Encoding for Signature of the Sender

To make a signature of the sender, RLP serialization should be done like the following:

RLP Encoding for Signature of the Fee Payer

To make a signature of the fee payer, RLP serialization should be done like the following:

RLP Encoding for SenderTxHash

To make a SenderTxHash, RLP serialization should be done like the following:

RLP Encoding for Transaction Hash

To make a transaction hash, RLP serialization should be done like the following:

RLP Encoding (Example)

The following shows the result of RLP serialization and the transaction object:

RPC Output (Example)

The following shows a transaction object returned via JSON RPC.

TxTypeFeeDelegatedChainDataAnchoring

TxTypeFeeDelegatedChainDataAnchoring is a fee-delegated transaction that anchors service chain data to the Klaytn mainchain. Service chains periodically send this type of transaction to the Klaytn mainchain to ensure its security and credibility of data. For more details about the data anchoring, see Anchoring. As it is a fee-delegated transaction as well, its transaction fee is charged to the fee payer. Be mindful that it is not allowed to send this transaction via RPC. Currently, this transaction is executed through private p2p channels for security reasons. This transaction does not change the state of the Klaytn blockchain except the sender's nonce being increased by one.

Attributes

Attribute
Type
Description

type

uint8 (Go)

The type of TxTypeFeeDelegatedChainDataAnchoring. This must be 0x49.

nonce

uint64 (Go)

A 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.

gasPrice

*big.Int (Go)

A unit price of gas in peb the sender will pay for a transaction fee. The amount of transaction fee is calculated as gas * gasPrice. For example, if the transaction consumes 10 units of gas and gasPrice is 10^18, the transaction fee will be 10 KLAY. See Unit of KLAY.

gas

uint64 (Go)

The maximum amount of transaction fee the transaction is allowed to use.

from

common.Address (Go)

The address of the sender. For more details, see Signature Validation of Transactions.

input

[]byte (Go)

Data of the service chain.

txSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The sender's signatures. For more details, see Signature Validation of Transactions.

feePayer

common.Address (Go)

The address of the fee payer.

feePayerSignatures

[]{*big.Int, *big.Int, *big.Int} (Go)

The fee payer's signatures.

RLP Encoding for Signature of the Sender

To make a signature of the sender, RLP serialization should be done like the following:

RLP Encoding for Signature of the Fee Payer

To make a signature of the fee payer, RLP serialization should be done like the following:

RLP Encoding for SenderTxHash

To make a SenderTxHash, RLP serialization should be done like the following:

RLP Encoding for Transaction Hash

To make a transaction hash, RLP serialization should be done like the following:

RLP Encoding (Example)

The following shows the result of RLP serialization and the transaction object:

RPC Output (Example)

The following shows a transaction object returned via JSON RPC.

Last updated