1

Hello ethereum experts,

I got the following error in the Chrome's Javascript Console:
ethereum_web3.js?hash=ee8d37819d18de934b202361e374522a33bbd060:3783 Uncaught TypeError: Cannot create property 'from' on string..

I'm on an MacOS(10.12.6) and using using Meteor (1.5) + Metamask. I started geth(1.6.7-stable) with the following commandline: geth --datadir "net_a" --networkid 1234 --rpc --rpcport "8545" --rpccorsdomain "*" --rpcapi "eth,net,web3,personal" console 2>console.log

And the followings are my attempt to send a transaction: // Transaction object var tnxObj = '{from: "'+fromAddr+'", to: "'+toAddr+'", value: "' + amount + '"}'; web3.personal.unlockAccount(fromAddr, "pwd123", function(err, result) { if (err != null) { console.error("Error while unlocking account: "+err); } else{ console.log("Account unlocked!"); web3.eth.sendTransaction({tnxObj} , function(err, result) { if (err != null) { console.error("Error while sending transaction: "+err); } else{ console.log("Transaction Sent!"); } }); } });

Any idea what I did wrong?

1 Answer 1

0

tnxObj should be an object, not a string.

Instead of

var tnxObj = '{from: "'+fromAddr+'", to: "'+toAddr+'", value: "' + amount + '"}';

just do

var tnxObj = {from: fromAddr, to: toAddr, value: amount};
3
  • Thank Mr. Edgar. I have changed the line and now, there is no exception.
    – 0x75aaa
    Commented Sep 13, 2017 at 7:19
  • However, the transaction did not get through. When I check the transaction in the terminal, the value of the 'to:' parameter is 'null'. In other words the recipient's address was lost. Nonetheless, same transaction work in the geth terminal. Thank you again for your help.
    – 0x75aaa
    Commented Sep 13, 2017 at 7:27
  • Thank you Mr. Edgar, it worked! My apology if I took your time. My careless mistake. If you notice the line: 'code' web3.eth.sendTransaction({tnxObj} ...'code' it has extra curly brackets! Took them out and it work.
    – 0x75aaa
    Commented Sep 13, 2017 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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