EIPs/EIPS/eip-155.md

76 lines
3.5 KiB
Markdown
Raw Normal View History

---
2018-03-21 12:51:05 +00:00
eip: 155
title: Simple replay attack protection
author: Vitalik Buterin
type: Standards Track
2018-03-21 12:51:05 +00:00
category: Core
status: Final
created: 2016-10-14
---
2017-05-03 15:12:34 +00:00
### Hard fork
[Spurious Dragon](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-607.md)
2017-05-03 15:12:34 +00:00
### Parameters
- `FORK_BLKNUM`: 2,675,000
2018-01-26 09:08:27 +00:00
- `CHAIN_ID`: 1 (main net)
2019-01-11 11:25:49 +00:00
2017-05-03 15:12:34 +00:00
### Specification
2018-01-26 05:08:33 +00:00
If `block.number >= FORK_BLKNUM` and `v = CHAIN_ID * 2 + 35` or `v = CHAIN_ID * 2 + 36`, then when computing the hash of a transaction for purposes of signing or recovering, instead of hashing only the first six elements (i.e. nonce, gasprice, startgas, to, value, data), hash nine elements, with `v` replaced by `CHAIN_ID`, `r = 0` and `s = 0`. The currently existing signature scheme using `v = 27` and `v = 28` remains valid and continues to operate under the same rules as it does now.
2019-01-11 11:25:49 +00:00
2017-05-03 15:12:34 +00:00
### Example
Consider a transaction with `nonce = 9`, `gasprice = 20 * 10**9`, `startgas = 21000`, `to = 0x3535353535353535353535353535353535353535`, `value = 10**18`, `data=''` (empty).
The "signing data" becomes:
```
0xec098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a764000080018080
```
The "signing hash" becomes:
```
2017-05-04 16:28:26 +00:00
0xdaf5a779ae972f972197303d7b574746c7ef83eadac0f2791ad23db92e4c8e53
2017-05-03 15:12:34 +00:00
```
If the transaction is signed with the private key `0x4646464646464646464646464646464646464646464646464646464646464646`, then the v,r,s values become:
```
2017-05-04 16:28:26 +00:00
(37, 18515461264373351373200002665853028612451056578545711640558177340181847433846, 46948507304638947509940763649030358759909902576025900602547168820602576006531)
2017-05-03 15:12:34 +00:00
```
Notice the use of 37 instead of 27. The signed tx would become:
```
0xf86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83
```
2019-01-11 11:25:49 +00:00
2017-05-03 15:12:34 +00:00
### Rationale
2018-01-26 05:08:33 +00:00
This would provide a way to send transactions that work on Ethereum without working on ETC or the Morden testnet. ETC is encouraged to adopt this EIP but replacing `CHAIN_ID` with a different value, and all future testnets, consortium chains and alt-etherea are encouraged to adopt this EIP replacing `CHAIN_ID` with a unique value.
2017-05-04 16:54:24 +00:00
### List of Chain ID's:
| `CHAIN_ID` | Chain(s) |
| ---------------| -------------------------------------------|
| 1 | Ethereum mainnet |
| 2 | Morden (disused), Expanse mainnet |
| 3 | Ropsten |
| 4 | Rinkeby |
2018-10-17 13:11:15 +00:00
| 8 | Ubiq mainnet |
| 9 | Ubiq testnet |
2017-05-04 16:54:24 +00:00
| 30 | Rootstock mainnet |
| 31 | Rootstock testnet |
| 42 | Kovan |
| 61 | Ethereum Classic mainnet |
| 62 | Ethereum Classic testnet |
| 66 | ewasm testnet |
2017-05-04 16:54:24 +00:00
| 1337 | Geth private chains (default) |
2018-11-23 22:44:14 +00:00
| 6284 | Görli |
2019-01-04 14:54:18 +00:00
| 43568 | Gangnam |
2018-11-23 22:44:14 +00:00
| 314158 | Stureby |
Find more chain ID's on [chainid.network](https://chainid.network) and contribute to [ethereum-lists/chains](https://github.com/ethereum-lists/chains).