Contract method calls?

jedimalonejedimalone Member Posts: 8

I've created a contract object for my solidity contract as described in the JavaScript API here:

Now when I go down to Contract Methods, I try to do what it tells me, but it seems like my transaction object is being ignored? What am I doing wrong?
This is my code:

machineInstance.buyClipcard($("#cardname").val(), {from: web3.eth.coinbase, value: price, gas: web3.toWei(1000, "finney")});

I can se my transaction in the pending box (and then the contract box), but it has the following details:

From: 78ceb0333e422a96c06f50a0581e900b7f098050
To: aa6416e3902654dfd2eedb7918a3532b072f3f4b
Value: 0 wei #27
Gas price: 10000 Gwei
Gas: 3141592
0000 :??3Malone?????? 3a af f0 33 4d 61 6c 6f 6e 65 00 00 00 00 00 00
0010 ???????????????? 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0020 ???? 00 00 00 00
.. (yadda yadda)

Why it the value 0? Why is the gas not right? I am doing what the examples on the JavaScript API tells me to do.

Please help me, as this is part of mine and my group's bachelor thesis


  • SmithgiftSmithgift Member Posts: 64
    This line may be part of your problem:

    gas: web3.toWei(1000, "finney")

    gas is the number of steps not the total cost. The total spent on gas is gasPrice * gas.

    If I may ask, what specific program/version are you using?
  • jedimalonejedimalone Member Posts: 8
    It started to work using the following code:

    machineInstance.buyClipcard.sendTransaction($("#cardname").val(), {from: web3.eth.coinbase, value: price, gas: 1000000});

    I think there was something amiss in my web3.js
  • PranayPranay Member Posts: 58
    Nice to hear that its started working, but sometime also we have to increase gas price to accommodate the contract execution.
Sign In or Register to comment.