text:
Use the week 01 Nix-shell for week 02?
I'd like to know if we should use the week 01 nix-shell?
My expectation is that the week 01 nix-shell, was used to start the playground service and the front-end UI.
Although, it's clear that there's a need to have the *.nix files for nix-shell to work or startup, would be nice to hear from someone more experienced in nix.

Each week, you should change into the plutus-pioneer-program directory
cd plutus-pioneer-program

Pull the latest changes from upstream
git pull

View the plutus-apps git tag for the week in the cabal.project file. For week 2, look at plutus-pioneer-program/code/week02/cabal.project. On line 63 you see the git tag.
source-repository-package
  type: git
  location: https://github.com/input-output-hk/plutus-apps.git
  tag: 6aff97d596ac9d59460aab5c65627b1c8c0a1528

Then change into plutus-apps
cd plutus-apps

Pull the latest changes from upstream
git pull

And checkout the appropriate tag
git checkout 6aff97d596ac9d59460aab5c65627b1c8c0a1528

Make sure you're in the plutus-apps directory and that you've checked out the correct tag. From there you can start as many Nix shells as necessary.
nix-shell

You may or may not want a Nix shell each for:

starting the playground server
starting the playground client
building and serving Haddock docs
starting a cabal REPL inside the appropriate week project
building the cabal project

Thanks @Travis!


text:
How will Cardano deal with the rise of quantum computing?
From my understanding, today's cryptography will be vulnerable to attacks from quantum computers soon. Are there any plans that IOG or Charles has mentioned about how Cardano will deal with the rise of quantum computing in the next few years / decade? What measures will be taken to keep the network secure and business as usual?
Thanks,
Myles

While this may be a concern in the future, there is currently no quantum computing system powerful enough to pose a threat to modern cryptographic standards. That being said, there are quantum-resistant signature schemes that can be employed if needed, such as XMSS.
There are drawbacks however; the signatures for such schemes tend to be much larger than the elliptic curve schemes currently used, which would lead to faster chain growth. As such, quantum resistant schemes can and will be deployed as soon as quantum computers pose a significant risk. Until then, they are simply unnecessary.

Thanks for the reply. Waiting until it becomes a problem / poses a significant risk does not seem like IOG's style at all. How do we definitively know what Google's or IBM's quantum computer is able to do? I'm not sure we can answer that. I realize I'm thinking at least a few years into the future but that's why now's the time to start thinking about it.

I don' think IOG is really waiting for it to become a problem, they simply realize that quantum resistance is not a priority right now because there is so much else to do. Considering the conservative approach IOG tends to take when implementing new features, it makes sense that they'd hold off on something that just isn't necessary right now. Charles even mentioned in one of his AMA's (sorry I can't remember which one) that implementing quantum resistance can and will be done, just not in the next year or two.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Im trying to split up a utxo in a Script into a value of 1 ada what do I do
Here is my code currently it ends up sending all of the value on the script to the caller but I only want it to send 1 ADA. How do I fix this? Is there anyway to create a smaller output to send
purchase :: AsContractError e => MintParams -> Contract w s e ()
purchase mp =  do
    utxos <- fundsAtAddressGeq valAddress (Ada.lovelaceValueOf 1)

    let redeemer = ()
        pkh = ownPubKey
        tx       = collectFromScript utxos redeemer

    void (submitTxConstraintsSpending lootBox utxos tx)

Because this is a utxo system all utxo's must be consumed and the outputs must balance. In the above case, if I understand your code correctly, the redeemer is the unit () which always passes. As such, any input/output consuming the contract would be accepted. You could send 1 ada to someone and send the rest back to the contract's script address (with fees subtracted) to do what you want.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
script for automation sending tokens
i just finished my first script and would love to share some ideas and also to listen your opinion for additional development.
how the script works and what it does

create Log file :)
while (looping)
save on a file with all UTXOs / TxHashes
new while (looping) , till all UTXOs on the previous file are read
save infos from the UTXOs in variables
if TX_hash is inside a file (we have created before)
then, old TX is found -> go Up in the begin of the second While (step 4.)
else, new TX is found :)
find the sender of the Transaction by
curl -H 'project_id: mainnetsldfkjslfjlsjfowejfslvlsvn'
https://cardano-mainnet.blockfrost.io/api/v0/txs/${tx_hash}/utxos
| jq '.inputs' | jq '.[0]' | jq '.address' | sed 's/^.//;s/.$//')
if the balance is not the requested amount of ADA,
11, then, send the amount of ADA back (user will loose few ada , because of the Fee)
else, send Token to the address we find in step 9. :)

who needs more help, i am happy to assist.
theTokenSquare17

This isn't a question...

This site is not for opinions/discussions.  Please take a look at this topic in the -> [help/dont-ask]


text:
VS Code Remote VM IntelliSense Issues
I was having trouble getting Plutus running properly on Windows & WSL2, so I spun up an Ubuntu Server VM on my Proxmox server and set everything up there. I use VS Code via SSH to connect from Windows. The Plutus application/code and playground run without issue, however, there is no IntelliSense for the Haskell code.
I already have the Haskell extension installed in VS Code for the remote VM (as suggested here: How to get intellisense/auto suggestion working for Plutus in VSCode?). The extension does not have any errors. It does act like it is processing the files, but the types, etc. never appear on hover.
I already have Nix, docker & GHC installed on the VM.
I have tried running it in and out of the devcontainer, but no luck with IntelliSense.
Here is the source code: https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week02
The one thing that did work with IntelliSense was running the following project via devcontainer: https://github.com/input-output-hk/plutus-starter. However, I currently do not understand why this would vary project to project. I even tried replacing the docker image in the pioneer program devcontainer.json with the one from the starter project, but that didn't work either.
The Plutus Pioneer Program is my first foray into the Haskell ecosystem, so I'm sure it is something fundamental that I have misunderstood. Any clarity on this would be much appreciated.

Unfortunately this doesn't work in the plutus pioneer program weeks so far (currently week03). Your IDE uses the haskell language server to get type references but if you run the command haskell-language-server in a nix-shell in the current week's repository you will get an error. This is documented in this question: HLS Compiler Error PPP Week01 (WSL2 + VSCode)


text:
build transaction without giving fee, is it possible? --change-address
i have seen in forum.cardano someone giving the parameter --change-address and explaing that we dont have to calculate the fee.
does anyone can verify this for mainnet and this current moment, if that works?
also my understanding is, we will give input, then the output to the recipient(s) and the rest goes to my address (in --change-address)
for the example below, we see a mint Token. can we use --change-address for any transaction? also only to send ADA?
cardano-cli transaction build
--mainnet
--alonzo-era
--tx-in $txhash#$txix
--tx-out $address+$output+"$tokenamount $policyid.$tokenname"
--change-address $address
--mint="$tokenamount $policyid.$tokenname"
--minting-script-file $script
--metadata-json-file metadata.json
--invalid-hereafter $slotnumber
--witness-override 2
--out-file matx.raw
do we need also the "--alonzo-era " ?

Using --change-address will send all the remaining balances to the specified address. It also includes tokens other than adas. Just keep in mind that there is a min amount of ada required for each utxo.
Yes, you need --alonzo-era.
There are some mistakes in your build command. You are missing following options.
--tx-in-collateral before the first --tx-out
--mint-redeemer-value or --mint-redeemer-file after --mint-script-file
--mint-script-file, not --minting-script-file

great, thank you so much for your quick respond, that give me amazing flexibility in script i write, and i had issue for some TxHashes, for specific cases.
For the mistakes i had in my build commands, was taken from guild operators, where they give only one specific case.
i will check your option and testing before using :)
thank you so much, and continue the amazing work mate.
TTS


text:
How do I test the on-chain validator in Vesting.hs?
In Plutus Pioneer Program, Iteration #3, Lecture #3, Part #4 at 27:48, Lars mentions that he wrote the contract code in a way that invalid transactions will always be caught by the off-chain code. So the on-chain validator never really gets exercised. He says that, as optional homework, you can modify the off-chain code so it always passes. I attempted to do that but I wasn't successful.
Here is the original Vesting.hs.
I modified the off-chain code to always pass by replacing the grab endpoint with a copy of the grab endpoint from week 2's Gift.hs. Here's the full script I'm pasting into the Plutus Playground.
{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE DeriveAnyClass      #-}
{-# LANGUAGE DeriveGeneric       #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE NoImplicitPrelude   #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell     #-}
{-# LANGUAGE TypeApplications    #-}
{-# LANGUAGE TypeFamilies        #-}
{-# LANGUAGE TypeOperators       #-}

{-# OPTIONS_GHC -fno-warn-unused-imports #-}

module Week03.Vesting where

import           Control.Monad        hiding (fmap)
import           Data.Aeson           (ToJSON, FromJSON)
import           Data.Map             as Map
import           Data.Text            (Text)
import           Data.Void            (Void)
import           GHC.Generics         (Generic)
import           Plutus.Contract
import           PlutusTx             (Data (..))
import qualified PlutusTx

import qualified PlutusTx.Builtins   as Builtins
import           PlutusTx.Prelude     hiding (Semigroup(..), unless)
import           Ledger               hiding (singleton)
import           Ledger.Constraints   (TxConstraints)
import qualified Ledger.Constraints   as Constraints
import qualified Ledger.Typed.Scripts as Scripts
import           Ledger.Ada           as Ada
import           Playground.Contract  (printJson, printSchemas, ensureKnownCurrencies, stage, ToSchema)
import           Playground.TH        (mkKnownCurrencies, mkSchemaDefinitions)
import           Playground.Types     (KnownCurrency (..))
import           Prelude              (IO, Semigroup (..), Show (..), String)
import           Text.Printf          (printf)

data VestingDatum = VestingDatum
    { beneficiary :: PaymentPubKeyHash
    , deadline    :: POSIXTime
    } deriving Show

PlutusTx.unstableMakeIsData ''VestingDatum

{-# INLINABLE mkValidator #-}
mkValidator :: VestingDatum -> () -> ScriptContext -> Bool
mkValidator dat () ctx = traceIfFalse "beneficiary's signature missing" signedByBeneficiary &&
                         traceIfFalse "deadline not reached" deadlineReached
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    signedByBeneficiary :: Bool
    signedByBeneficiary = txSignedBy info $ unPaymentPubKeyHash $ beneficiary dat

    deadlineReached :: Bool
    deadlineReached = contains (from $ deadline dat) $ txInfoValidRange info

data Vesting
instance Scripts.ValidatorTypes Vesting where
    type instance DatumType Vesting = VestingDatum
    type instance RedeemerType Vesting = ()

typedValidator :: Scripts.TypedValidator Vesting
typedValidator = Scripts.mkTypedValidator @Vesting
    $$(PlutusTx.compile [|| mkValidator ||])
    $$(PlutusTx.compile [|| wrap ||])
  where
    wrap = Scripts.wrapValidator @VestingDatum @()

validator :: Validator
validator = Scripts.validatorScript typedValidator

valHash :: Ledger.ValidatorHash
valHash = Scripts.validatorHash typedValidator

scrAddress :: Ledger.Address
scrAddress = scriptAddress validator

data GiveParams = GiveParams
    { gpBeneficiary :: !PaymentPubKeyHash
    , gpDeadline    :: !POSIXTime
    , gpAmount      :: !Integer
    } deriving (Generic, ToJSON, FromJSON, ToSchema)

type VestingSchema =
            Endpoint "give" GiveParams
        .\/ Endpoint "grab" ()

give :: AsContractError e => GiveParams -> Contract w s e ()
give gp = do
    let dat = VestingDatum
                { beneficiary = gpBeneficiary gp
                , deadline    = gpDeadline gp
                }
        tx  = Constraints.mustPayToTheScript dat $ Ada.lovelaceValueOf $ gpAmount gp
    ledgerTx <- submitTxConstraints typedValidator tx
    void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
    logInfo @String $ printf "made a gift of %d lovelace to %s with deadline %s"
        (gpAmount gp)
        (show $ gpBeneficiary gp)
        (show $ gpDeadline gp)

grab :: forall w s e. AsContractError e => Contract w s e ()
grab = do
    utxos <- utxosAt scrAddress
    let orefs   = fst <$> Map.toList utxos
        lookups = Constraints.unspentOutputs utxos      <>
                  Constraints.otherScript validator
        tx :: TxConstraints Void Void
        tx      = mconcat [Constraints.mustSpendScriptOutput oref $ Redeemer $ Builtins.mkI 17 | oref <- orefs]
    ledgerTx <- submitTxConstraintsWith @Void lookups tx
    void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
    logInfo @String $ "collected gifts"

endpoints :: Contract () VestingSchema Text ()
endpoints = awaitPromise (give' `select` grab') >> endpoints
  where
    give' = endpoint @"give" give
    grab' = endpoint @"grab" $ const grab

mkSchemaDefinitions ''VestingSchema

mkKnownCurrencies []

I set up the simulation exactly as Lars has it in the video:
3 wallets with 100000000 Lovelace opening balances.

Wallet 1 gives 30 ADA to wallet 2 with a deadline of slot 10
Wait for 1 slot
Wallet 1 gives 30 ADA to wallet 2 with a deadline of slot 20
Wait for 1 slot
Wallet 1 gives 30 ADA to wallet 3 with a deadline of slot 10
Wait until slot 11
Wallet 2 grabs
Wallet 3 grabs
Wait for 5 slots

After evaluating the simulation, I expected the exact same transactions as Lars at 24:59 in the video:

Slot 0: set the opening balances for the 3 wallets
Slot 1: wallet 1 locks 30 ADA at script address
Slot 2: wallet 1 locks another 30 ADA at script address
Slot 3: wallet 1 locks another 30 ADA at script address
Slot 12, tx 0: wallet 3 grabs 30 ADA from the script
Slot 12, tx 1: wallet 2 grabs 30 ADA from the script (the other 30 ADA for wallet 2 doesn't get unlocked because the deadline is not reached)

However, there is no slot 12 in my simulation. Meaning that neither of the expected grab transactions went through.

I would post the full log and trace but they exceed StackExhange's character limit. Instead, here's the most interesting piece I've found in the trace:
Slot 11: 00000000-0000-4000-8000-000000000002 {Wallet Wc30e}:
             Contract instance stopped with error: "WalletError (ValidationError (ScriptFailure (EvaluationError [] \"BuiltinEvaluationFailure of UnConstrData\")))" ]

I know I'm doing something wrong. How do I set up Vesting.hs to test the on-chain validator?

The error that you are getting is due to you are using an invalid redeemer: Redeemer $ Builtins.mkI 17. The validation script needs () as redeemer. You should use unitRedeemer. In this case the error occurs when the offchain part tries to build the transaction. Having said that you cannot debug onchain because it never reaches the validator.
tx      = mconcat [Constraints.mustSpendScriptOutput oref $ Redeemer $ Builtins.mkI 17 | oref <- orefs]

On other hand, if you fix this, it will fail again because you don't set the time validation constraint in offchain code Constraints.mustValidateIn (from now). If you don't set it, the default validity interval is "all the time", and the validator will fail with "deadline not reached".
Additionally, if you fix these two things (valid redeemer and time constraint), it will fail in grab because it will try to spend all UTXOs (the good ones and the others) sitting at the script address, and the validator will reject the transaction.


text:
Is there away to retrieve the senders addresses of a transaction from its hash, using cli?
Is there away to retrieve the senders addresses of a transaction in cli commands, given the transaction hash? How do APIs (like blockfrost) get this data?
I know db-sync stores the data, but how does db-sync know in the first place about these details that are not directly retrievable from the ledger?

You would have to use cardano-db-sync - it is a service that stores ledger (chain) data into a more easy-to-work-with SQL structure. Otherwise, one would have to parse raw chain data (incredibly inefficient), which is why a framework like db-sync is so useful.
All the API's like Blockfrost or Cardanoscan use db-sync at backend to provide their services.

I am familiar with db-sync and APIs that provide services to provide users with more details than can be found in the ledger. But how does db-sync know this in the first place? since only the utxo hashes are available at the input of a transaction. I am currently using blockfrost, but with congestion it is my weak point and there are times it does not respond, which miss up my wor

With Cardano-cli you can only query your UtxOs to get the corresponding tx hash. Unfortunately, there is nothing to go deeper and get additional information.
I dont' understand what you mean by "are not directly retrievable from the ledger", but yes, db-sync has access to this information.

The purpose of Cardano DB Sync is to follow the Cardano chain and take
information from the chain and an internally maintained copy of ledger
state. Data is then extracted from the chain and inserted into a
PostgreSQL database. SQL queries can then be written directly against
the database schema or as queries embedded in any language with
libraries for interacting with an SQL database.

However, you need some non negligible resource to run db-sync. What Blockfrost does is "just" to wrap a web API around the DB in order for everyone to get an easy access to it. Blockfrost is the easiest way to retrieve your sender address.

I am familiar with db-sync and APIs that provide services to provide users with more details than can be found in the ledger. But how does db-sync know this in the first place? since only the utxo hashes are available at the input of a transaction. I am currently using blockfrost, but with congestion it is my weak point and there are times it does not respond, which miss up my work

I don't know exactly how, but a transaction references the Utxo it consumes. This reference is made up of a Tx Hash and UtxO index (from a previous transaction). But, the referenced UtxO belongs to some address, so, somehow, you can get the sender.

like the other colleagues mentioned it is not possible from cli.
what i would recommend is to

create account in https://blockfrost.io/
take a Project ID

and then "curl" info from the DB using the command below
curl -H 'project_id: Insert_here_youProject_ID'
https://cardano-mainnet.blockfrost.io/api/v0/txs/${tx_hash}/utxos
| jq '.inputs' | jq '.[0]' | jq '.address' | sed 's/^.//;s/.$//'
TX_Hash, you can receive it from
cardano-cli query utxo --address $myAddr --mainnet

I am familiar with db-sync and APIs that provide services to provide users with more details than can be found in the ledger. But how does db-sync know this in the first place? since only the utxo hashes are available at the input of a transaction. I am currently using blockfrost, but with congestion it is my weak point and there are times it does not respond, which miss up my work

i dont know if that here is clear for you. github.com/input-output-hk/cardano-db-sync - The purpose of Cardano DB Sync is to follow the Cardano chain and take information from the chain and an internally maintained copy of ledger state. Data is then extracted from the chain and inserted into a PostgreSQL database. SQL queries can then be written directly against the database schema or as queries embedded in any language with libraries for interacting with an SQL database. - i am learning also, and i read so many related infos here –

Yeah I understand, I have been developing on Cardano for awhile now. I like most of the concepts but the fact that you cant get info of input and output addresses is frustrating. It would be much more robust for the ledger to include these info. I know main reason is size and all, but still. Anyways thank you a lot


text:
In a docker Cardano node where are address key files created?
I'm running a dockerized Cardano node and I'm trying to generate keys for a new address with the cardano-cli using the command:
cardano-cli address key-gen --verification-key-file 01.vkey --signing-key-file 01.skey

Docker command to run the node:
docker run -e NETWORK=mainnet -v cardano-node-ipc:/ipc -v cardano-node-data:/data inputoutput/cardano-node

Docker command to run the cardano-cli call:
docker run -it --entrypoint cardano-cli -e NETWORK=testnet -e CARDANO_NODE_SOCKET_PATH=/ipc/node.socket -v cardano-node-ipc:/ipc inputoutput/cardano-node

Where are those files created?

Instead of calling the cardano-cli with docker run, I just got into the pod running the node in a bash shell and ran the cardano-cli from there, the files are created in the folder the bash shell runs the command.


text:
Tutorials to integrate Nami to your website
is there a dummy guide on Nami wallet integration into websites?
I have found nami-wallet-api lib by Felippo001. But I can't find any walkthroughs. Specially that I am not familiar with webpack.

Maybe this video is helpful? https://www.youtube.com/watch?v=iBfHgIuvHgY
It is a tutorial on how to integrate Nami using this template: https://github.com/cheffNFT/namiwallettemplate

I watched it. I want hands down on actual server integration. I myself dont know webpack so I am missing major part that is not mentioned in the video. Thanks anyways

this video is private

you can try using the cardano-wallet-interface to handle all the various wallets and not only nami, there are no videos but the provided documentation should be enough.
In any case, consider reading the CIP-0030 if you want to understand how wallet extensions are working.


text:
Running submit-api on mac for Nami to connect to Daedalus?
I found windows-based instructions for this, and looking to do it on mac. Problem is I know nothing about Windows Powershell.
Could someone help translate the following, suitable for mac terminal?
$ENV:CARDANO_NODE_SOCKET_PATH = (Get-ChildItem \\.\pipe\ | Where-Object {$_.name -like "cardano-node*"}).FullName

Run this to check to see if the command worked.
$ENV:CARDANO_NODE_SOCKET_PATH

You should see something like
\.\pipe\cardano-node-mainnet.12768.1

Now execute the next command to start the Cardano Submit API
.\cardano-submit-api.exe --mainnet --socket-path $ENV:CARDANO_NODE_SOCKET_PATH --config .\tx-submit-mainnet-config.yaml --port 8090

You should see
Running server on 127.0.0.1:8090

To clarify from the above, if I export an env var, what should 'something here' be on mac/linux?
export CARDANO_NODE_SOCKET_PATH='something here'
As for the command to execute, I think it should just be:
.\cardano-submit-api --mainnet --socketpath CARDANO_NODE_SOCKET_PATH --config tx-submit-mainnet-config.yaml --port 8090
Only bit I'm stuck with is what the actual env var is or how it is being set above.

TD;DR
Full instructions for Mac/linux are here: https://pastebin.com/MbjkvgL5
Regarding permissions running unverified applications: https://www.lifewire.com/fix-developer-cannot-be-verified-error-5183898

Long version
Found it going to this video:
https://www.youtube.com/watch?v=sfLhNEtiktA
Under one of the comments was a link to this twitter post:
https://twitter.com/877PSBYTE6/status/1485438232254812163
Which referenced this manual:
https://pastebin.com/MbjkvgL5
Important note
I had to allow about 7-10 lib files which were not allowed by the mac’s default security policy.
Did this by opening “Security & Privacy” in “System Preferences”.
This helped to go through the security: https://www.lifewire.com/fix-developer-cannot-be-verified-error-5183898


text:
Lesson 3 - unsure how "sigs" is created or where txInfoSignatories comes from or how it works
Spoiler Alert!
The solution for lesson 3 includes the following:

{-# INLINABLE mkValidator #-}
-- This should validate if either beneficiary1 has signed the transaction and the current slot is before or at the deadline
-- or if beneficiary2 has signed the transaction and the deadline has passed.
mkValidator :: VestingDatum -> () -> ScriptContext -> Bool
mkValidator dat () ctx
    | (unPaymentPubKeyHash (beneficiary1 dat) `elem` sigs) && (to       (deadline dat) `contains` range) = True
    | (unPaymentPubKeyHash (beneficiary2 dat) `elem` sigs) && (from (1 + deadline dat) `contains` range) = True
    | otherwise = False
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx
sigs :: [PubKeyHash]
sigs = txInfoSignatories info

range :: POSIXTimeRange
range = txInfoValidRange info

It appears that " txInfoSignatories " is a function (functor?) that analyzes " info " which itself is drawn from the script context, but I am at a loss as to where the " txInfoSignatories " code actually comes from. Is there a way to analyze which imported module it is attached to? Is there a way to analyze its code in order to understand what it does? Much of what I am seeing in Haskell seems so opaque, with new features simply appearing and magically doing something, but I am lost as to how I could have analyzed the code/modules/options and come up with this solution on my own.
For the record, here is what I created before I looked at the solution. It compiles without error, but does not behave in the playground as intended.

{-# INLINABLE mkValidator #-}
-- This should validate if either beneficiary1 has signed the transaction and the current slot is before or at the deadline
-- or if beneficiary2 has signed the transaction and the deadline has passed.
mkValidator :: VestingDatum -> () -> ScriptContext -> Bool
-- mkValidator _ _ _ = False -- FIX ME!
mkValidator dat () ctx =
     ( traceIfFalse "beneficiary 1 - signature missing" signedByBeneficiary1
    && traceIfFalse "deadline 1 has passed" deadline1Reached )
    || (traceIfFalse "beneficiary 2 - signature missing" signedByBeneficiary2
    && traceIfFalse "deadline 2 not reached" deadline2Reached )
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx
signedByBeneficiary1 :: Bool
signedByBeneficiary1 = txSignedBy info $ unPaymentPubKeyHash $ beneficiary1 dat

signedByBeneficiary2 :: Bool
signedByBeneficiary2 = txSignedBy info $ unPaymentPubKeyHash $ beneficiary2 dat

deadline1Reached :: Bool
deadline1Reached = contains (to $ deadline dat) $ txInfoValidRange info
deadline2Reached :: Bool
deadline2Reached = contains (from $ deadline dat) $ txInfoValidRange info

Any Haskell wisdom is much appreciated. I feel like this is more a Haskell knowledge deficit than anything else.

TxInfo is a Record type and one of the fields of the TxInfo-record is txInfoSignatories. The fields in the records work as "getters". You may refer e.g. to learnyouhaskell-records for an example.
The whole definition for TxInfo is here:

It is also completely fine to use the txSignedBy helper function as you have done to check whether the given hash is one of the signatories.

Your answer simply moves my question from  txInfoSignatories   to TxInfo. Where does TxInfo come from? It is not defined in the code for Solution1.hs. If I (in the repl) do ":i TxInfo" or ":t TxInfo" or simply "TxInfo" I get a "variable not in scope" error message. Where does that definition (a very nice and helpful definition to be sure) for TxInfo come from, and how could I have found it on my own?

It is one of the fields of the ScriptContext ctx, see "info :: TxInfo
info = scriptContextTxInfo ctx". In repl, do "import Ledger" then ":i TxInfo" and ":i ScriptContext" should work.

Thank you @MihaiCodescu, I see that now. Is there a way to quickly trace/track these nested types/data/functions/records or is a tedious hunting mission necessary when reverse engineering? BTW, I discovered the :browse command in the repl, which does help.

@XiTouch It also helps to remember that the validators in the extended UTXO model "see" the whole transaction they are about to validate. In other words: the context where the script is run contains full transaction info. Thus, it is not a big surprise to find TxInfo within ScriptContext.

I spent a day creating this animation to visualize the connections and sources of each part. Hope this helps anyone else.   https://www.youtube.com/watch?v=ZLURnogC_kU

Impressive animation!


text:
How to move Cardano Node stake pool to new IP address?
We are changing hosting services, and want to move the BP and Relay nodes to new machines.  They are all set up and synced with Mainnet, but when we re-run the 05c SPOS script it complains there are no funds on the wallet address.  We shouldn't have to pay the registration fee again.  All we want to do is update the IP addresses of the Relay Nodes on the network.  All of the keys are moved over to the new servers, and the topology file is updated.
We did some searches and found some articles, but nothing that was helpful.
The command we ran is from the keys folder:
05c_regStakepoolCert.sh myPool myWallet REREG
It says:
No funds on the Source Address!

You don't have to pay the 500 ADA registration fee, but you do have to pay the regular transaction fee since updating a pool registration must be submitted via a regular transaction.
If all you are doing in this transaction is submitting a pool cert, it should cost you somewhere around 200,000 Lovelaces (0.2 ADA). Just make sure the new pool cert has the new IP addresses.
Pro tip: if you purchase a domain name (say, mypool-rocks.com), you can actually avoid having to resubmit pool certs every time you change IPs. Instead, you can point your pool certs at a DNS address (i.e. relay1.mypool-rocks.com and relay2.mypool-rocks.com), and use a DNS resolver like Google to point your IPs at those respective sub-domains. This works great for moving IPs around, just make sure that your security is tight with whatever DNS resolver you choose.

Aha, that makes sense.  FYI, I added 1A to my wallet, and that was insufficient.  It then proceeded to list the amount needed, which adds up to 1196433 Lovelaces:  196433 for TxIn/TxOut, 196433 for re-registration, and 803567 for being returned to payment address...  Makes sense we have to have funds to pay the tx fee.

I don't think the second 196433 fee is for re-registration. As far as I am aware there is no "re-registration" fee. However, there is a minimum UTXO value of 1 ADA (meaning every UTXO on Cardano must have at least 1 ADA or 1000000 Lovelaces in it - which is exactly what should be sent back to you as change.

I will say I had 1A in the wallet and it said not enough funds, but when I had 2A it worked.  Thanks again!


text:
Create Delegation Certificate Transaction
When building the Create Delegation Certificate Transaction with the cardano-cli, do we need to use all the Utxos of a wallet/base.address? or we can just use one Utxo only as long as it covers the fee?
from coincashewnut
cardano-cli transaction build-raw \
    ${tx_in} \ #all the Utxos in an address here? or just one is enough?
    --tx-out $(cat payment.addr)+${txOut} \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee ${fee} \
    --certificate-file deleg.cert \
    --out-file tx.raw

If the only purpose of this transaction is to submit a delegation certificate, then the only costs will be the fee for submitting it. Any UTXO will suffice of the --tx-in, so long as the TX is then signed by the appropriate payment (for the fee) and staking keys (for the delegation). Once submitted, any and all UTXO's residing at the address(es) in the delegation certificate will automatically be delegated to whatever pool you've chosen - no need to manually delegate individual UTXOs.
Fun fact: you can even pay the fee for such a transaction from an address/wallet completely unassociated with the address you are delegating, so long as the Tx contains the appropriate payment signatures.


text:
Can't start Cardano Node
I have a node that I had run a few months ago and then stopped using for a long time, a few days ago I decided to start the node again, the node started syncing with no issues but midway trough it all the Terminal app (I'm using a Mac) stopped responding, so after seeing it for a while like that (and after all the other apps stopped responding too) I decided to turn off the computer thinking I could start the process again, but then today I got this:
[yeshco:cardano.node.ChainDB:Info:5] [2022-02-01 00:39:49.68 UTC] Opened imm db with immutable tip at 9ff948e88999a5de60fa92694c55e764ef4b3985dbcf1c88d7442fdcca576ed4 at slot 40555639 and chunk 1877

Shutting down..
FsError {fsErrorType = FsResourceDoesNotExist, fsErrorPath = /Volumes/2T WD NEGRO/Crypto/Cardano/db/volatile/blocks-6266.dat, fsErrorString = "No such file or directory", fsErrorNo = Just (Errno 2), fsErrorStack = CallStack (from HasCallStack):
  prettyCallStack, called at src/Ouroboros/Consensus/Storage/FS/API/Types.hs:297:23 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.API.Types
  ioToFsError, called at src/Ouroboros/Consensus/Storage/FS/IO.hs:88:41 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.IO
  handleError, called at src/Ouroboros/Consensus/Storage/FS/IO.hs:84:23 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.IO
  rethrowFsError, called at src/Ouroboros/Consensus/Storage/FS/IO.hs:37:21 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.IO
  hOpen, called at src/Ouroboros/Consensus/Storage/FS/API.hs:152:43 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.API
  withFile, called at src/Ouroboros/Consensus/Util/CBOR.hs:227:7 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Util.CBOR
  withStreamIncrementalOffsets, called at src/Ouroboros/Consensus/Storage/VolatileDB/Impl/Parser.hs:67:5 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.VolatileDB.Impl.Parser, fsLimitation = False}

cardano-node: FsResourceDoesNotExist for /Volumes/2T WD NEGRO/Crypto/Cardano/db/volatile/blocks-6266.dat: No such file or directory at CallStack (from HasCallStack):
  prettyCallStack, called at src/Ouroboros/Consensus/Storage/FS/API/Types.hs:297:23 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.API.Types
  ioToFsError, called at src/Ouroboros/Consensus/Storage/FS/IO.hs:88:41 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.IO
  handleError, called at src/Ouroboros/Consensus/Storage/FS/IO.hs:84:23 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.IO
  rethrowFsError, called at src/Ouroboros/Consensus/Storage/FS/IO.hs:37:21 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.IO
  hOpen, called at src/Ouroboros/Consensus/Storage/FS/API.hs:152:43 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.FS.API
  withFile, called at src/Ouroboros/Consensus/Util/CBOR.hs:227:7 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Util.CBOR
  withStreamIncrementalOffsets, called at src/Ouroboros/Consensus/Storage/VolatileDB/Impl/Parser.hs:67:5 in rbrs-cnsnss-0.1.0.0-0b62aa4c:Ouroboros.Consensus.Storage.VolatileDB.Impl.Parser

And I can't sync it.
I would be very thankful if somebody can help!

The first thing I'd check is if your disk is full. A lot of unix programs will error failing to create a file because there's no disk space and report it as no such file or directory...
The next thing would be that the user running node has permission to write to the state directories. If you ran it as a service user in the past and now are running it as your normal user (or if you did something bad like running node with sudo), fixing permissions with chown might do the trick.
Next thing I'd do is update the node to latest and remove only the ledger and volatile directories. This will force a ledger rebuild that could take a while, so just be patient. While it's doing the rebuild if it detects any corruption in immutable the node should truncate to that point and start syncing. Leaving immutable will significantly reduce sync time if there's no corruption early in the chain data.

Thanks!, I was going to ask this before but how do you update the node, I tried to clone the repository again on a copy I made but my node is still 1.29.0?

It looks like the on disk storage is corrupted. If you also have not run it in a couple of months you probably need to upgrade your node version.
Upgrading the software may help with the other problem, otherwise delete all the storage and resync the node.


text:
What are the benefits of using Plutarch?
Is Plutarch a good replacement for Plutus Tx?

https://github.com/Plutonomicon/plutarch/blob/master/docs/GUIDE.md

This is covered pretty nicely in the project README. https://github.com/Plutonomicon/plutarch#why-plutarch
In short, Plutus Tx attempts to replicate Haskell-like lazy semantics inside of Untyped Plutus Core, which is strict by default.  Untyped Plutus Core is the compilation target of Plutus which is actually run onchain.
As a result, the plutus interpreter injects a lot of unnecessary code, and makes it very difficult to reason about the time/space complexity of the code that you write.
This is compounded by very low limits for plutus script size, memory, and cpu usage which prevents scripts from running onchain if they are exceeded. As a result, Plutus Tx is only viable for very simple plutus contracts.
Plutarch is 300%+ more efficient on all three of these limits, allowing the same logic to be expressed with less than 1/4 of the resource usage.  it is written using haskell, yet makes no attempt to maintain Haskell's lazy semantics, instead i

It looks like your answer got cut short.


text:
(ppp Class 3). Parameterized contracts. What's the benefit for given example? and more use cases
In the auction example (Class 2), the endpoint for Grab just only requires the Wallet as parameter. The wallet and the validator will retrieve all UTxOs for that wallet that are available (past their deadline).
In class 3 example, now there cannot be a grabAll endpoint because the deadline is a parameter, so I did not see a benefit in this approach, please enlighten me.
Can you please provide more examples where this is actually useful?

The benefit is limiting scope of addresses to scan to the beneficiary (and deadline). The reason you'd want to do this is say 1 million people are using this contract. Someone redeeming would need to filter through millions of utxos with the first approach but in the second only has to look at utxos associated with them. The homework switching this to 50/50 approach takes the best of both worlds. All utxos found are for the beneficiary but then you can filter on the datum for all transactions that are vested to redeem.

In class 3 example, now there cannot be a grabAll endpoint because the
deadline is a parameter, so I did not see a benefit in this approach,
please enlighten me.

Can you please provide more examples where this is actually useful?

As you said, the deadline is the parameter and as I understand it one can actually 'grabAll' as long as the deadline parameter of that particular grab is after all the deadlines specified by the gifts.
I think the example is useful in cases if you want to stagger the redemption of the gifts by beneficiaries into different deadlines or slots or specific times.

Here is a real example on Cardano mainnet and how one of the decentralized exchanges uses it. https://twitter.com/adax_pro/status/1488524779686608903


text:
Why is my cardano-node not working anymore?
My cardano-node is failing, and I'm not sure how to debug or fix it:
NodeToClientV_10    HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* Nil)
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:44:25.51 UTC] Opened imm db with immutable tip at 1ae2812fe7d76761e9d6f3733fcb8ee9c468040152ae8ad7f58d0527703e443f at slot 51967021 and chunk 2405
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:44:33.05 UTC] Opened vol db
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:45:25.71 UTC] Replaying ledger from snapshot DiskSnapshot {dsNumber = 51964788, dsSuffix = Nothing} at 8f134f487815d32650107fb04609ad1a7fbab47daaa55d27e6a4b4c3588c705f at slot 51964788
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:45:26.22 UTC] Replayed block: slot SlotNo 51964807 of At (SlotNo 51967021)
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:45:37.13 UTC] block replay progress (%) = 100.0
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:45:38.79 UTC] before next, messages elided = 51964826
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:45:38.79 UTC] Replayed block: slot SlotNo 51967021 of At (SlotNo 51967021)
[vvv-:cardano.node.ChainDB:Info:5] [2022-02-01 02:45:38.79 UTC] Opened lgr db
Killed

Yes, it looks like it was out of memory: [102938.126815] Out of memory: Killed process 28026 (cardano-node) total-vm:1074350476kB, anon-rss:7832444kB, file-rss:2160kB, shmem-rss:0kB, UID:1000 pgtables:15576kB oom_score_adj:0
[102938.346596] oom_reaper: reaped process 28026 (cardano-node), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

Killed probably means it was killed by the OOM (Out Of Memory) killer. If it was OOM killed, there will be a message in the dmesg output.
Running the node requires at least 8GB and you should have 4G of swap as well.

journalctl -k around that time stamp is what you'd run to see kernel logs of what was killed.


text:
Need help getting Cardano-node installed and running - trying to follow Lars example Week03 - Cohort03
I'm trying to replicate what Lars was demonstrating at the start of the week03 testnet setup video https://www.youtube.com/watch?v=ABtffZPoUqU&list=PLNEK_Ejlx3x2zxcfoVGARFExzOHwXFCCL&index=6 (time 0:49-1:05), but after picking the hydra binaries, he is magically in a nix-shell and able to do cardano-node --version.
My question is what steps were done after downloading the binaries in order to be able from run cardano-node from a nix-shell?  I'm new to nix so not always sure what has to be done to get things working.
I've tried just running the nix-shell, which spent quite a while updating dependencies, but in the end cardano-node didn't exist - ie running cardano-node --version in shell did nothing, neither did 'which cardano-node'.
Can someone please provide specific steps to get cardano-node running in the nix-shell.  Thanks

How are you running your node? Did you install the binaries? If so which one for which OS? Or are you using a docker image?

easiest way to get a testnet node running: nix run github:input-output-hk/cardano-node#testnet/node --no-write-lock-file

Once you have nix-shell and downloaded the repository, you run it:
cabal build cardano-node cardano-cli
(it takes about 30 minutes)
and then:
cardano-node run.
You open the second console, restart nix-shell and can play with cardano-cli.

I think Lars skipped some steps because they are not necessarily relevant to Plutus. It's more general and will depend on your operating system. Assuming you're running Linux like Lars, follow the steps below. Note that you can be in a Nix shell for this, but you don't have to be. This is just downloading a binary and putting it on your PATH.
In the video, Lars cuts while on this page:
https://hydra.iohk.io/build/9941098#tabs-constituents
From there, you should click on cardano-node-linux (job #9941151)
Click on cardano-node-1.33.0-linux.tar.gz binary distribution to download the tarball
Make a permanent directory in which to store the binaries
mkdir ~/cardano-node

Extract the tarball contents into the directory. Note that your downloaded tarball may be in a different directory depending on how your system is configured.
tar -xf ~/Downloads/cardano-node-1.33.0-linux.tar.gz -C ~/cardano-node

At this point, you can execute cardano-node
cd ~/cardano-node
cardano-node --version

But you probably want to be able to run it from anywhere, not just in that one directory.
To do that, make sure the ~/cardano-node directory is always part of your PATH when you log in by editing ~/.bashrc and adding the following line
export PATH="$HOME/cardano-node:$PATH"

While you're editing .bashrc, save yourself some time later by adding this environment variable, too. You'll need it later. Note: Change the path if your plutus-pioneer-program directory is somewhere else.
export CARDANO_NODE_SOCKET_PATH="$HOME/plutus-pioneer-program/code/week03/testnet/node.socket"

Finally, source .bashrc to make sure the PATH and that environment variable are set in your current session
source ~/.bashrc

At this point, you'll be at the same point Lars is in the video.


text:
Homework2.hs: checking that the beneficiary signed the transaction
Spoiler, so don't look if you haven't done the homework yet.
In the solution file Solution2.hs we have
checkSig :: Bool
checkSig = unPaymentPubKeyHash pkh `elem` txInfoSignatories info

while in the file from the lecture Vesting.hs we have the same check implemented as
signedByBeneficiary :: Bool
signedByBeneficiary = txSignedBy info $ unPaymentPubKeyHash $ beneficiary dat

I get the same behavior in the playground with the two implementations in Solution2.hs, and moreover looking at the implementation of txSignedBy
{-# INLINABLE txSignedBy #-}
-- | Check if a transaction was signed by the given public key.
txSignedBy :: TxInfo -> PubKeyHash -> Bool
txSignedBy TxInfo{txInfoSignatories} k = case find ((==) k) txInfoSignatories of
    Just _  -> True
    Nothing -> False

I don't see a difference. Maybe my tests in the playground aren't good enough, but is there an example of different behavior?

They are the same. I'd say the signedByBeneficiary way is more idiomatic.


text:
Smart contract configuration
Is it possible to write smart contract validator that would check:

if UTXO that contains service price information was included so only script can read what is actual price of the service.
UTXO with service price information could be only updated by given public key hash
validator would validate if user paid the service price

This is certainly possible! With the new Vasil HF and the new Babbage era, this will be easier than before. Here is how you can do it using reference inputs.
Mint a NFT with say policy ID and token name abc.ServicePrice. Keep this token at an address that you control, but additionally add a datum to it that contains the service price information. A little disclaimer here, spending this output will destroy the data, so keep that in mind. You can always update the service price by spending it and sending it to the same address with a new datum. Another, more involved option is to keep this NFT + datum at a script address that could mandate more constraints. Possible logical constraints could be that you want to make sure that this NFT never moves to another address. But since you control the price, this is not a necessity.
Now you create a script that provides the service and needs the price. In it, you mandate that the script only validates if the token abc.ServicePrice is in the transaction as a reference input. Given that this holds, you can retrieve the datum of that reference input and thus the service price. Also, make the script fail if the service price is not paid to you.
Cool construction of a proxy contract!


text:
Why is my cardano-node not doing anything?
I've doubled my RAM to 16GB to be safe, and added a 4GB swap file as well, but when starting the node, it does this and then ... nothing else:
node-to-node versions:
NodeToNodeV_6   HardForkNodeToNodeEnabled HardForkSpecificNodeToNodeVersion1 (EraNodeToNodeEnabled ByronNodeToNodeVersion2 :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1 :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1 :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1 :* EraNodeToNodeDisabled :* Nil)
NodeToNodeV_7   HardForkNodeToNodeEnabled HardForkSpecificNodeToNodeVersion1 (EraNodeToNodeEnabled ByronNodeToNodeVersion2 :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1 :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1 :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1 :* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1 :* Nil)
node-to-client versions:
NodeToClientV_1 HardForkNodeToClientDisabled ByronNodeToClientVersion1
NodeToClientV_2 HardForkNodeToClientDisabled ByronNodeToClientVersion1
NodeToClientV_3 HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion1 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion1 :* EraNodeToClientDisabled :* EraNodeToClientDisabled :* EraNodeToClientDisabled :* Nil)
NodeToClientV_4 HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion2 :* EraNodeToClientDisabled :* EraNodeToClientDisabled :* EraNodeToClientDisabled :* Nil)
NodeToClientV_5 HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion2 :* EraNodeToClientEnabled ShelleyNodeToClientVersion2 :* EraNodeToClientDisabled :* EraNodeToClientDisabled :* Nil)
NodeToClientV_6 HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion2 :* EraNodeToClientEnabled ShelleyNodeToClientVersion2 :* EraNodeToClientEnabled ShelleyNodeToClientVersion2 :* EraNodeToClientDisabled :* Nil)
NodeToClientV_7 HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion3 :* EraNodeToClientEnabled ShelleyNodeToClientVersion3 :* EraNodeToClientEnabled ShelleyNodeToClientVersion3 :* EraNodeToClientDisabled :* Nil)
NodeToClientV_8 HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion3 :* EraNodeToClientEnabled ShelleyNodeToClientVersion3 :* EraNodeToClientEnabled ShelleyNodeToClientVersion3 :* EraNodeToClientDisabled :* Nil)
NodeToClientV_9 HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* Nil)
NodeToClientV_10    HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion2 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* EraNodeToClientEnabled ShelleyNodeToClientVersion4 :* Nil)

When I ran free -m I get:
              total        used        free      shared  buff/cache   available
Mem:          16008         195        1843           0       13968       15516
Swap:          4095           0        4095

Not sure if the database is corrupt and needs to be rebuilt, or what is going on. Is there a way to get a verbose error?

Check your configuration file. This looks like your logs are going to a separate file. I've seen this with tools like cntools where they redirect all logging out of stdout into separate log files.


text:
How to move Stake Pool Node to new IP address?
I believe we are missing something.  Earlier I asked a question on how to reregister the stake pool from the new hosts.  However, apparently I had not asked the entire question - which is, how do you go about moving the node?  As in, what are the steps?  The documentation on this has been pretty hard to find.  What I did was to set up the node on the new hosts, transfer the keys, and then re-register the stake pool using the SPOS scripts.  But, the IP addresses of the relays aren't being updated on the net - so how do I update the topology file?  I found a Topology Updater script, but I can't just download and run it - it appears that a set of very specific prerequisites needs to be set up, and I don't see where that is documented.  So how exactly do I take my updated topology file and submit it to the network to supersede the old one?

In general, there's nothing in the protocol itself that cares where your node made blocks, but here's some best practices on what you would do:

Create your new relays in the new hosting center
Setup bi-directional connections between your old/new relays in your topology files
Notify any pools you're pairing with of your new relays so they can add them to their topology files as well
Re-register the new relays for your pool so IOHK and other pools getting information from db-sync to generate their topology files can find your relays
Sync a new "relay" against your new relays in your new hosting center. This will eventually become your block producing node
Identify a time when your node will not produce a block that's a good maintenance window (ideally a few hours in case anything goes wrong)
cleanly stop both the old block producing node and the new one (that's currently a relay) with a SIGINT signal so the database is cleanly shutdown.
(optional but good practice) generate a new KES key an opcert
restart your new block producing node with the VRF skey and new KES/opcert.
Ensure your relays have adequate incoming relay connections from outside prior to shutting down your old relays.
remove old relays from your new relay topology and restart them

This to me sounds like a good, comprehensive set of steps.  Forgive my ignorance as a first-time SPO, maybe I could confirm details of some of the steps.  2) Bi-directional connections meaning what, I add each of the old/new relays in each of the relay topology files?  4) Re-register, meaning run SPOS 05c script?  Or is there a specific cardano-cli command or such?  10) Adequate relay conxs - how do I do this, is this a cardano-cli query?

First thing: you can re-register the stake pool from any host in the world. You don't have to do it from one of the stake pool nodes.
Second thing: the only keys you need on the block producer node are: kes.skey, vrf.skey and the operational certificate (node.cert or oper.cert, depending on what guide you were using). It is not advised to have the payment keys on a server connected to the Internet. Maybe it is a requirement for the scripts you are using, but I would not do that.
If the new relays are in sync, you should install the topology updater script. You have some requirements to install, but you can use the documentation.
https://cardano-community.github.io/guild-operators/basics/#pre-requisites
Once you are running the topology updated script on the new relays and you have incoming connections, you can re-register the stake pool with the new relays. I assume you already have the new block producer connected to the new relays (both directions connections between relays and block producer). But you should not run both block producers in the same time, if you have blocks scheduled. You can also connect the new block producer to both old relays and new relays, and stop the old block producer even before updating the stake pool registration certification.

When I run the prereqs, don't forget I have an already-installed, running node.  I enter the path to the install folder, and it says I have to give it an empty path.  I don't know what it is going to do, and the documentation isn't clear on my question.  Do I create an empty folder and run the script to that?

I think the prereqs.sh will only install some packages that you need to run the scripts. You may already have them. You can try to run topology updater without running the prereqs.sh, but if it is not working correctly, take a look to the script to see what it is doing and maybe you can see what's missing. I know for sure I have issues with gLiveView.sh for example because I did not have jq and bc packages installed.

I definitely have jq, not sure about bc - jq is used by SPOS... I also had issues with gLiveView hanging the node, back on 1.29.0 when I got started with cnode.  I think I will try the topologyUpdater script, run the prereqs to an empty folder and see what happens.  Take a snapshot of the host first.

OK, I configured and ran the topologyUpdate script, set it up to run every hour.  However, when I looked at the Cardano centralized topology file (https://explorer.mainnet.cardano.org/relays/topology.json), our relays are not there after 24 hours.  How do we get our relays on that list?

i think you are missing something and you make more complicated your question.
every pool needs only one BP (second one for redudancy, but never run 2 BPs at the same time) and you also need Relays, more than 2 for the redudancy.
the BP (block producer) need his settings and only connections to your relays. no other connection to any other Relay in the network. that is for your security. this node, the BP, need 3 files so that runs as BP. that is the only different to the Relays.
which means now,
the IPs which are known and used in public, are the IPs from your relays.
now to your point.
if you want to install new node, what ever it is (either BP or Relay), you need a normal installation as it was for any other old Node.
if you want to use this new Node a Relay,

prepare it as relay,
connect it with your BP only
register the pool with your new public IPs

if you notice here, in importan key_step is to register again the pool with your new IPs (from Relays)
in case now you want new installation for your BP,
then please just install new node, connect it with your Relays, and add the proper files to run as BP.
please let me know, if that is what you exactly want to make it clear.
for any further support, let us know and we are happy to assist you.
TTS17

thank you so much for your answer!  I want to make sure I understand.  When you say "register the pool with your new public IPs" I ran the SPOS registration script 05c to register the stake pool with REREG as a command line parameter, from one of the new nodes.  I believe this submitted the topology file with the new IP addresses, right?  Or, maybe more to the point - how do I update the Cardano network topology file with my new relay IP addresses?

do you use cntools? - here is a great guidance from cool operator -
https://forum.cardano.org/t/how-to-set-up-a-pool-in-a-few-minutes-and-register-using-cntools/48767/1699   -  i speak for the "STEP 8 - register the pool" -/- in your case you have to go  >> POOL >> MODIFY

to update the topology file, you need a script to run everyone ,which s called "topologyUpdater"

OK I will have a look.  I didn't download cntools, and like I said in my post, I tried the topologyUpdater.sh, but it didn't work, and I had to run the prereqs.sh, but that asked for an empty folder, so I didn't understand what it was going to do.

OK,  now it goes to be more complicated, as we open more tickets,
if you need further support, find telegram group : https://t.me/CardanoStakePoolWorkgroup - or open tickets in : https://forum.cardano.org/ -
we are huge community and happy to support you.
welcome mate

I did get topology updater to work, I found the env settings. But I dont see the new relays in https://explorer.mainnet.cardano.org/relays/topology.json  I can try Telegram, I figured StackExchange is the best method of capturing the Q&A.

if you installed properly the node, and is synched, did you modify the pool with the new public IPs of your Relays?

Yes, the new node is synced, all 3 servers up to date.  What exactly do you mean by "modify the pool with the new public IPs of your Relays"?  The mainnet-topology.json files on all the new pool node servers have the new IP addresses, and the cron job of topologyUpdater.sh should have submitted those, right?  I noticed that a week later, adapools.org still has the old relay IPs.

do you build your whole installation with cntools or manually? or another installation guide?

you have to Register the stakepool certificate but without "Generating your delegation certifcate", means you dont have to pay again the 500ADA -----i have 2 different ways, -CNTOOLs -> >> POOL >> MODIFY >>OnLine or OffLine -> then you select your Pool and give values to all parameters again, but using your new Relays IPs.  ///// the second way is the manual by commands, how it was in the past 1. Generating the stakepool certificate(cardano-cli shelley stake-pool registration-certificate) 2. Calculating the fees, 3. building the transaction, and 4.submitting it

if some / a comment / answer is useful, you can give a credit :)

Yes, absolutely I will.  Our stake pool is still not operational, and I have had some personal challenges stopping me from working on it at the moment.  I apologize for the delay.  I followed the stakepool247 guide to install, so I installed via their script, not via cntools.  This is the third stakepool I have installed, but I have never moved one before.  I am considering deregistering, get the 500 ada back, and re-registering from the new pool.  The registration I ran using SPOS scripts, and I did that from the BP.

Another idea might be to wipe the OS back to plain Ubuntu, and do a CNTOOLS install.  I have never done that before, but it can't be that much different.

if you want, find me in telegram or other chats and groups, i can help you,,
there is also amazing forum.cardano.org/
anyway, i am really happy to assist you. find me
tts17.com, or twitter : tts1710

cntools is what i use and recommend it.

it is so easy, and i can assists 101%, the point is , you need the learn and understand the folder structure.


text:
PublicKeyOutputs at Script Address vs ScriptOutputsAt Validator Hash vs valueLockedBy
Is the line
scriptOutputsAt ownHash equivalent to pubKeyOutputsAt scrptAddress?
More importantly, is (valueLockedBy (scriptContextInfoTx ctx) ownHash) just the sum of the outputs at the script address? IE is it the same as
let values = pubKeyOutputsAt scptAddress (scriptContextInfoTx ctx) in fold values

Looking at source code of scriptOutputsAt, pubKeyOutputsAt and valueLockedBy I think, that (correct me if I wrong):

One important think to note right away, is that pubKeyOutputsAt requires PubKeyHash as first argument, so pubKeyOutputsAt scptAddress ... won't type check, if script hash used as scptAddress (otherwise - naming is a bit misleading =) ). Script hash defines script address, and public key, which defines public key hash, used to derive a Cardano wallet address.
scriptOutputsAt ownHash is not equivalent to pubKeyOutputsAt pubKeyHash (note: pubKeyHashs for pubKeyOutputsAt, not scptAddress). pubKeyOutputsAt is values paid to a public key address by a pending transaction (when/if transaction succeeds). scriptOutputsAt is basically the same, but for scripts - values paid to a script address (defined by hash) by current transaction. So scriptOutputsAt ownHash will get you Value that will be paid to the current script (the script that does current validation) when transaction succeeds.
valueLockedBy uses scriptOutputsAt under the hood, applying one extra step to accumulate total Value (i.e. go from [(DatumHash, Value)] to just Value summing values from list). So it will give you total Value that will be paid to a script (and locked by that script). So valueLockedBy (scriptContextInfoTx ctx) ownHash is not the total Value of UTxOs that currently locked by the current script, but total Value of UTxOs which will be produced by this transaction and will be locked at the current script when transaction succeeds.
So, (valueLockedBy (scriptContextInfoTx ctx) ownHash) and fold $ pubKeyOutputsAt pubKeyHash (scriptContextInfoTx ctx) are not the same in principle, as former uses script hash, and latter - public key hash , giving value for different kinds of addresses.

Yes in my example scptAddress is the PubKeyHash associated with the script. Sorry if this was misleading. But essentially, in point 4 you are saying that the types of parameters differ, but they both do return the same result correct?


text:
Contract deployment in week03 is failing with "beneficiary signature missing"
When running the grab.sh script the following error occurs:
./grab.sh
Command failed: transaction build  Error: The following scripts have execution failures:
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 provided Plutus code called 'error'.
Script debugging logs: beneficiary's signature missing
PT5

Command failed: transaction submit
Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 0 (fromList [])) (Value 619499845 (fromList []))))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (BadInputsUTxO (fromList [TxInCompact (TxId {_unTxId = SafeHash "98640ff41b8ffcba0a505e5ec90365cbb36f1eec47e0e1ac0bcbbe563517632b"}) 0]))))])

Turns out I was using the wrong vesting.addr - so the gotchas here were

NEED TO "cabal repl" after updating the deploy.hs
get the correct vesting.addr and use it in the give.sh and grab.sh

The warning signs for if you've used the wrong vesting.addr is that you see a whole bunch of erroneous ones in the TxHash of the script address.  There should only be one!

I have spent a full day on this same issue! Drove me around the bend until I saw this post of yours. So thanks a million!  I don't know how to 'like' your answer in here - but huge kudos to you!
For others with the same issue, all I had to do in the repl after updating and saving the Deploy.hs was a :r to reload Deploy.hs. Major lesson learnt. Always :r before running anything. I then ran writeVestingValidator in the repl to create the vesting.plutus script file. I then, from the nix-shell, used cardano-cli query utxo --address $(cat vesting.addr) --testnet-magic 1097911063 and saw the contract address stiing there with no (zero, empty) utxos present. I then ran the give.sh and waited about a minute before I found my utxo in my contract (vesting.addr) at cardano-cli query utxo --address $(cat vesting.addr) --testnet-magic 1097911063. I copied the TxHash from this newly created utxo in at the vesting.addr to update the grab.sh file. Saved it, ran it, and FINALLY found my gift utxo sitting in my wallet 2 addr.


text:
Validator check for amount locked vs amount unlocked
A simple validator that insures that for every transaction, the amount of ADA being locked into the contract is greater than the amount being unlocked (spent) must be possible given how simple the premise is. However, it seems that there is a gap in the provided context functions.
We can easily get the amount of ADA that is locked in the transaction with:
adaLockedBy ctx ownHash
But there is no equivalent function to get the amount of ADA unlocked in the transaction.
Am I correct in thinking that currently the only way to get the total amount of ADA unlocked in the transaction is to filter script inputs for ? ex:
[txOutValue (txInInfoResolved i) | i <- txInfoInputs (scriptContextInfoTx ctx), ((==) (txOutAddress (txInInfoResolved i)) (ScrptAddress))]

Is there no valueUnlockedBy ctx ownHash?

A simple validator that insures that for every transaction, the amount of ADA being locked into the contract is greater than the amount being unlocked (spent) must be possible given how simple the premise is.

Since we use a UTxO based ledger, indeed we have to track the inputs and outputs from and to the script address. So, we define the amount that is locked/unlocked here as the difference between the value send to the script and the value spent from the script. You are correct that the former (the value send to the address) can be extracted via the function valueLockedBy defined by,
{-# INLINABLE valueLockedBy #-}
-- | Get the total value locked by the given validator in this transaction.
valueLockedBy :: TxInfo -> ValidatorHash -> Value
valueLockedBy ptx h =
    let outputs = map snd (scriptOutputsAt h ptx)
    in mconcat outputs

We see that this adds all the value found at the created outputs of the transaction that contain the ValidatorHash. Here, the scriptOutputsAt function is defined as,
{-# INLINABLE scriptOutputsAt #-}
scriptOutputsAt h p =
    let flt TxOut{txOutDatumHash=Just ds, txOutAddress=Address (ScriptCredential s) _, txOutValue} | s == h = Just (ds, txOutValue)
        flt _ = Nothing
    in mapMaybe flt (txInfoOutputs p)

Your assessment that currently there is no dedicated function for grabbing the total value of the inputs at the script address is correct. Your list comprehension seems correct. But it is not the only way, we can rewrite the above function to work on the inputs as well,
{-# INLINABLE scriptInputsAt #-}
scriptInputsAt :: ValidatorHash -> TxInfo -> [(OutputDatum, Value)]
scriptInputsAt h p =
    let flt TxInInfo{txInInfoResolved=TxOut{txOutDatum=d, txOutAddress=Address (ScriptCredential s) _, txOutValue}} | s == h = Just (d, txOutValue)
        flt _ = Nothing
    in mapMaybe flt (txInfoInputs p)

{-# INLINABLE valueUnlockedBy #-}
valueUnlockedBy :: TxInfo -> ValidatorHash -> Value
valueUnlockedBy ptx h =
    let inputs = map snd (scriptInputsAt h ptx)
    in mconcat inputs

Disclaimer: the above functions are for plutusV2 (contexts are handled differently between the two versions).

I made a PR for these functions to be included in the module https://github.com/input-output-hk/plutus/pull/4810


text:
Total Ouput in Cardano
Looking at epoch 316 details on CardanoScan (https://cardanoscan.io/epoch/316) and I see that the Total Output value has 53 billion ADA.
What does this field mean? How can it be greater than the total supply of ADA which is 45 billion?

Imagine you have $100, and it exchanges hands 10 times in 1 day. That means in a single day there was $1000 worth of value transfer, even though it was the same $100 moving the whole time. Total Epoch output is the same way. If 1M ADA is transferred 45,000 times in one epoch, thats already 45B ADA total output.
Additionally, change likely makes up the majority of the total output metric. In a UTXO system like Cardano, if I have a single UTXO with 1M ADA in it and I only want to send you 100 ADA, the whole UTXO will be used as an input and two outputs will be created - one to your address for 100 ADA and one back to me as change for 999900 ADA. So even though I only sent you 100ADA, the total output for that Tx would be 1M ADA.

Very interesting. So the value is a 'summation' of all the UTXO amounts that moved around during that epoch. I guess my thinking was around an account-based ledger.


text:
Failed to automate entering spending passphrase through 'cardano-cli'
I have been experimenting with cardano-cli in the past week. My goal is to find a way to automate sending transactions from multiple wallets in my Daedalus Mainnet.app.
After doing some research, I found: Bash script to send the transaction through cardano-cli. So I followed the instructions on GitHub, and everything was successful.
From here on out, sending transactions from multiple wallets is easy, as I only need to run the function daedalus-cli-send-tx numerous times with different arguments each time. Here's what I've got so far:
$ cat test.sh

#!/bin/bash
echo Please enter sender address:
read sender
echo $sender

daedalus-cli-send-tx wallet1 1000000 $sender #sending from wallet1 with 1ADA to sender
daedalus-cli-send-tx wallet2 1000000 $sender #sending from wallet2 with 1ADA to sender

And I also made a text file to redirect my input from test.sh to this input file:
$ cat input
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3 #sender address
8736867242 #wallet1 passphrase
1932862497 #wallet2 passphrase

But when I redirect my input, here's what I get:
$ source ~/test.sh < input

Please enter sender address:
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3
Please enter your passphrase: **********
The given encryption passphrase doesn't match the one I use to encrypt the root private key of the given wallet: 890483bc9ec5c5bfc7d612d9cad885df199c3533
Please enter your passphrase: cardano-wallet: <stdin>: hGetChar: end of file

Note that I purposely used a wrong passphrase for both transactions, but the first one actually read the input from the text file, so that isn't the problem. The problem lies in that the second transaction asked for a passphrase, yet it returned this line:
Please enter your passphrase: cardano-wallet: <stdin>: hGetChar: end of file

Even though the input textfile supplies both passphrases.
I have very little knowledge of shell script, so I am asking for help here. What is this error cardano-wallet: <stdin>: hGetChar: end of file (AFAIK it is because the input was not captured), and how do I actually automate entering my passphrase when prompt?

In shell scripting, for something like this you want to use expect and send. Here's an example of how we use it for cardano-faucet: https://github.com/input-output-hk/cardano-faucet/blob/master/nix/nixos/create-faucet-wallet/create-faucet-wallet.sh#L69-L70

Hi this is a fairly common problem in bash. It has nothing to do with Cardano-cli and can be thought of as the general problem of automating password-based authentication for applications via bash scripts.
I did something similar to this using https://stackoverflow.com/questions/67570700/how-do-i-automate-a-remote-login-with-a-bash-script
if you have any problems feel free to reach out I will happily take a look at your code and fix the bug.


text:
How to convert posixTime to slot number on Cardano Testnet
I'd like to obtain the slot number corresponding to a posixtime on Cardano Testnet.
For example, this might be useful if you need to set a slot number in cardano-cli, say building a transaction: cardano-cli transaction build --invalid-before slotNumber

I share this code snippet with the converter.
module Week03.Converter ( posixTimeToSlotTestnetConverter ) where

import Ledger          ( POSIXTime(POSIXTime), Slot(Slot) )
import Ledger.TimeSlot ( SlotConfig(SlotConfig), posixTimeToEnclosingSlot )

posixTimeToSlotTestnetConverter :: POSIXTime -> Slot
posixTimeToSlotTestnetConverter time = slotWhenSlotChangedTo1Sec + posixTimeToEnclosingSlot testnetConf time

timeWhenSlotChangedTo1Sec :: POSIXTime
timeWhenSlotChangedTo1Sec = POSIXTime 1595967616000  -- 2020/07/28 20:20:16 - epoch:74 - slot:1598400 - block:1597133

slotWhenSlotChangedTo1Sec :: Slot
slotWhenSlotChangedTo1Sec = Slot 1598400

testnetConf :: SlotConfig
testnetConf = SlotConfig 1000 timeWhenSlotChangedTo1Sec

Kudos to @Travis for timeWhenSlotChangedTo1Sec value. See:
When was the slot duration set to 1 sec on Cardano Testnet?

The accepted answer already explains how the calculation must be made and provides a sample code in Haskell; however, I will also leave here a simple snippet of code in Java, removing all the Haskell boilerplate (and can be easily ported to any other language).
/**
 * Converts from POSIX time to slot.
 *
 * @param time The POSIX time to be converted (in seconds).
 *
 * @return The matching slot.
 */
static long posixTimeToSlot(long time)
{
    long slotWhenSlotChangedTo1Sec = 1598400;
    long timeWhenSlotChangedTo1Sec = 1595967616L;

    long remainingSeconds = time - timeWhenSlotChangedTo1Sec;

    return slotWhenSlotChangedTo1Sec + remainingSeconds;
}


text:
On the off-chain code of homework 3 cohort 3
I was solving homework1.hs of week 3 of the third cohort and I think there is something wrong with the off-chain code of the solution given the validator. Namely the following, the off-chain part does not specify the end of the txInfoValidRange for the grab endpoint.
I think the current implementation sets this range to [currentTime, Inf]. For the grab of a beneficiary 2 that can grab after the deadline this poses no problem. This since the txInfoRange is contained in the range [deadline, Inf]. But if beneficiary 1 tries to grab before the endpoint the txInfoRange is not contained in the [0, Deadline] since 0 is in general not contained in txInfoRange. This makes that the current proposed solution of the validator can not construct transactions for beneficiary 1 before the deadline?
This can be solved in two ways,

Change the off-chain code to make transactions such that the grab for beneficiary 1 will not fail. How can we set this valid range to before the deadline?
Change the validator (I can not see how one could make this work if we permit the txInfoRange to be indefinite. This because it would also permit beneficiary 1 to collect the vesting funds after the deadline, what we want to avoid.)

I had a similar solution to the solution provided by the IOG acadamy (1) but both of course use the same off-chain code and thus don't work. For example if do the following

Where wallet 1 is beneficiary 1 that can claim after the deadline of slot 10 (POSIXTime = 1596059101000) and wallet 2 with PaymentPubKey 98c77c40ccc536e0d433874dae97d4a0787b10b3bca0dc2e1bdc7be0a544f0ac is beneficiary 2 which can claim the funds before the deadline of slot 10. This emulation in the above screenshot works, wallet 1 can grab the funds. But if we set it up to test if wallet 2 can grab by the following simulation it fails with the following error at slot 6
Add slot 3
Contract instance for W872cb83: (ContractLog (RawJson "made a gift of 50000000 lovelace to 98c77c40ccc536e0d433874dae97d4a0787b10b3bca0dc2e1bdc7be0a544f0ac with deadline POSIXTime {getPOSIXTime = 1596059101000}"))
Add slot 4
Add slot 5
Add slot 6
Contract instance for W7ce812d: (ReceiveEndpointCall (EndpointDescription { getEndpointDescription: "grab" }) (RawJson "{\"contents\":[{\"getEndpointDescription\":\"grab\"},{\"unEndpointValue\":[]}],\"tag\":\"ExposeEndpointResp\"}"))
Contract instance for W7ce812d: (ContractLog (RawJson "found 0 gift(s) to grab"))
Add slot 7

Is my assessment of the off-chain code correct? How can we solve this?

Someone on the IOG discord channel mentioned that this problem arose due to the PubKeyHashes of the wallets being different in this cabal build. I'll do some testing and logging of the PubKeyHashes to check this out.

I found the answer myself. Turns out it has to do with the use of the wrong PubKeyHash in the endpoints. I followed the lecture where Lars used mockWalletPaymentPubKey $ knownWallet 1 to find the PubKey. I used that instead of the hash of this. To get the hash one has to observe the type signature of mockWalletPaymentPubKey $ knownWallet 1 :: PaymentPubKey, I saw in the haddock files that this is just some type wrapper around PubKey, to undo this wrapper simply use its constructor unPaymentPubKey :: PaymentPubKey -> PubKey . Now to hash this PubKey one can use pubKeyHash :: PubKey -> PubKeyHash . So in the end we can easily generate these wallets pubKeyHash's via the following
pubKeyHash $ unPaymentPubKey $ mockWalletPaymentPubKey $ knownWallet 1
a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2

and
pubKeyHash $ unPaymentPubKey $ mockWalletPaymentPubKey $ knownWallet 2
80a4f45b56b88d1139da23bc4c3c75ec6d32943c087f250b86193ca7

Hopes this helps anyone. In conclusion there is nothing wrong with the off-chain code, it was just weird that it validated for grabbing if the deadline past which put me on the wrong track. If anyone knows why this happened, please enlighten me :)

You can also use mockWalletPaymentPubKeyHash $ knownWallet 1, which yields the same result but is shorter


text:
Issues insttaling Cardano-node
I have followed instructions to install Cardano-node and cli ( cardano-node-1.33.0-linux) based on video instructions in https://hydra.iohk.io/build/9941151.
I've got an error:
trace: haskell-nix.haskellLib.cleanGit: /run/user/1001/build-9941151/cardano-node/source does not seem to be a git repository,
assuming it is a clean checkout.
main: line 82:  2996 Killed                  nix-build "${args[@]}" "${extraArgs[@]}"

After that I checked and found release 1.32
[nix-shell:~]$ cardano-node --version
cardano-node 1.32.1 - linux-x86_64 - ghc-8.10
git rev 0000000000000000000000000000000000000000

Any idea?
Thanks
Xavier

can you show us, where is your installation? please the output of this command. which cardano-node && which cardano-cli

Try this manual: https://developers.cardano.org/docs/get-started/installing-cardano-node

Try this resource for installing the cardano-node it worked for me and it was very intuitive it goes through installations up to version 1.33.1 currently https://cardano-node-installation.stakepool247.eu/

i think you need this :

check your ghc --version and use the version in the command below (compare the path, if you have the proper version.
with this command you can find where is cardano-cli .

find ~/git/cardano-node/dist-newstyle/build -type f -name cardano-cli

here you can find where is your current 1.32.0 version

ps -Af | grep cardano-node

at the end, if you have ghc version(step 1., you will have the path where is the new version (step 2.),  then you type the next command correct

cp /home/{yourusername}/git/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.10.4/cardano-node-1.33.0/x/cardano-node/build/cardano-node/cardano-node ~/.local/bin/
i hope that helps

So I checked and 1.33 properly instaled on linux, but after running nix-shell it goes back to 1.32.
It seems like nix-shell invokes git to look for 1.32
Xavier

In addition to the excellent resource mentioned by @Floof99 there is another guide you may find useful if you intend to make use of other tools like the Signing API or DBSync:

https://cardano-community.github.io/guild-operators/Build/node-cli/ - Comprehensive guide to getting a node built with additional tools


text:
How to make a PubKeyHash into a PaymentPubKeyHash
Im reading through old Plutus code and it seems to be that you could use in the past
pubKeyHash with the mustPayToPubKey function now it asks for a PaymentPubKeyHash. How do you get around this if you want to send a value to an owners paymentPubKeyHash from a plutus script considering that there is no byte string implementation of a PaymentPubKeyHash?
I cant use PubKeyHash anymore in the mustPayToPubKey is there a way to convert this format?

you can get own PymentPubKeyHash with ownPaymentPubKeyHash inside Contract.  Or that is not your case?

no its not I had previously manually typed in a pubKeyHash as a data type to reference the owners pubKeyHash

This is a simple newtype https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger-Address.html#t:PaymentPubKey
you can import Ledger.Address and convert it with something like PaymentPubKeyHash myPubKeyHash, you can convert in the opposite direction with unPaymentPubKeyHash

thanks a ton it worked I've been trying to figure that out for days


text:
Project Catalyst Voting, did not save QR code, but have transaction ID and Pin, can I use this?
Is there a way to use any information from the project catalyst registration voting transaction ID, instead of the QR code, say if you lost the QR code?
Assume the pin is known.
The transaction ID metadata looks like the following.
{
   1: "103a3919a376ca98431c871d7f....fbceab46732e9d4a3c1e5a87995e6ed1786",
   2: "ef36ce85e2967d96db6c26.....29eb132b0df06393b29f790b26a97da90",
   3: "e1916b5b1df589d4a70e5ebde9fc71ea10.....4cab8b8a329b1625620",
   4: 47594896
}

{
   1: "f182e4faa36097d42360416b6d5136e.....a1a535ab6f822293046e5fe426dc37a68557d41da0ac08794b0820addad359299316fd3674a66bced33f95056d07"
}

No, the transaction only contains the public key, and the pin code is used to decrypt the private key from the QR code. If you don't have the QR code, you don't have the private key.

Thank you Samuel


text:
StateMachine - keep the same value for the next state
I work with the StateMachine library, and I need to transition from state to another where the stateValue of the State is exactly the same. The problem is that when I try to do the transition, I get an error that the user has insufficient funds pointing at the thread token. I presume that the stateValue of a State already includes the thread token, but it is added one more time or something like that. In summary, I have this (simplified):
{-# INLINABLE transition #-}
transition :: ContractParam -> State ContractDatum -> ContractRedeemer -> Maybe (TxConstraints Void Void, State ContractDatum)
transition cParam cState cRedeemer =
  ...

     -- This is simply what I need to transition to
     Just(mempty, State ("some updated datum") (stateValue cState))

  ...

To summarize, I need to keep the same stateValue into the next state but get insufficient funds error, so I presume I need something like (stateValue cState) - threadToken except the threadToken is not of type Value and I can not figure out, how to convert the thread token to Value or how to remove the thread token from stateValue so that I don't get the insufficient funds error.

Edit: The code snippet should work as is, but there was a bug. The newest plutus versions work.

Which version of plutus are you using? IIRC a problem like that was fixed in the last couple of months and maybe updating your dependencies to the latest plutus-apps (repository was split in two) might help already.

I am using an older plutus from time of plutus pioneer program #2. I am not sure what plutus version is that but I will try updating it.

Yes! Thank you, I updated to the latest plutus-starter project, and it is working as intended!


text:
Staking address bech32
I was trying to extract the staking address from an address and I was able to do that by using the bech32 decode, getting the last 56 bytes and encoding back again.
The question is: following this, I needed to add e1 (mainnet) or e0 (testnet) and it worked perfectly. The only thing though is that I don't know the reason. I mean, solving isn't enough, I wanted to understand why it's necessary to add those bytes as prefix.
Thank you.

The e comes from these address prefixes defined in the CDDL https://github.com/input-output-hk/cardano-ledger/blob/f2a783cf00911b7492e81dd6c7fb8a963f9ce8fe/eras/shelley/test-suite/cddl-files/shelley.cddl#L98
e equivalent in binary is 1110. The 0/1 is the part of the network ID defined in this part of the CDDL https://github.com/input-output-hk/cardano-ledger/blob/f2a783cf00911b7492e81dd6c7fb8a963f9ce8fe/eras/shelley/test-suite/cddl-files/shelley.cddl#L79
Combined they're the header that prefixes the payload defined here https://github.com/input-output-hk/cardano-ledger/blob/f2a783cf00911b7492e81dd6c7fb8a963f9ce8fe/eras/shelley/test-suite/cddl-files/shelley.cddl#L72


text:
"You may need to update to a newer hackage.nix" when trying to enter a nix-shell
I am trying to update the packages in my plutus app to the newest version of the PAB. I am by no means an expert with nix or cabal, or any haskell package managers for that matter. I can't seem to figure out how to update hackage.nix, like the error says to do.
>>>  nix-shell
trace: haskell-nix.haskellLib.cleanGit: /Users/{...} does not seem to be a git repository,
assuming it is a clean checkout.
error: Unknown index-state 2022-01-22T00:00:00Z, the latest index-state I know about is 2021-08-15T00:00:00Z.
You may need to update to a newer hackage.nix.
(use '--show-trace' to show detailed location information)

>>>  nix-shell --show-trace
trace: haskell-nix.haskellLib.cleanGit: /Users/{...} does not seem to be a git repository,
assuming it is a clean checkout.
error: Unknown index-state 2022-01-22T00:00:00Z, the latest index-state I know about is 2021-08-15T00:00:00Z. You may need to update to a newer hackage.nix.

       … while evaluating anonymous lambda

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/lib/call-cabal-project-to-nix.nix:9:1:

            8| in
            9| { name          ? src.name or null # optional name for better error messages
             | ^
           10| , src

       … from call site

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:487:36:

          486|               args = { caller = "cabalProject'"; } // args';
          487|               callProjectResults = callCabalProjectToNix args;
             |                                    ^
          488|               plan-pkgs = importAndFilterProject {

       … while evaluating anonymous lambda

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/lib/import-and-filter-project.nix:5:1:

            4| { pkgs, haskellLib }:
            5| { projectNix, sourceRepos, src }:
             | ^
            6| let

       … from call site

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:488:27:

          487|               callProjectResults = callCabalProjectToNix args;
          488|               plan-pkgs = importAndFilterProject {
             |                           ^
          489|                 inherit (callProjectResults) projectNix sourceRepos src;

       … while evaluating the attribute 'hsPkgs'

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:510:43:

          509|               project = addProjectAndPackageAttrs rec {
          510|                   inherit (pkg-set.config) hsPkgs;
             |                                           ^
          511|                   inherit pkg-set;

       … while evaluating the attribute 'hsPkgs'

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:533:15:

          532|               # Haskell packages
          533|               hsPkgs = final.lib.mapAttrs (packageName: package':
             |               ^
          534|                 if package' == null

       … while evaluating 'project'

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:836:19:

          835|         # for `cabalPackage` and `stackPackage`.
          836|         project = args: let p = project' args;
             |                   ^
          837|           in p.hsPkgs // p;

       … from call site

       at /Users/{...}/nix/pkgs/haskell/haskell.nix:12:13:

           11| let
           12|   project = haskell-nix.project {
             |             ^
           13|     # 'cleanGit' cleans a source directory based on the files known by git

       … while evaluating anonymous lambda

       at /Users/{...}/nix/pkgs/haskell/haskell.nix:4:1:

            3| ############################################################################
            4| { haskell-nix
             | ^
            5| , gitignore-nix

       … from call site

       at /Users/{...}/nix/pkgs/haskell/default.nix:24:13:

           23|   # The haskell project created by haskell-nix.cabalProject'
           24|   project = import ./haskell.nix {
             |             ^
           25|     inherit lib haskell-nix compiler-nix-name gitignore-nix libsodium-vrf;

       … while evaluating the attribute 'project.shellFor'

       at /Users/{...}/nix/pkgs/haskell/default.nix:35:10:

           34| rec {
           35|   inherit project projectPackages packages;
             |          ^
           36| }

I found the hackage.nix repository located at https://github.com/input-output-hk/hackage.nix. It seems that somehow this needs to be used to update it using nix-tools, located at https://github.com/input-output-hk/nix-tools.
I have very limited experience using nix or other haskell package managers so upgrading hackage.nix has been a blocker for me.
If someone can provide any guidance, or even better, a step by step of how to update hackage.nix, that would be greatly appreciated.
Thanks

Did you resolve this error? I met this error.

Try installing niv and running niv update hackage-nix from the root of the repository.


text:
How do I use Plutus to check that payment has been made to a native script?
If I want to check that payment has been made to a Plutus script, then I can use the function valueLockedBy txinfo vhash where vhash is the ValidatorHash of the Plutus script. Is there an analogous function to check that payment has been paid to a native script?

I'm confused by what you mean by "native script" vs "Plutus script."

This video introduces native scripts. (As you can see, they are distinct from scripts written in Plutus.)


text:
How can a native token be removed/de-registered from Cardano token registry
We have minted and registered a native token on Cardano. Now we want to burn it, because of change of policy and remove it from the registry.
After burning the tokens how should I de-register, so that it does not appear in cardanoscan any more?

One solution, i can think of is this. I would remove the entry that was created during token registration in the repository:https://github.com/cardano-foundation/cardano-token-registry from the mapping/ directory. Would this remove the entry entirely from the registry ?

No, this will not work. See my answer below.

There are instructions on how to do it within the Cardano Registry documentation
(https://developers.cardano.org/docs/native-tokens/token-registry/How-do-I-delete-my-entry-from-the-registry%3F)
These are:

Removing an entry from the registry is an ad-hoc process. If this was
allowed without verification, anyone could delete anyone's metadata.
The verification process is therefore identical to updating an entry,
with the additional step of updating the value of the 'name' and
'description' fields to 'VOID' and explicitly mentioning in the title
of your Pull Request that you would like the entry deleted.
If the Pull Request passes validation (meaning you have signed the
submission with the required key/s), the maintainers of the registry
will delete your entry.
Steps Update your entry by updating the value of the 'name' and
'description' fields to 'VOID'. Submit a pull request. Make sure to
indicate in the title of your Pull Request that you would like the
entry deleted.

Quality quoting, well done.