Last active
July 20, 2016 17:06
-
-
Save anders94/e7796465c361021e208419196cb44617 to your computer and use it in GitHub Desktop.
Step by step process of converting DAO tokens back into ETH via the WithdrawDAO using geth on the command line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start by getting to a geth shell running "geth attach" or however you do it. | |
$> geth attach | |
Welcome to the Geth JavaScript console! | |
instance: Geth/v1.4.10-stable/darwin/go1.6 | |
coinbase: 0xcbcac9e9e30f3121834bc97c8b99b6602acc6c75 | |
at block: 1920784 (Wed, 20 Jul 2016 12:58:48 EDT) | |
datadir: /home/user/.ethereum | |
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0 | |
// start by defining the DAO contract locally | |
> dao = web3.eth.contract([{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},{"constant":true,"inputs":[],"name":"standard","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Approval","type":"event"}]).at('0xbb9bc244d798123fde783fcc1c72d3bb8c189413'); | |
{ | |
abi: [{ | |
constant: true, | |
inputs: [], | |
name: "name", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: false, | |
inputs: [{...}, {...}], | |
name: "approve", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [], | |
name: "totalSupply", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: false, | |
inputs: [{...}, {...}, {...}], | |
name: "transferFrom", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [], | |
name: "decimals", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [], | |
name: "standard", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [{...}], | |
name: "balanceOf", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [], | |
name: "symbol", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: false, | |
inputs: [{...}, {...}], | |
name: "transfer", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [{...}, {...}], | |
name: "allowance", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
anonymous: false, | |
inputs: [{...}, {...}, {...}], | |
name: "Transfer", | |
type: "event" | |
}, { | |
anonymous: false, | |
inputs: [{...}, {...}, {...}], | |
name: "Approval", | |
type: "event" | |
}], | |
address: "0xbb9bc244d798123fde783fcc1c72d3bb8c189413", | |
transactionHash: null, | |
Approval: function(), | |
Transfer: function(), | |
allEvents: function(), | |
allowance: function(), | |
approve: function(), | |
balanceOf: function(), | |
decimals: function(), | |
name: function(), | |
standard: function(), | |
symbol: function(), | |
totalSupply: function(), | |
transfer: function(), | |
transferFrom: function() | |
} | |
// Do the same for the withdraw contract | |
> withdrawable = web3.eth.contract([{"constant":false,"inputs":[],"name":"trusteeWithdraw","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"mainDAO","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"trustee","outputs":[{"name":"","type":"address"}],"type":"function"}]).at('0xbf4ed7b27f1d666546e30d74d50d173d20bca754'); | |
{ | |
abi: [{ | |
constant: false, | |
inputs: [], | |
name: "trusteeWithdraw", | |
outputs: [], | |
type: "function" | |
}, { | |
constant: false, | |
inputs: [], | |
name: "withdraw", | |
outputs: [], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [], | |
name: "mainDAO", | |
outputs: [{...}], | |
type: "function" | |
}, { | |
constant: true, | |
inputs: [], | |
name: "trustee", | |
outputs: [{...}], | |
type: "function" | |
}], | |
address: "0xbf4ed7b27f1d666546e30d74d50d173d20bca754", | |
transactionHash: null, | |
allEvents: function(), | |
mainDAO: function(), | |
trustee: function(), | |
trusteeWithdraw: function(), | |
withdraw: function() | |
} | |
// You may need to unlock your account (this assumes the DAO was purchased with eth.accounts[0]) | |
> personal.unlockAccount(eth.accounts[0]); | |
Unlock account 0x1ceff6495e5688DB9b9cf0E55F9b3eaDC25Cb0C1 | |
Passphrase: | |
true | |
// Recovering DAO tokens is done in 2 steps - first is the approval | |
> dao.approve(withdrawable.address, dao.balanceOf(eth.accounts[0]), {from: eth.accounts[0]}); | |
"0xc7c6cd13de3dc78c8bce630f69740efe66e6f7f88edb167eb9dca4fb65e699b6" | |
// And the second is the actual withdrawal | |
> withdrawable.withdraw({from: eth.accounts[0], gas: 100000}); | |
"0x20f265df09ee011025b3bacbc2d7c9fd2e837967a0ac046faccac680f89d7d47" | |
// Now the original funding account should have ETH returned. That's it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment