I'm testing a simple fallback function with Truffle, the fallback function is:

function () public payable {
    internalTransfer(this, msg.sender, 100000000);
    FundSuccess(msg.sender, msg.value);

function internalTransfer(address _from, address _to, uint256 _value) 
  internal returns (bool) {
    // SafeMath.sub will throw if there is not enough balance.
    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(_value);
    return true;

where .sub and .add are imported from SafeMath library, in the truffle test I have

trx = await token.send(power18(1), {from: accounts[1]});
var balance1 = await token.balanceOf.call(accounts[1]);

what I found was, no matter what I specify in the from, balance is always assigned to account[0]. Checking the transaction in Ganache shows that the transaction was recorded as sent from account[0].

I know {from:...} works, I have used it in other places and never had a problem. This is the first time I used it on ".send". I am at a stage where I do not know how to proceed, tried googling but couldn't find good information, please help!

1 Answer 1


It looks like send ignores the tx_params (aka the {from: val, ...}) object.

Here's its implementation.

You can use sendTransaction instead, which works as expected:

token.sendTransaction({from: accounts[1], value: 10**18})

IMO this was poorly documented, and the usage of send should conform to the standard that most other functions have set.


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.