I have created a payment function, the problem is that the tez is debited from my contract and I would like it to be debited from a wallet address, how do I do this? If I replace Tezos.transaction unit purchase_price ship_address it gives me a compilation error...

let purchase (item,purchase_price, store : nat * tez * nft_token_storage) : operation list * nft_token_storage = 
    let ship_address : address = ("tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" : address) in
    let vendor_address : address = ("tz1M6BCKeb1hWX7DD8qcKB4T5zJKNpsk5YCc" : address) in

    let vendor_contract : unit contract =
      match (Tezos.get_contract_opt (vendor_address) : unit contract option) with
        Some contract -> contract
      | None -> (failwith "Contract not found." : unit contract) in
       let op : operation = Tezos.transaction unit purchase_price vendor_contract in

    if Tezos.source <> ship_address then (failwith ("Access denied"): operation list * nft_token_storage) else
    if Tezos.amount > purchase_price then (failwith ("Incorrect amount"): operation list * nft_token_storage) else ([op], store)

1 Answer 1


You need to enforce the sender to send an amount equal to purchase_price.

if Tezos.amount <> purchase_price then failwith ...

And when calling the contract you need to provide an amount equal to purchase_price in the transaction.

  • Hi Rodrigo, so I have to pass it as a purchase price and amount parameter to my function? because when calling it fails.. it always returns me amount invalid :(
    – oriana
    Commented Apr 5, 2022 at 7:21
  • The initial transaction operation needs to include the respective amount. The transaction has an "amount" field. Commented Apr 5, 2022 at 7:37

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.