I have a smart contract where user can transfer ETH to an ICO. Like this

function buyICO(paymentAddress, amount) {

// do some other important things

// transfer the amount to the payment address


Because some ICOs require a specific gas price and limit, but I can't set these in the transfer function. I can set it when user call buyICO() function but I don't know how do I calculate the gas limit and price for the whole thing.

What's the best practice here?

1 Answer 1


If you want to adjust gas limit you should use address.call.value().gas()(). See this answer for more details <address>.send vs <address>.transfer best practice usage? You can't adjust the gas price though.

  • sweeet, thanks for this! exactly what I needed. however would this be a problem that I can't adjust gas price? it is often required by ICOs to set a certain price and limit when participating. May 16, 2018 at 10:03
  • Then you will have to set the gas price when calling buyICO() in the top level transaction. The internal call .transfer() inherits this price. May 16, 2018 at 10:23
  • You can accept the answer if it helped May 16, 2018 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.