Solidity and Remix – Transferring Ether from Test Account to Contract

etherremixsolidity

I have a contract successfully deployed and working well in the Javascript VM on Remix.

contract BlipCoinIco is PausableToken {
  *snip*

  function() isIcoOpen payable {
      totalRaised = totalRaised.add(msg.value);

      uint256 tokenAmount = calculateTokenAmount(msg.value);
      balances[fundsWallet] = balances[fundsWallet].sub(tokenAmount);
      balances[msg.sender] = balances[msg.sender].add(tokenAmount);
      Transfer(fundsWallet, msg.sender, tokenAmount);

      // immediately transfer ether to fundsWallet
      fundsWallet.transfer(msg.value);
  }

  function calculateTokenAmount(uint256 weiAmount) constant returns(uint256) {
      // standard rate: 1 ETH : 50 ESP
      uint256 tokenAmount = weiAmount.mul(50);
      if (now <= startTimestamp + 7 days) {
          // +50% bonus during first week
          return tokenAmount.mul(150).div(100);
      } else {
          return tokenAmount;
      }
  }

  *snip*
}

The Javascript VM provides a couple of test accounts with preloaded Ether:

enter image description here

The contract owner and fund's wallet belongs to the first test account.

How can I send ether to the first test account, from the second test account, so that it hits the contract's isIcoOpen payable function?

I've tried using the send and transfer functions, but I can't get it to work.

Best Answer

You don’t have to send ether to the other account to trigger the function. The function you mention is a fallback function of the contract. To trigger it you have to send ether to the contract, not the accounts you list.

Related Topic