Contract code:

function rand( uint256 seedB ) returns (uint256){ 
    //define seedA variable
    uint256 seedA = 1;
    uint amount = 1 finney;
    if (seedA == seedB) { 

    return seedA + seedB; 


Basically, if SeedA (which equals 1) equals SeedB it sends amount to msg.sender.

Why does this not work, when I am calling the function using:

    {from: eth.accounts[0], 
    value: web3.toWei(.0001, 'ether'), 
    to: '0x4abc14efad9a7a84a0a9ef6e1a782c43a9e3f550', 
    gas: 500000,  data: web3.fromAscii('message')})

Here is the contract address: https://www.etherchain.org/account/0x4abc14efad9a7a84a0a9ef6e1a782c43a9e3f550

Am I invoking the contract improperly in the sendTransaction? I am invoking it from inside my local geth client.

How do I ensure my parameter (1) is passed into the contract function rand via sendTransaction?


In your contract you are trying to send 1 finney, but you are only providing your contract with 0.1 finney... A Finney is 0.001 ETH, not 0.0001

  • OMG. My code has been working all day. You do not want to know how long I have been trying to work this out. I have stripped back my code to bare basics because of this error LOOOOL THANK YOU. It now works, you can see the first sent tx from the contract address: etherchain.org/account/… Feb 5 '16 at 14:28
  • 1
    No problem. You can also use "finney" as the units in web3.fromWei Feb 5 '16 at 14:30
  • 2
    Also, you don't need to put the to: field in the tx object. It gets filled in automatically Feb 5 '16 at 14:32

It might be because you supply data when calling sendTransaction on an actual function, overriding the function identifier and the function argument you gave (1).


Try web3.eth.defaultAccount = web3.eth.accounts[0]

and then random.rand.sendTransaction(1)

  • 1
    The transactions are going through, just I am not seeing that seedA == seedB because if it did it would send me 1 Finney. Feb 5 '16 at 14:08

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.