How to safely access your Ethereum Classic tokens (ETHC) and prevent replay attacks
ethereum·@cryptocylon·
0.000 HBDHow to safely access your Ethereum Classic tokens (ETHC) and prevent replay attacks
# How to safely access your new Ethereum Classic tokens
Recently Poloniex started trading Ethereum Classic tokens (free markets at work!); If you're like me (i.e. you were not storing your ether in an exchange pre-HF), you now have twice the amount of ether you had before the fork. But how do you get the new half? This guide will show you how to access your shiny new ETHC tokens.
**IMPORTANT**: This guide was written to avoid replay attacks. If, at any time, you feel uncomfortable or that this stuff is technically beyond you, I suggest you **stop**. If you mess this up, you could lose all your ether in a replay attack and ETHC is (in my opinion) probably not going to be worth very much. I personally wouldn't take the risk if I felt uncomfortable with the technical aspects. Also, I suggest you test these steps with ~1ETH to make sure you've got it down. **Be careful**.
**DISCLAIMERS**: If you fuck this up, I'm sorry (and not responsible). The below steps worked for me. Again, do not proceed if you feel uncomfortable at any time. The risk isn't worth it (in my opinion). Also, I am a majority chain supporter, so appologies if that bothers you.
## 1. Make sure you have access to both chains
The best way to do this is to cleanly separate two directories, one per chain, and have a separate copy of a geth-1.4.10 binary (get it [here](https://github.com/ethereum/go-ethereum/releases/tag/v1.4.10)) in each directory. This is not necessary, but it is easier for instruction and for sanity checks.
Let's set up our directory tree:
```
eth-2chainz/
├── geth-classic
│ ├── data
│ └── geth-1.4.10
└── geth-new
├── data
└── geth-1.4.10
```
Notice that I have two folders marked `data`. These will be the default folders for the new chains. When I run either client, I will want to specify `--datadir=data` (assuming I am running the binary inside of its actual directory).
## 2. Create two new addressees
We need to create a new address for each chain to prevent replay attacks. Pick either client and run:
```
geth account new
geth account new
```
and navigate to your current default data directory (something like `~/.ethereum/keystore`, depending on your system) to fetch the key files. They should be named after a timestamp (starting with `UTC-`). Move them to the two separate geth directories specified above. Create two subdirectories: `data/keystore` and move the files into those respective directories.
Your directory tree should now look something like this:
```
eth-2chainz/
├── geth-classic
│ ├── data
│ │ └── keystore
│ │ └── UTC--...
│ └── geth-1.4.10
└── geth-new
├── data
│ └── keystore
│ └── UTC--...
└── geth-1.4.10
```
Create a new file called `boot.sh` in each of the two directories:
#### Classic:
```
#!/bin/bash
geth-1.4.10 --datadir "./data" --oppose-dao-fork console 2>>geth.log
```
#### Ethereum (i.e. "main chain", in my worldview):
```
#!/bin/bash
geth-1.4.10 --datadir "./data" --support-dao-fork console 2>>geth.log
```
Go ahead and run `chmod 777 boot.sh` in both directories and run the boot script with `./boot.sh`.
## 3. Copy the blockchain
Please tell me you haven't run a node since the fork happened. Go ahead and copy your old blockchain (`DEFAULTDATADIR/chaindata`) to both new data folders.
If you **have** run a node since the HF, copy the relevant one (presumably the main chain) to the appropriate `data` directory and then start syncing the other chain (presumably Ethereum Classic) in its data directory (i.e. using `--datadir`). See you in a few hours...
Note that it may take a while for the Classic chain to sync because it is very difficult to find peers.
**Make sure your chains are both synced (at the very least past the HF, i.e. block 1920000) before proceeding.**
## 4. Split your account and move your ether (on Ethereum, main chain)
Before monkeying around with Ethereum Classic, let's first move our ether to a new address on the *main* chain. Depending on your political leanings, you may call this sacrilege and you may kindly move to the next step if you so choose (you probably shouldn't be reading this guide in the first place).
Navigate to your `geth-new` directory and run `./boot.sh`. Make sure *only* your Ethereum node (i.e. the one with `--support-dao-fork`) is running **and synced**. A good way to make sure the chain is synced is to run `tail geth.log` and check that the last few lines show that only 1-5 blocks are being imported (as opposed to the ~1000 blocks that are imported per line when the node is syncing the blockchain).
Okay, are we ready to move? Check out the split contract posted by Vitalik [here](http://etherscan.io/address/0xb671c3883307cf05bb3dff77a9754e87b4347195).
**IMPORTANT**: Below I am using *eth.accounts[0]* as my newly created address (i.e. the one I am sending ether to on the newly split chains) and *eth.accounts[1]* as my old address (i.e. the one I am sending from).
We will be calling this contract from geth console. In the console, type the following:
```
var split_abi = [{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"transferIfHF","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"transferIfNoHF","outputs":[],"type":"function"}]
var Split = eth.contract(split_abi);
var SplitInstance = Split.at('0xb671c3883307cf05bb3dff77a9754e87b4347195');
```
*Sanity check*: Make sure when you type `SplitInstance`, an object is printed to the console.
Now we're going to **carefully** load our old wallet into the new chain. Copy your original wallet file to `data/keystore` in **both** directories.
Now we're in good shape to send the ether, type the following into your console. Again, **be careful**.
```
personal.unlockAccount(eth.accounts[1], "mypassword")
SplitInstance.transferIfHF.sendTransaction(eth.accounts[0], {from:eth.accounts[1], value: web3.toWei(1.1, "ether")})
personal.lockAccount(eth.accounts[1])
```
Replacing "mypassword" with your account password, of course.
Now load up etherscan or some oter trusted chain-watching service and **make sure your ether is in the new address**. Is it? Good. Now move the rest using the code above and an appropriate `value` to drain your account. I like to chunk my transfers into 3-5 slices for psychological well being, but it's up to you.
Once your account is drained, close geth. You're done with Ethereum main chain!
## 4. Move your ether to the new addresses on Ethereum Classic
Now that your ether is safe in the main chain, let's move it on Etherem Classic. Navigate to your `geth-new` directory and run `./boot.sh`. Let the chain sync if you haven't already.
Make sure only your Ethereum Classic node (i.e. the one with `--oppose-dao-fork`) is running *and synced* (again, check using `tail geth.log`). We will use the same contract as before, but this time calling the `transferIfNoHF` method.
Back to the geth console (**again, accounts[1] represents my old account and accounts[0] is my new account**):
```
var split_abi = [{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"transferIfHF","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"transferIfNoHF","outputs":[],"type":"function"}]
var Split = eth.contract(split_abi);
var SplitInstance = Split.at('0xb671c3883307cf05bb3dff77a9754e87b4347195');
personal.unlockAccount(eth.accounts[1], "mypassword")
SplitInstance.transferIfNoHF.sendTransaction(eth.accounts[0], {from:eth.accounts[1], value: mybalance)})
personal.lockAccount(eth.accounts[1])
```
Replacing "mypassword" and "mybalance", of course. Check to make sure it went through and drain your account like you did on the main chain.
## 5. Move your funds to poloniex (optional)
If you're like me and just want your free lunch, grab your poloniex deposit address and send away (again, make sure only Ethereum Classic is running):
```
personal.unlockAccount(eth.accounts[0], "myotherpassword")
eth.sendTransaction({from: eth.accounts[0], to: 'mypoloniexaddress', value: web3.toWei(mybalance, "ether")})
```
with the proper replacements.
# Congrats!
Hopefully you're now X ETHC richer. I personally will be dumping it immediately, but it's yours to do with as you please. Enjoy!