I have this payable fallback function in a contract code:

function() is_live() payable {
        if (msg.value == 0) throw;
        if (isFinalized) throw;

        uint256 tokens = safeMult(msg.value, tokenExchangeRate);   // calculate num of tokens purchased
        uint256 checkedSupply = safeAdd(totalSupply, tokens);      // calculate total supply if purchased

        if (maxCap < checkedSupply) throw;                         // if exceeding token max, cancel order

        totalSupply = checkedSupply;                               // update totalSupply
        balances[msg.sender] += tokens;                            // update token balance for payer
        MPYCreation(msg.sender, tokens);                           // logs token creation event

In truffle console I execute the command:

Token.send(500, {from: web3.eth.accounts[1]})

(Where Token refers to the contract instance)

But then I check web3.eth.accounts[0] and web3.eth.accounts[1] balances and 0 has paid the weis, while 1 has a balance of 10 ether.

How is this possible?


  • 1
    To call the fallback of your contract use eth.sendTransaction({ to: "0xContractAddress", from: web3.eth.accounts[1], value: web3.toWei(1, "ether") })
    – Ismael
    Jul 24, 2017 at 17:19
  • @Ismael make it an answer and I'll accept it Jul 28, 2017 at 10:11

1 Answer 1


To call the fallback of your contract you have to send a transaction, a low level way of doing this is the following:

var amount = web3.toWei(1, "ether");
var account = web3.eth.accounts[1];
var contractAddress = "0xContractAddress";
eth.sendTransaction({ to: contractAddress, from: account, value: amount });

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.