How to create and transfer tokens - TheDAO/DAO-1.0 GitHub Wiki

DAO Wiki - Reliable

The DAO code has implemented the Standard Token: https://github.com/ethereum/EIPs/issues/20

Creation

Tokens are created by sending ether to the DAO during the creation period. There is different ether/token creation ration during the period, as specified in the white paper section 5.

There are two ways to create those tokens.

  1. Sending ether directly to the DAO contract without calling any function (no data attached to the transaction, simple value transfer). In this case the sender of the transaction will be the owner of the newly created tokens.

  2. Calling the createTokenProxy function. This function has an address as input parameter. This address will be the owner of the tokens.

Example data: In the case I would like to create tokens owned by the address: 0x112233445566778899aabbccddeeff0011223344, I would send a transaction to the DAO contract with the data: 0xbaac5300000000000000000000000000112233445566778899aabbccddeeff0011223344 (for another address, replace the last 40 characters with your address).

This is particular useful when sending ether stored by an exchange, who typically holds the private keys of your sender account. This way one could create an ethereum account, owning the private keys, and send ether from an exchange adding the above described data, in order to own the DAO token yourself.

Transfer

NOTE: During the Creation phase, tokens cannot be transferred between accounts.

The latest version of the Mist Wallet (https://github.com/ethereum/mist/releases) support standard Token. You can simply use the "watch token" feature, and enter the address of the DAO contract, a freely given name and the decimals for the token. In the white paper the decimal is defined as 16. This means, one DAO token is defined as 10^16 base unit tokens. Similar to ether being 10^18 Wei (the base unit in ethereum). You can then use the Mist Wallet to send tokens (see Mist Wallet documentation).

Additionally you can use the functions transfer and transferFrom in the DAO contract. The transfer function takes two parameters:

  • to Recipient of the tokens
  • value Amount of tokens (base units!) to be transferred

Here the tokens from the sender of the transaction are transferred.

The function transferFrom works similar. It has the same parameters as transfer, but additionally takes

  • from Sender of the tokens.

as the sender of the tokens. This function can only be used, when the owner of the token has approved this spending. He can do this by calling approve with the parameter:

  • spender Address of the account allowed to transfer the token
  • amount Amount of tokens the spender is allowed to transfer

This is similar to writing a check. The speder using transferFrom to transfer tokens from another owner, can check how much he is still allowed to spend using the read only allowance function, which takes two parameters as input:

  • owner Address of the owner of the tokens
  • spender Address of the account allowed to transfer the token

It returns the amount of token allowed to be transferred in it base unit.