-
Notifications
You must be signed in to change notification settings - Fork 514
Description
i am trying to transfer token from one address to another
function functionCallWallet(){
var fromAddr = '0xe38265a9635f395d6a6ea1505f93fbfdb4b4175c';
var toAddr='0xe38265a9635f395d6a6ea1505f93fbfdb4b4175c';
var contractAddr = '0xbec5d11534d68a724640b8291310f56c92b31010';
var abi = JSON.parse('[ { "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" }, { "constant": false, "inputs": [ { "name": "token", "type": "address" }, { "name": "_addresses", "type": "address[]" }, { "name": "amount", "type": "uint256" } ], "name": "Airdrop", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_spender", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "approve", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "transfer", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "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, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "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" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": true, "inputs": [ { "name": "_owner", "type": "address" }, { "name": "_spender", "type": "address" } ], "name": "allowance", "outputs": [ { "name": "remaining", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "_owner", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "balance", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "INITIAL_SUPPLY", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" } ]');
var contract = web3.eth.contract(abi).at(contractAddr)
var functionName = 'transfer';
//var args = JSON.parse('[' + document.getElementById('functionArgs').value + ']')
//var srg = "from,value";
//var args = document.getElementById('functionArgs').value.split(",");
//alert(args[0]);
var valuetkn = '1';
var valuet = parseFloat(valuetkn)*1.0e6
var gasPrice = 50000000000
var gas = 3141592
txOptions = {
gasPrice: gasPrice,
gasLimit: gas,
value: 10000000,
nonce:2
}
txOptions.to = contractAddr;
//alert(txOptions.to);
//var args= { "to":"0xe38265a9635f395d6a6ea1505f93fbfdb4b4175c","value": valuet,"from":fromAddr};
var args= { toAddr,valuet};
//var functionCallTx = lightwallet.txutils.functionTx(abi,functionName,[ {"from":fromAddr ,"to": toAddr , value: 1 } ],txOptions);
var functionCallTx = lightwallet.txutils.functionTx(abi,functionName,[args],txOptions);
var password = prompt('Enter password ', 'Password');
lightwallet.keystore.deriveKeyFromPassword(password, function(err, pwDerivedKey) {
var signedFunctionTx = signing.signTx(global_keystore,pwDerivedKey,functionCallTx,fromAddr);
console.log("Signed function transaction:"+signedFunctionTx);
console.log('');
web3.eth.sendRawTransaction('0x'+signedFunctionTx, function(err, hash) {
console.log(err);
console.log(hash);
});
})
}