I have wrote it like this but it is always throwing error that inputAmount is not in range but it is in range,

const transaction = await preSaleContract.buyTokens({value: inputAmount, from: userAddress}) await transaction.wait(); and like this also

const transaction = await preSaleContract.buyTokens().send({value: inputAmount, from: userAddress});

1 Answer 1


Try parsing your input amount.

let tx = await connectedContract.YOUR_PAYABLE_FUNCTION(ALL, OTHER, PARAMETERS, {value: ethers.utils.parseEther(ETH_VALUE_AS_STRING)});

In Your case,

const transaction = await preSaleContract.buyTokens({value: ethers.utils.parseEther(inputAmount), from: userAddress})

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.