I want to transfer ERC20 (standard) tokens from a basic ethereum account to an exchange or to another account. How do I do that without using a GUI like Mist?
[Ethereum] How to transfer ERC20 tokens (GNT,OMG, etc) from a cold wallet to another account (or exchange) using geth
go-ethereumgolemomisego
Related Solutions
start geth console
$ geth --fast console
in console :
var tokenContractABI = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"dutchAuction","type":"address"},{"name":"owners","type":"address[]"},{"name":"tokens","type":"uint256[]"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]
var tokenContract = eth.contract(tokenContractABI).at("0x6810e776880c02933d47db1b9fc05908e5386b96");
var gnoAccount = "{your GNO account}".toLowerCase();
var amount = 0.1; /* GNO tokens you want to send */
var destination = "{address where to send}".toLowerCase();
check balance
tokenContract.balanceOf(gnoAccount);
transfer tokens
personal.unlockAccount(gnoAccount);
tokenContract.transfer(destination, web3.toWei(amount), {from: gnoAccount});
You cannot send tokens directly from one address to another address. Tokens balances only exist in the Token contract storage. You necessarily have to send a transaction to the contract indicating you want to make a tranfer, so the contract can update the balances accordingly.
Best Answer
Step 0: Install geth, start geth (with "--unlock 0xYOURACCOUNT"), sync the blockchain, open up a geth terminal in another window with "geth attach".
Step 1: Save the ERC20 ABI to a variable. This is the interface for interacting with the token contract.
Step 2: Create the contract variable using the web3 contract method:
Optional step, check an account balance (# of OMG tokens for this acct):
or check all of your accounts in the .ethereum/keystore directory
Step 3: Send a small amount of the token (here, 1) to the destination address.
Step 4: Transfer the rest. Same command as above with a greater value