0

I'm trying to make a contract call that requires an amount of tezos to be sent in. I've done this before and it has worked, but now I get this error every time.

Here's the code I'm running:

  const costOfNFT = 0.1

  const value = { amount: costOfNFT }

  const purchaseNFTOperation = await contract.methods
     .buy(nftId)
     .send(value)

Here's the error:

[amount] Value is not a number: undefined
undefined
NatValidationError
NatToken {
  val: { prim: 'nat', annots: [ '%amount' ] },
  idx: 1,
  fac: [Function: createToken],
  createToken: [Function: createToken]
}

It seems like somehow it's not recognizing the amount I'm sending. I've tried as well:

  const value = { amount: costOfNFT*1000000, mutez:true }

Let me know if there's another way to send tezos in a contract call. I'm super confused how this works in another contract call I'm doing.

Thanks

2
  • Not 100% sure, but it looks like you may be trying to call an entrypoint that expects a value of type nat called amount. Could you share the entrypoint type signature in Michelson? Commented Jan 26, 2023 at 17:19
  • @ClaudeBarde You are exactly correct! I got thrown off because I was alternating between two contracts which I thought were identical, but one of them had another param called "amount". This was thrown when trying to call that contract & not the other. Thanks for the help! Commented Jan 26, 2023 at 20:42

2 Answers 2

1

1000000 mutez is 1 tez, so give this a try instead?

const value = { amount: costOfNFT * 1000000, mutez:true }

Hope it helps:)

1

This was all because I was trying to call a contract with a param called "amount" that I was not passing. I got thrown off because I was alternating between two contracts which I thought were identical, but one of them had another param called "amount". This was thrown when trying to call that contract & not the other. Thanks for the help!

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.