You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: services/concepts/transaction-types.md
+63-3
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,8 @@ sidebar_position: 4
5
5
6
6
# Ethereum transaction types
7
7
8
-
You can interact with the [Ethereum JSON-RPC API](../reference/ethereum/json-rpc-methods/index.md) using different transaction types (specified by the `type` parameter).
8
+
You can interact with the [Ethereum JSON-RPC API](../reference/ethereum/json-rpc-methods/index.md) using different transaction types (specified by the
The following methods use a unique format depending on the transaction type:
11
12
@@ -20,14 +21,50 @@ The following methods use a unique format depending on the transaction type:
20
21
21
22
Transactions with type `0x0` are legacy transactions that use the transaction format existing before typed transactions were introduced in [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718). They contain the parameters `nonce`, `gasPrice`, `gasLimit`, `to`, `value`, `data`, `v`, `r`, and `s`. Legacy transactions don’t use [access lists](../reference/ethereum/json-rpc-methods/eth_createaccesslist.mdx) or incorporate [EIP-1559 fee market changes](#eip-1559-transactions).
22
23
24
+
```js title="Legacy transaction object example"
25
+
{
26
+
nonce:"0x0", // Number of transactions made by the sender before this one.
27
+
gasPrice:"0x09184e72a000", // Gas price, in wei, provided by the sender.
28
+
gasLimit:"0x2710", // Maximum gas provided by the sender.
29
+
to:"0x0000000000000000000000000000000000000000", // Address of the recipient. Not used in contract creation transactions.
30
+
value:"0x0", // Value transferred, in wei.
31
+
data:"0x7f7465737432000000000000000000000000000000000000000000000000000000600057", // Used for defining contract creation and interaction.
32
+
v:"0x1", // ECDSA recovery ID.
33
+
r:"0xa07fd6c16e169f0e54b394235b3a8201101bb9d0eba9c8ae52dbdf556a363388", // ECDSA signature r.
34
+
s:"0x36f5da9310b87fefbe9260c3c05ec6cbefc426f1ff3b3a41ea21b5533a787dfc", // ECDSA signature s.
35
+
}
36
+
```
37
+
23
38
## Access list transactions
24
39
25
40
Transactions with type `0x1` are transactions introduced in [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930). They contain, along with the [legacy parameters](#legacy-transactions), an `accessList` parameter, which specifies an array of addresses and storage keys that the transaction plans to access (an _access list_). Access list transactions must specify an access list, and they don’t incorporate [EIP-1559 fee market changes](#eip-1559-transactions).
26
41
27
-
Also, access list transactions contain the `yParity` parameter. The returned values for this parameter can either be `0x0` or `0x1`. This is the parity (0 for even, 1 for odd) of the y-value of a [`secp256k1`](https://eips.ethereum.org/EIPS/eip-2098#:~:text=A%20secp256k1%20signature%20is%20made%20up%20of%203%20parameters%2C%20r%2C%20s%20and%20yParity.) signature.
42
+
Also, access list transactions contain the `yParity` parameter. The returned values for this parameter can either be `0x0` or `0x1`. This is the parity (0 for even, 1 for odd) of the y-value of a [`secp256k1`](https://eips.ethereum.org/EIPS/eip-2098) signature.
28
43
29
44
Use the [`eth_createAccessList`](../reference/ethereum/json-rpc-methods/eth_createaccesslist.mdx) API to simulate a transaction which returns the addresses and storage keys that may be used to send the real transaction, and the approximate gas cost.
30
45
46
+
```js title="Access list transaction object example"
47
+
{
48
+
nonce:"0x0", // Number of transactions made by the sender before this one.
49
+
gasPrice:"0x09184e72a000", // Gas price, in wei, provided by the sender.
50
+
gasLimit:"0x2710", // Maximum gas provided by the sender.
51
+
to:"0x0000000000000000000000000000000000000000", // Address of the recipient. Not used in contract creation transactions.
52
+
value:"0x0", // Value transferred, in wei.
53
+
data:"0x7f7465737432000000000000000000000000000000000000000000000000000000600057", // Used for defining contract creation and interaction.
54
+
v:"0x1", // ECDSA recovery ID.
55
+
r:"0xa07fd6c16e169f0e54b394235b3a8201101bb9d0eba9c8ae52dbdf556a363388", // ECDSA signature r.
56
+
s:"0x36f5da9310b87fefbe9260c3c05ec6cbefc426f1ff3b3a41ea21b5533a787dfc", // ECDSA signature s.
57
+
chainId:"0x1", // Chain ID of the transaction.
58
+
accessList: [ // List of addresses and storage keys the transaction plans to access.
yParity:"0x1"// Parity of the y-value of a secp256k1 signature.
65
+
}
66
+
```
67
+
31
68
:::info
32
69
33
70
View the [Infura article](https://blog.infura.io/post/optimizing-ethereum-transactions-with-eth_createaccesslist) that describes how `eth_createAccessList` can help optimize gas costs, reduce out-of-gas errors, and verify clients for infrastructure access.
@@ -42,8 +79,31 @@ EIP-1559 transactions don’t specify `gasPrice`, and instead use an in-protocol
42
79
43
80
EIP-1559 transactions contain the [`accessList` and `yParity` parameters](transaction-types.md#access-list-transactions) and [legacy parameters](transaction-types.md#legacy-transactions) (except for `gasPrice`).
44
81
45
-
They also contain a `maxPriorityFeePerGas` parameter, which specifies the maximum fee the sender is willing to pay per gas above the base fee (the maximum _priority fee_ per gas), and a `maxFeePerGas` parameter, which specifies the maximum total fee (base fee + priority fee) the sender is willing to pay per gas.
82
+
They also contain a `maxPriorityFeePerGas` parameter, which specifies the maximum fee the sender is willing to pay per gas above the base fee, in order to get their transaction prioritized;
83
+
and a `maxFeePerGas` parameter, which specifies the maximum total fee (base fee + priority fee) the sender is willing to pay per gas.
46
84
47
85
An EIP-1559 transaction always pays the base fee of the block it’s included in, and it pays a priority fee as priced by `maxPriorityFeePerGas` or, if the base fee per gas + `maxPriorityFeePerGas` exceeds `maxFeePerGas`, it pays a priority fee as priced by `maxFeePerGas` minus the base fee per gas. The base fee is burned, and the priority fee is paid to the miner that included the transaction. A transaction’s priority fee per gas incentivizes miners to include the transaction over other transactions with lower priority fees per gas.
48
86
87
+
```js title="EIP-1559 transaction object example"
88
+
{
89
+
nonce:"0x0", // Number of transactions made by the sender before this one.
90
+
gasLimit:"0x2710", // Maximum gas provided by the sender.
91
+
maxPriorityFeePerGas:"0x0", // Maximum fee, in wei, the sender is willing to pay per gas above the base fee.
92
+
maxFeePerGas:"0x6f4d3132b", // Maximum total fee (base fee + priority fee), in wei, the sender is willing to pay per gas.
93
+
to:"0x0000000000000000000000000000000000000000", // Address of the recipient. Not used in contract creation transactions.
94
+
value:"0x0", // Value transferred, in wei.
95
+
data:"0x7f7465737432000000000000000000000000000000000000000000000000000000600057", // Used for defining contract creation and interaction.
96
+
v:"0x1", // ECDSA recovery ID.
97
+
r:"0xa07fd6c16e169f0e54b394235b3a8201101bb9d0eba9c8ae52dbdf556a363388", // ECDSA signature r.
98
+
s:"0x36f5da9310b87fefbe9260c3c05ec6cbefc426f1ff3b3a41ea21b5533a787dfc", // ECDSA signature s.
99
+
chainId:"0x1", // Chain ID of the transaction.
100
+
accessList: [], // List of addresses and storage keys the transaction plans to access.
101
+
yParity:"0x1"// Parity of the y-value of a secp256k1 signature.
102
+
}
103
+
```
104
+
105
+
:::info
106
+
49
107
Read the [Consensys EIP-1559 primer](https://consensys.net/blog/quorum/what-is-eip-1559-how-will-it-change-ethereum/) for more information on how EIP-1559 changes Ethereum.
yParity:"0x1"// Parity of the y-value of a secp256k1 signature.
103
+
}
104
+
```
105
+
106
+
</TabItem>
107
+
<TabItemvalue="EIP-1559 transaction">
108
+
109
+
```js
110
+
{
111
+
nonce:"0x0", // Number of transactions made by the sender before this one.
112
+
gasLimit:"0x2710", // Maximum gas provided by the sender.
113
+
maxPriorityFeePerGas:"0x0", // Maximum fee, in wei, the sender is willing to pay per gas above the base fee.
114
+
maxFeePerGas:"0x6f4d3132b", // Maximum total fee (base fee + priority fee), in wei, the sender is willing to pay per gas.
115
+
to:"0x0000000000000000000000000000000000000000", // Address of the recipient. Not used in contract creation transactions.
116
+
value:"0x0", // Value transferred, in wei.
117
+
data:"0x7f7465737432000000000000000000000000000000000000000000000000000000600057", // Used for defining contract creation and interaction.
118
+
v:"0x1", // ECDSA recovery ID.
119
+
r:"0xa07fd6c16e169f0e54b394235b3a8201101bb9d0eba9c8ae52dbdf556a363388", // ECDSA signature r.
120
+
s:"0x36f5da9310b87fefbe9260c3c05ec6cbefc426f1ff3b3a41ea21b5533a787dfc", // ECDSA signature s.
121
+
chainId:"0x1", // Chain ID of the transaction.
122
+
accessList: [], // List of addresses and storage keys the transaction plans to access.
123
+
yParity:"0x1"// Parity of the y-value of a secp256k1 signature.
124
+
}
125
+
```
126
+
127
+
</TabItem>
128
+
</Tabs>
129
+
66
130
### Nonce
67
131
68
132
:::note
@@ -82,29 +146,31 @@ Nonces are easy to mess up, especially when a user is interacting with multiple
82
146
pending transactions using the same account, potentially across multiple devices.
83
147
Because of this, MetaMask doesn't allow dapp developers to customize nonces.
84
148
Instead, MetaMask
85
-
[assists the user in managing their transaction queue themselves](https://metamask.zendesk.com/hc/en-us/articles/360015489251).
149
+
[assists the user in managing their transaction queue themselves](https://support.metamask.io/manage-crypto/transactions/how-to-speed-up-or-cancel-a-pending-transaction/).
86
150
87
151
### Gas price
88
152
89
-
Gas price is an optional parameter, and best used on private blockchains.
153
+
`gasPrice` is an optional parameter.
154
+
It is used in [legacy transactions](/services/concepts/transaction-types/#legacy-transactions) and specifies the gas price the sender is willing to pay for the transaction.
155
+
MetaMask automatically configures gas settings, but [users can also customize these settings](https://support.metamask.io/configure/transactions/how-to-customize-gas-settings/).
90
156
91
-
In Ethereum, every transaction specifies a price for the gas it consumes.
92
-
To maximize their profit, block producers pick pending transactions with higher gas prices first
93
-
when creating the next block.
94
-
This means that a high gas price usually causes your transaction to be processed faster, at the cost
95
-
of greater transaction fees.
157
+
### Gas limit
96
158
97
-
Some networks, such as Layer 2 networks, might have a constant gas price or no gas price.
98
-
So while you can ignore this parameter on MetaMask's default networks, you might include it when
99
-
your dapp knows more about the target network than MetaMask does.
100
-
On the default networks, MetaMask allows users to choose between slow, medium, and fast options for
101
-
their gas price.
159
+
`gasLimit` is an optional parameter.
160
+
It specifies the maximum amount of gas units the sender is willing to pay for the transaction.
161
+
MetaMask automatically sets this parameter, but [users can also customize their gas settings](https://support.metamask.io/configure/transactions/how-to-customize-gas-settings/).
102
162
103
-
Read about [how to use advanced gas controls](https://metamask.zendesk.com/hc/en-us/articles/360022895972).
163
+
### Max priority fee per gas
104
164
105
-
### Gas limit
165
+
`maxPriorityFeePerGas` is an optional parameter.
166
+
It is used in [EIP-1559 transactions](/services/concepts/transaction-types/#eip-1559-transactions) and specifies the maximum fee the sender is willing to pay per gas above the base fee, in order to get their transaction prioritized.
167
+
MetaMask automatically sets this parameter, but [users can also customize their gas settings](https://support.metamask.io/configure/transactions/how-to-customize-gas-settings/).
168
+
169
+
### Max fee per gas
106
170
107
-
Gas limit is an optional parameter, since MetaMask automatically calculates a reasonable gas price.
171
+
`maxFeePerGas` is an optional parameter.
172
+
It is used in [EIP-1559 transactions](/services/concepts/transaction-types/#eip-1559-transactions) and specifies the maximum total fee (base fee + priority fee) the sender is willing to pay per gas.
173
+
MetaMask automatically sets this parameter, but [users can also customize their gas settings](https://support.metamask.io/configure/transactions/how-to-customize-gas-settings/).
0 commit comments