You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
In this Tx, one input Utxo that has 1000 Ada was consumed for about 5.555 Ada, but the leftover was not return its source account, instead, the leftover was split into 2 part and sent to two account.
Though all these accounts belong to one Wallet.
But I want the leftover return to it original address. How to archive this goal?
Code of the bid endpoint is almost the same as PPP week01 example, exception that I remove the mustValidateIn limitation.
bid :: forall w s. BidParams -> Contract w s Text ()
bid bp@BidParams{..} = do
(oref, o, d@AuctionDatum{..}) <- findAuction bpCurrency bpToken
when (bpBid < minBid d) $
throwError $ pack $ printf "bid lower than minimal bid %d" (minBid d)
pkh <- ownPaymentPubKeyHash
let b = Bid {bBidder = pkh, bBid = bpBid, bSecret = emptyByteString}
let b2 = Bid {bBidder = pkh, bBid = bpBid, bSecret = bpSecret}
d' = d {adHighestBid = Just b}
v = Value.singleton bpCurrency bpToken 1 <> Ada.lovelaceValueOf (minLovelace + bpBid)
r = Redeemer $ PlutusTx.toBuiltinData $ MkBid b2
lookups = Constraints.typedValidatorLookups typedAuctionValidator P.<>
Constraints.otherScript auctionValidator P.<>
Constraints.unspentOutputs (Map.singleton oref o)
tx = case adHighestBid of
Nothing -> Constraints.mustPayToTheScript d' v <>
Constraints.mustSpendScriptOutput oref r
Just Bid{..} -> Constraints.mustPayToTheScript d' v <>
Constraints.mustPayToPubKey bBidder (Ada.lovelaceValueOf bBid) <>
Constraints.mustSpendScriptOutput oref r
ledgerTx <- submitTxConstraintsWith lookups tx
void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
logInfo @P.String $ printf "made bid of %d lovelace in auction %s for token (%s, %s)"
bpBid
(P.show adAuction)
(P.show bpCurrency)
(P.show bpToken)
I have manager to do this via cardano-cli. So my question are:
Is there equivalent constraints function in PAB endpoint as --tx-in-collateral of cardano-cli ?
Is there equivalent constraints function in PAB endpoint as --change-address of cardano-cli ?
Maybe they are there, but I can not find them while searching for long time.
Describe alternatives you've considered
Should provide constraints to support feature like cli's --tx-in-collateral and --change-address.
The text was updated successfully, but these errors were encountered:
code-brewer
changed the title
Should be able to transfer leftover/change Ada to it original address!
Should be able to transfer leftover/change Ada back to it original address!
Jun 23, 2022
It seems it's the way how cardano-wallet works which we use to balance the transaction. There is an issue for this — cardano-foundation/cardano-wallet#2614
I'm not sure but you may try to avoid using the cardano-wallet balancing (submitTxConstraintsWith calls balanceTx).
And to answer the comparison with cardano-cli, we don't yet have the equivalent of --tx-in-collateral and --change-address. However they are tracked internally.
Describe the feature you'd like
These question come from the issue when practice the PPP week01 on testnet. I did some Bid action on the contract.
One Bid Tx is: https://testnet.cardanoscan.io/transaction/721856d69696a58a466b02779b01d28058356ef6cf3e4e4dee3952a6faddc081
In this Tx, one input Utxo that has 1000 Ada was consumed for about 5.555 Ada, but the leftover was not return its source account, instead, the leftover was split into 2 part and sent to two account.
Though all these accounts belong to one Wallet.
But I want the leftover return to it original address. How to archive this goal?
Code of the bid endpoint is almost the same as PPP week01 example, exception that I remove the mustValidateIn limitation.
I have manager to do this via cardano-cli. So my question are:
--tx-in-collateral
of cardano-cli ?--change-address
of cardano-cli ?Maybe they are there, but I can not find them while searching for long time.
Describe alternatives you've considered
Should provide constraints to support feature like cli's
--tx-in-collateral
and--change-address
.The text was updated successfully, but these errors were encountered: