I have an issue with getEthToTokenInputPrice Here is part of my code that is not working.

const web3_utils = require('web3-utils')
const Web3 = require('web3')

const ETH_AMOUNT = web3_utils.toWei('1', 'Ether')
const exchangeContract = new web3.eth.contract(EXCHANGE_ABI, EXCHANGE_ADDRESS);
const daiAmount = await exchangeContract.methods.getEthToTokenInputPrice(ETH_AMOUNT).call()

But I am getting this error:

TypeError: Cannot read properties of undefined (reading 'getTokenToEthInputPrice')

From this documentation https://docs.uniswap.org/protocol/V1/reference/exchange it seems right but it's failing on getTokenToEthInputPrice. Any help will be appreciated.

  • I think your contract is not properly deployed...are you trying to access an existing one or creating a new one ? Apr 16, 2022 at 3:36
  • I am accessing an existing one. What do you mean that it is not properly deployed @DanielWeigel
    – Byusa
    Apr 19, 2022 at 19:18

1 Answer 1


It seems like the contract does not contain the method you are using. getEthToTokenInputPrice is a method only available on uniswap v1's exchange contract.

For example, the exchange for DAI and Eth is on 0x2a1530C4C41db0B0b2bB646CB5Eb1A67b7158667. Your code should work fine with it.

Hope that helps, happy coding.

  • Don't copy & paste the same answer. The system will flag them as duplicates. If you think the questions are the same you can flag them as duplicates.
    – Ismael
    Mar 8, 2023 at 5:30
  • 1
    Sorry didn't know this. I was just being lazy, now it is modified to fit this question. Mar 8, 2023 at 5:38

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.