0

My code is like this :

gameInstance.initGame.sendTransaction({from: webInstance.eth.coinbase, to: contractAddress, value: webInstance.toWei(person_num, "ether")});

Of course, it doesn't work very well.

Codes in the function has been executed, but ether haven't been transferred. And value of the variable "person_num" is not 0.

So what can I do?

0

use this

gameInstance.initGame({from: web3.eth.coinbase, to: contractAddress, value: web3.toWei(person_num, "ether")});
|improve this answer|||||
  • I tried and it doesn't work...[br /]I also tried add the second parameter, like below:[br /]gameInstance.initGame({from: webInstance.eth.coinbase, to: contractAddress, value: webInstance.toWei(person_num, "ether")}, function(err, res){ console.log(err); console.log(res); });[br /]And it doesn't work either – hankuksui Mar 20 '18 at 11:15
  • if the code executed and didn't show any error by web3. then kindly check your solidity function 'initGame' and ensure that you have write the right code to transfer the ether – Akash Mar 20 '18 at 11:18
  • Thank you for your help. I tested it in Ethereum Wallet and the function works ok. So I think maybe the function is right? – hankuksui Mar 20 '18 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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