0

I am trying to pass a negative integer to smart contract, but it is not success.

Take this smart contract as an example https://etherscan.io/address/0xc90ea5fa2d3eacbd63ae9e37c80a5772e57785b6#readContract#F15

When calling ticks function, it requires int24 as an input parameter.

#1. input = -276200

It gives error saying "invalid BigNumber string (argument="value", value="00000000000000000-276200", code=INVALID_ARGUMENT, version=bignumber/5.1.1)"

#2. input = 0xFBC918

It gives error saying "value out-of-bounds (argument=null, value="0x000000000000000000FBC918", code=INVALID_ARGUMENT, version=abi/5.0.7)"

What would be the correct input to pass negative number to smart contract function? Thank you.

1 Answer 1

1

If you are trying to use it directly on etherscan i don't know how to help you but in ethers you can do it straight as -276200

//...
    const mintingParams = {
      token0: token0,
      token1: token1,
      fee: fee,
      tickLower: -276200,
      tickUpper: 276200,
      amount0Desired: amount0Desired,
      amount1Desired: amount1Desired,
      amount0Min: amount0Min,
      amount1Min: amount1Min,
      recipient: recipient,
      deadline: deadline,
    }
    
    const tx = uniswapV3Pool.mint(mintingParams)

    tx.wait()
    return tx.hash

//...




2
  • 1
    I consider this as accepted answer. I overlooked the parameter and passed it as string, ie. "-276200", but it gave the error "invalid BigNumber string". However, if I pass it after parseInt, it responses with correct result now.
    – Ben
    Dec 27, 2022 at 1:14
  • Glad i could help you finding the solution :) Dec 28, 2022 at 3:59

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.