0
validator :: BuiltinData -> BuiltinData -> BuiltinData -> ()
validator _ _ ctx =
  if paidTo seller then () else traceError "NFT locked until seller is paid."
    where
      paidTo x = valuePaidTo txInfo (PubKeyHash x) `gt` minAmount
      txInfo = scriptContextTxInfo $ unsafeFromBuiltinData ctx
      minAmount = assetClassValue (assetClass adaSymbol adaToken) 50
      seller1 = <public key hash of seller1_addr>

This is the basic validator. It compiles to PLC code and I can lock the NFT to the script address, however when I try to build a transaction to spend it:

cardano-cli transaction build \
--babbage-era \
--testnet-magic 2 \
--tx-in $script_utxo \
--tx-in-script-file $script_file \
--tx-in-inline-datum-present \
--tx-in-redeemer-value $redeemer \
--tx-in-collateral $buyer_utxo \
--tx-out "$(cat $seller1_addr) + 100000000 lovelace" \
--tx-out "$(cat $buyer_addr) + 1 $NFT" \
--change-address $(cat $buyer_addr) \
--protocol-params-file proto_params \
--out-file buyer_unsigned.tx

It fails with the following:

the script for transaction input 0 (in the order of the TxIds) failed with: 
The Plutus script evaluation failed: An error has occurred:  User error:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Script debugging logs: NFT locked until seller1 paid.

Is there something incorrect here? What am I missing?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.