contract token { mapping (address => uint) public coinBalanceOf; event CoinTransfer(address sender, address receiver, uint amount); /* Initializes contract with initial supply tokens to the creator of the contract */ function token(uint supply) { if (supply == 0) supply = 10000; coinBalanceOf[msg.sender] = supply; } /* Very simple trade function */ function sendCoin(address receiver, uint amount) returns(bool sufficient) { if (coinBalanceOf[msg.sender] < amount) return false; coinBalanceOf[msg.sender] -= amount; coinBalanceOf[receiver] += amount; CoinTransfer(msg.sender, receiver, amount); return true; } }

trx = { ????address: tokenAddres????, sender: fromAccount, receiver: toAccount, amount: 3333 }; var trx_hex = web3.toHex(trx); console.log(web3.toAscii(trx_hex)); var rawTx = { nonce: '0x06', gasPrice: gasPriceHex, gasLimit: gasLimitHex, to: toAccount, value: '0x00', data: trx_hex }; var tx = new Tx(rawTx); tx.sign(privateKey); var serializedTx = tx.serialize(); web3.eth.sendRawTransaction(serializedTx.toString('hex'), function (err, hash) { if (err) { console.log(err) } else { console.log(hash); } });

var token= web3.eth.contract(tokenABI).at(tokenaddress); token.sendCoin.sendTransaction(0x00001, 10, {from: 0x00002})

I'v implemented the beginners token example from the Ethereum website and this works well from geth:When using web3 I can interact with the contract's public token.coinBalanceOf. So that is also working.Now I'd like to use the private key which I have on the browser side, to sign the transfer of a token from one account to the other. Via geth this works: "token.sendCoin.sendTransaction(0x00001, 10, {from: 0x00002})".My current approach is the following, but I don't see how to pass on the contract address of my token contract on which this transaction should execute to the sendRawTransaction:Or is there a way to tell web3 the current private key to use, which would allow me to do the following:Thank you in advance!