Ethereum
Last updated
Last updated
Klaytn provides wrapped transaction types to support Ethereum compatibility. Ethereum transaction types in Klaytn have the same attributes and RLP encoding schemes with Ethereum's design except for the single-byte type delimiter called EthereumTxTypeEnvelope
. Therefore, users can successfully deploy transactions generated by Ethereum development tools on Klaytn. The type delimiter is also omitted when users use eth
namespace APIs, so they can use Klaytn just as if they were using Ethereum. Using klay
namespace APIs, users can deploy and retrieve Ethereum formatted transactions as a type of Klaytn transactions without getting confused with the existing Klaytn transaction types.
EthereumTxTypeEnvelope is a single-byte prefix for raw transactions that denotes Ethereum transaction types. Ethereum has adopted an extendable transaction type scheme from EIP-2718 and it uses a type numbering system that conflicts with Klaytn's. To resolve the conflict between two different transaction type schemes, Klaytn has introduced EthereumTxTypeEnvelope
which allows for separation and expansion for future Ethereum transaction types.
EthereumTxTypeEnvelope
is an additional type delimiter and used only for raw transactions and type numbering. It is not used for transaction hash or signature hash. For that purpose, EthereumTransactionType
as defined in EIPs is used.
EthereumTxTypeEnvelope: 0x78
TxHashRLP : EthereumTransactionType || TransactionPayload
RawTransaction : EthereumTxTypeEnvelope || EthereumTransactionType || TransactionPayload
TxTypeEthereumAccessList
represents a type of Ethereum transaction specified in EIP-2930. This transactions type contains an access list, a list of addresses and storage keys that the transaction is supposed to access. Since this transaction type exists to support compatibility, it only works with EOAs associated with [AccountKeyLegacy]. EOAs associated with other account key types should use other transaction types such as TxTypeValueTransfer
, TxTypeSmartContractExecution
, and so on. This transaction type can create accounts, transfer tokens, deploy/execute smart contracts or a mix of the aforementioned.
NOTE: Klaytn networks can process this transaction type after the EthTxTypeCompatibleBlock
NOTE: This transaction type only supports the format of the Ethereum transaction type. Unlike EIP-2930, there are no benefits in terms of transaction fee from using access list.
Attribute | Type | Description |
---|---|---|
To make a signature for this transaction type, the RLP serialization proceeds as follows:
NOTE: This type of transaction should be signed with London Signer
To obtain SenderTxHash
for this transaction type, the RLP serialization proceeds as follows:
To make a transaction hash, the RLP serialization proceeds as follows:
The following shows the result of the RLP serialization and the transaction object:
The following shows a transaction object returned via JSON RPC.
The return of eth_getTransactionByHash
The return of klay_getTransactionByHash
TxTypeEthereumDynamicFee
represents a type of Ethereum transaction specified in EIP-1559. This transaction type contains gasTipCap
and gasFeeCap
instead of gasPrice
. Since this transaction type exists to support compatibility, it only works with EOAs associated with [AccountKeyLegacy]. EOAs associated with other account key types should use other transaction types such as TxTypeValueTransfer
, TxTypeSmartContractExecution
, and so on. This type of transaction can create accouns, transfer tokens, deploy/execute smart contracts, or a mix of the aforementioned.
NOTE: Klaytn networks can process this transaction type after the EthTxTypeCompatibleBlock
NOTE: Currently, this type of transaction only supports the format of the Ethereum transaction type. Unlike EIP-2930, there are no benefits in terms of transaction fees from using access list.
NOTE: Since Klaytn has a fixed gas price, gasTipCap
and gasFeeCap
should take the gas price for the respective network, which is 250 ston at the time of writing.
To make a signature for this transaction type, the RLP serialization proceeds as follows:
NOTE: This type of transaction should be signed with London Signer
To obtain SenderTxHash
for this transaction type, the RLP serialization proceeds as follows:
To obtain a transaction hash, the RLP serialization proceeds as follows:
The following shows the result of the RLP serialization and the transaction object:
The following shows a transaction object returned via JSON RPC.
The return of eth_getTransactionByHash
The return of klay_getTransactionByHash
Attribute | Type | Description |
---|---|---|
type
uint8 (Go)
The type of TxTypeEthereumAccessList
that is a concatenation of EthereumTxTypeEnvelope
and EthereumTransactionType
. This must be 0x7801.
chainId
*big.Int (Go)
The destination chain ID.
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.
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.
data
[]byte (Go)
Data attached to the transaction, used for transaction execution.
accessList
type.AccessList (Go)
A list of addresses and storage keys consisting of [](common.Address, []common.Hash).
v, r, s
*big.Int (Go)
The cryptographic signature generated by the sender to let the receiver obtain the sender's address.
type
uint8 (Go)
The type of TxTypeEthereumDynamicFee
that is a concatenation of EthereumTxTypeEnvelope
and EthereumTransactionType
. It must be 0x7802
.
chainId
*big.Int (Go)
The destination chain ID.
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.
gasTipCap
*big.Int (Go)
A multiplier to get how much the sender will pay in addition to baseFee
. Since Klaytn has a fixed gas price, gasTipCap
and gasFeeCap
should take the gas price for the respective network, which is 250 ston at the time of writing.
gasFeeCap
*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
* gasFeeCap
. Since Klaytn has a fixed gas price, gasTipCap
and gasFeeCap
should take the gas price for the respective network, which is 250 ston at the time of writing.
gas
uint64 (Go)
The maximum amount of transaction fee 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.
data
[]byte (Go)
Data attached to the transaction, used for transaction execution.
accessList
type.AccessList (Go)
A list of addresses and storage keys consisting of [](common.Address, []common.Hash).
v, r, s
*big.Int (Go)
The cryptographic signature generated by the sender to let the receiver obtain the sender's address.