So I have the following functions
buyTokens
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(getRate());
weiRaised = weiRaised.add(weiAmount);
token.issue(address(vault), tokens);
vault.deposit.value(msg.value)(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
forwardFunds
function forwardFunds() internal {
wallet.transfer(msg.value);
}
deposit (in another smart contract)
function deposit(address supporter, uint256 tokensAmount) onlyOwner public payable{
depositedETH[supporter] = depositedETH[supporter].add(msg.value);
depositedToken[supporter] = depositedToken[supporter].add(tokensAmount);
emit Deposit(supporter, msg.value, tokensAmount);
}
So buyTokens won't work unless I comment out EITHER the deposit call or the forwardFunds call. After doing some reading I was thinking that it had something to do with gas?
Furthermore, if I call the deposit function by passing the value as a param rather than receiving through the msg object in the other function (not using .value() methodology) it works fine.
vault.deposit(beneficiary, tokens, msg.value)
Is there an issue with using a .value() call and also forwarding to an internal function that uses .transfer()?
Thanks!
buyTokens
won't work", but in which way? Kindly share which message lets you know there is a problem. Like a call with arguments and what you see then.