5

I don't want to use Mist to interact with the DAO. How do I do it from geth instead?

6

Assumption: You have (fully-synced) geth on Linux, some DAO tokens, and access to the account you bought the DAO tokens with.

First, you need The DAO’s contract ABI. This is the interface definition that allows you to interact with The DAO contract in the blockchain. Here it is in a gist. It’s long.

https://gist.github.com/fivedogit/4f3e9a035262b99b2e7356a4fdf6dd34

Or from here (slockit github):

https://github.com/slockit/DAO/wiki/The-DAO-v1.0-Code

Cut and paste all of that and then type this in geth to set it to a variable:

> var abi = <paste it here, no outer quotes necessary>;

The ABI tells geth how to make sense of the bytecode at an address in the blockchain. With it, you can use the “eth.contract” method of web3 to interact with the DAO contract at its address:

> var contract = web3.eth.contract(abi).at(“0xbb9bc244d798123fde783fcc1c72d3bb8c189413″);

Now you can execute all the methods The DAO contract supports. How about checking your balance?

> contract.balanceOf(eth.coinbase);

or

> contract.balanceOf(“0xabc123…”);

Divide this number by 10^16 to get the DAO token total in its “natural” denomination. For me:

> contract.balanceOf(eth.accounts[1]);
80000000000000000000
> contract.balanceOf(eth.accounts[1])/10000000000000000;
8000

At the time of this writing, I have 8000 DAO tokens.

Checking your balance is a “constant” method, (as you can see from the ABI) which means it reads from the blockchain and costs no gas to execute.

Transferring a balance, however, changes the state of the blockchain and requires a small gas payment. In the next command the "{from:YOURADDR}" parameter provides that payment. You can specify gas explicitly like this: "{from:YOURADDR,gas:2500000}" but geth has a default it will provide if you don't which is why I don't show it below. (Unused gas is always refunded.)

BUT FIRST! We need the exchange address to send it to. In Poloniex, it’s under "Balances" and "Deposits and Withdrawals". Find DAO in the list and click the link to get a deposit address.

Now here’s the transfer execution command (This will transfer 2000 DAO tokens to a polo address from my second ETH account):

contract.transfer(“0xaaaaPoloDAODepositAddressaaaaa”, 20000000000000000000, {from:eth.accounts[1]});

Wait for the tx to propagate, then check your balance again with:

> contract.balanceOf(eth.accounts[1])/10000000000000000;
6000

My tokens took about an hour to land in Poloniex (on 5/28/2016), so don't panic if you don't see the transfer happening right away.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.