text:
Do I Need A Contract Monad For a Burn Wallet?
If I make a script address to be a burn address, I end up having a validator that never validates i.e. returns false all the time. Does a Smart Contract that never can validate need an instance of the contract monad to be recognised by the blockchain?
I get that I could just make a Trival instance of the contract monad and that is how I am currently doing it, but I'm curious how would the chain view this?

to help clarify, a plutus smart contract does not need a contract monad.  A contract monad is used by the plutus PAB to create a client side contract that helps prepare and submits the plutus script and required data (inputs, outputs, redeemer, datum, etc).
So back to your question regarding a plutus script that always fails. This script would be no different that any other plutus script, so it would be deployed in the same way with or without the PAB.  When ADA is sent to this script, there would be no way to spend it because the script will always fail.  The only way to spend ADA locked at a script address is to include that script as a witness to the spend, and because the script will always fail, the transaction to spend will also fail.


text:
How to get CLI access from Daedalus installation?
I have a Daedalus wallet running which is a full node so in theory, I should get all the CLI functionality from that one install, how do I access it?

Daedalus has its own cardano-node instance, so you can specify the node's socket variable and use it for cardano-cli purposes.
First, launch Daedalus, and click on Help > Daedalus Diagnostics. Under the "Core Info" section, the "Daedalus State Directory" specifies the filepath that Daedalus uses on your computer. There should be a socket variable (likely named cardano-node.socket) in this directory which you can point to in your bashrc file.
In your CLI, run: nano ~/.bashrc
Now, scroll down and add the following line to the bashrc file:
export CARDANO_NODE_SOCKET_PATH=<PATH_TO_SOCKET_IN_DAEDALUS_STATE_DIRECTORY>
Exit the bashrc file and run: source ~/.bashrc
Make sure cardano-cli is installed and is in your $PATH. You should now be able to run cardano-cli commands using Daedalus' cardano-node instance.

Is there a quick command to check if its using deadulus? I have both the repo and Deadlus installed and cant seem to figure out which one node its using (also I have verified all the steps were done exactly as you said and its a beautiful and succinct explanation thanks man).

Not sure if there is a "quick" command for this. cardano-cli will connect with whichever node's socket variable is specified in the bashrc file. You can probably use commands like ps aux or htop to query which processes are running, but if both are running simultaneously, I would just check the bashrc file with nano ~/.bashrc

thanks man i think i might turn this into a bash script

Can't seem to run cardano-cli because it says not found, how do you run it? I think it's not found because it's part of nix maybe?

Go to the Deadalus menu, and you should see a menu item that says "Open a Marlowe terminal", and a terminal will open with Marlowe Cli installed.

is the marlowe terminal diffrent from the CLI or the same thing with a different name?

source: Stack Exchange

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

sort: votes


text:
Did I update Plutus Apps Repo Wrong?
I just did a git pull updating my plutus repos from the one used in plutus pioneers 3 to the full state. I did not choose to move the HEAD to the commit mentioned and wanted to see what happens if I build the whole thing (all the other steps are as we told to do them) the interesting this is that the sample code does not compile

After Double Checking, you must specify the tag of the repo when building it via git checkout. It seems that the build from the main folder would not necessarily go to the newest possible version.
Also if you have a repo and are looking to make the right environment checkout lecture 1 of the PPP course and Dr. Larz will show you how to find the right version. Its basically in the cabal file file of the project.
Note: I was going to delete/close this post, but I thought it might become useful to future PPP students when they decide to update their envs to ill be leaving it up. Hope it helps.

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


text:
How To Get Address Transaction history into Smart Contract?
If I want the smart contract to alter functionality depending of the history of the signing address, how do I access the history from within the smart contract?

Seems like supplying on-chain history to smart contracts is a prime candidate for Oracles! Already have a large supply of trusted history with all the SPOs. :)

Turns out plutus does not support this yet (if your reading this in the future it might be out of date -> please check the timestamp).


text:
How to get transaction info of a public key hash in a plutus smart contract?
Given a PubKeyHash (pkh) how can I get the history of that pkh's transactions from within a plutus smart contract?

Plutus only validates a pending transaction given a datum, redeemer and script context, which includes tx inputs. The only way you could potentially provide that kind of information is through the datum or maybe reference inputs.

Turns out plutus does not support this yet (if your reading this in the future it might be out of date -> please check the timestamp).


text:
How to securely call Blockfrost or other API service from Smart Contract?
I just spent a few days trying to find a way to access account data from a smart contract using only plutus. Turns out IOG has yet to put that functionality in (at least that's how I understand it) but I no I can get info from the node and therefore from a service like blockfrost.
How do I get that data and have it update regularly until the contract validates?

You can't call API services directly from the smart contract, and this is not something that the "IOG has yet to put that functionality in";
the same behaviour is not possible in any other smart contract programming language for security reasons.
with that being said there are a few options you could use:
get the data from the off-chain (bad)
you could get the data from the Redeemer; so that the user is telling you the information you need.
this approach is bad because the user could send any redeemer to the script, and you have no way to check the information is true
as an example say you want to access the history of the past user transactions
the user can easily omit (or add) some transactions and you have no way to check that is true.
since ANYONE can write off-chain code to interact with the smart contract you cannot trust the input form the redeemer
Implement an Oracle
You could write a smart contract that keeps on a recognizable UTxO the data you need as Datum; then include that UTxO in the tx input of the smart contract you need the data for.
this way you access the data you need by reading any datum from the input.
now the trust is put only in the person that is able to update the oracle, and no longer in ANYONE in the world
the Plutus Pioneer Program, iteration #2, lesson 6 might help to have a better idea about Oracles

There are two points to note:

if you have access keys (such as the blockfrost project_id) you don't want to publish these.

you normally want to push the data into the contract by using the datum or pramterisation.

This means you might be well advised to put that processing on off-chain servers and figure out the input you want to send to the contract and proceed accordingly.

It is good to remember that all on-chain scripts are passive. This means that the do not compute anything, they validate only. A computer can query something, a validation process can only check whether something is done correctly.


text:
How does valuePaidTo work?
How does valuePaidTo work ? Does it give the value paid by the script to the pubkeyhash or is it the total value of the pubkeyhash for the pending transactions ?
Consider the following TxOut
txOutputs = [
   TxOut {
       txOutAddress = Address {
           addressCredential = PubKeyCredential "80a4f45b56b88d1139da23bc4c3c75ec6d32943c087f250b86193ca7",
            addressStakingCredential = Nothing
        },
        txOutValue = Value (Map [
                (,Map [("",87950820)])
            ]),
        txOutDatumHash = Nothing
    },
    TxOut {
        txOutAddress = Address {
            addressCredential =
                ScriptCredential "d909e024ee4ed177cee1ec2b93de9afcf1ca1cb082f3af67ffa6a6e0",
            addressStakingCredential = Nothing
        },
        txOutValue = Value (Map [(,Map [("",2000000)]),
            (64636464636161,Map [("T1",1)])]),
        txOutDatumHash = Just 5b3b53a06a4c34209a6278e9c89b570e9bf76e1e040cd528a7f1bf4ce3535742
    },
    TxOut {
        txOutAddress = Address {
            addressCredential = PubKeyCredential "80a4f45b56b88d1139da23bc4c3c75ec6d32943c087f250b86193ca7",
            addressStakingCredential = Nothing
        },
        txOutValue = Value (Map [(,Map [("",20000000)])]),
        txOutDatumHash = Nothing
    }
],

In this case the script is paying 20_000_000 to the pubkeyhash 80a4f45b56b88d1139da23bc4c3c75ec6d32943c087f250b86193ca7
Will valuePaidTo output 20_000_000 or 107_950_820 ?

perhaps the source code will explain it better than me.
in any case I'll try to explain it here.
valuePaidTo is defined as:
{-# INLINABLE valuePaidTo #-}
-- | Get the total value paid to a public key address by a pending transaction.
valuePaidTo :: TxInfo -> PubKeyHash -> Value
valuePaidTo ptx pkh = mconcat (pubKeyOutputsAt pkh ptx)

the comment
-- | Get the total value paid to a public key address by a pending

should already give you answer
in any case, we see that in the definition of valuePaidTo the function pubKeyOutputsAt is used
that function is defined in the same source file just some lines above
in any case only having a look at the type signature should tell us a lot:
pubKeyOutputsAt :: PubKeyHash -> TxInfo -> [Value]

from this, we know that pubKeyOutputsAt returns a list of Value ([Value]), which we can assume (and confirm by reading the source) that are all the Values going to the PublicKeyHash
and from Haskell we know that mconcat (used in valuePaidTo) is something like the following
mconcat :: Monoid a => [a] -> a

where Monoid are "things with a binary operation that returns something of the same type", and Values happen to be a valid instance of Monoid where the operation acts as a "sum"
so what valuePaidTo is doing is

take all the values going to the given PublicKeyHash
"sum" them

in your case then the output lovelaces value would be 107950820


text:
Whats the function to get the current time in Plutus?
Im using the time module in the ledger class to do some custom validation logic, but everything is done as intervals and I cant find the function that gets the current time. What is it?

each transaction on Cardano has a ttl (Time To Live) determined in the moment of transaction creation, it can't be submitted outside that interval, and even if the transaction is submited, other node would not reconize it

on cardano-cli the ttl defaults to ~2/~3 hours after the tx-body creation

and this information is reported in the ScriptContext from the Plutus.V1.Ledger.Contexts module, in particular yo need the TxInfos and from then the POSIXTimeRange you get form the txInfoValidRange function.
so starting from the ScriptContext your function would be somehting like:
getTTL :: ScritpContext -> POSIXTimeRange
getTTL = txInfoValidRange . scriptContextTxInfo

If you need to express logic valid before a specific time you should check for the upper limit of the interval to be before that timestamp
since POSIXTimeRange is just an alias for Interval POSIXTime
type POSIXTimeRange = Interval POSIXTime

you can check the Interval documentation for more
but you can get the upper limit of the interval like so
extractFiniteUpper :: Interval a -> Maybe a
extractFiniteUpper interval = case ivTo interval of
    UpperBound (Finite value) _isInclusive -> Just value
    _ -> Nothing


text:
Where Do I Go To Find All The ScriptContexts Feilds and Functions?
Hi im getting lost in the documentation, I have found some things I was looking for but am failing to find the info and functions for script contents. Im using this link https://playground.plutus.iohkdev.io/doc/haddock/ where should I look in here the docs are pretty long.

here it is: https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Contexts.html
a little hint to use the docs:
usually when I'm searching for some module I press Ctrl+F (for "find") and type for some module I'm looking for.
in this case by going to https://playground.plutus.iohkdev.io/doc/haddock/ I just pressed Ctrl+F and searched for "Context"
pro tip
on modules-specific pages you can use the same trick with functions type signature
as an example say you are searching for a function that gives you back the total value spent but you don't remember the name
just press Ctrl+F and search for something like -> value

the search is NOT case sensitive

to quickly find all the functions that do return Values

Yeah I asked because I got something weird using ctrl F but that's for another question

Try searching with just S


text:
Where does the PAB run?
I understand that PAB is a backend that:

provides a standardized environment in which Plutus applications run
provides disciplined state management
presents discoverable interfaces to the external clients
tracks on-chain information for smart contract uses
allows developers to work in an emulated or non-emulated environment
deals with requests such as running contract instances, forwarding user input to these instances, and notifying these instances of ledger state change events

But is it just another piece of infrastructure we should consider in our solution or is it a service we can consume for example from a third party like Blockfrost?

You don't have to use it in your dApp stack. As a matter of fact, many existing dApps don't use it since it's not ready. It essentially is a module/ component that makes use of existing IO products (cardano-node, cardano-db-sync or its light version of it chain-indexer etc.)
Therefore, if you want to create a dApp you can choose to use Blockfrost to keep track of your smart contract state/ fetch datum hashes/ get UTxOs etc.
or you host your own instances of cardano-node/ submit-api and db-sync to do what blockfrost allows you to do and eventually PAB will as well.
PAB will offer more features than Blockfrost from what I understand.


text:
Do I need to validate for minADAUTxO output in Smart Contract validator?
I have a spending validator that currently expects an output with an NFT to be recreated at its own address.
Is it necessary to also include a check whether the output's value has a greater equal ADA balance of minAdaTxOut (minAdaTxOut Reference)
Or is this done by the 2 phase node validation process?

In theory no; In practice maybe.
If min ada is not present in each output then the Tx will fail regardless of validator.
But. Min ada as implemented in Plutus is hardcoded to 2 ada. This is not how min ada works. Min ada is calculated against the size (of data) of the utxo. More than three NFTs? that'll be more than 2 Ada  required in the same utxo.
If your using constraints then you'll need to bear this in mind,
since these details may really matter https://github.com/input-output-hk/plutus-apps/blob/c4cc9ee1add8f421e57789befb6a0c90621801f1/plutus-ledger-constraints/src/Ledger/Constraints/OnChain.hs#L123
How to calculate min ada is a bit convoluted. Why isnt a function in plutus-apps for it? No idea. Why wasn't it implemented properly... ?
You can extract the logic from here https://docs.cardano.org/native-tokens/minimum-ada-value-requirement/


text:
Problem with metadata on pool.pm
I am having some trouble with metadata for NFT I am minting.
This is the asset on pool.pm:
https://pool.pm/asset1q6fku9qrfld526pfdm746qu3j7wtgvuh5xet9u
And again on adaptors.org:
https://adapools.org/transactions/3bec2e04ecf374d8d341f6d4ef38c2b1b70b1817cb2e6a9fa197b2aea7dd8de2/metadata
When viewing the asset on pool.pm it shows an error:
Error:
Expecting an OBJECT with a field named `721`

But viewing it on adapools.org show that 721 tag is there.
And this is the actual metadata submitted in the transaction. What am I doing wrong here? And why is it pool.pm showing an error?
{
  "721": {
    "b767134d5185d7d7be2234855cc732c8b3b42d8b956b84244c83015c": {
      "TestNFT5": {
        "Name": "TestNFT #5",
        "Collection": "Multi-asset minting",
        "Description": "Used for testing multi-asset minting",
        "Mythic": "True",
        "Mythic Name": "Ancient",
        "Wizard Type": "Alcemist",
        "Ring Name": "Vollzabar",
        "mediaType": "image/jpg",
        "image": "ipfs://QmXEyaE9GQJ2Qbgzozjfb23drA5jaU9qXJu8jNPPxysZhu"
      }
    }
  }
}

Any help will be appreciated!
Edit: Naturally, I have validated metadata before minting using https://pool.pm/test/metadata and no errors were shown.

pool.pm answers a similar issue - see if there are some useful pointers there: https://forum.cardano.org/t/problem-in-displaying-nft-on-pool-pm-after-minting/90381/10

You have wrong policy ID in your metadata.
This is your mint trx https://cardanoscan.io/transaction/3bec2e04ecf374d8d341f6d4ef38c2b1b70b1817cb2e6a9fa197b2aea7dd8de2?tab=metadata
The actual policy Id of your asset is abd58940b13f956ca5450786f14276204cf19b8b62105dc83b32cc64 and your metadata has b767134d5185d7d7be2234855cc732c8b3b42d8b956b84244c83015c

Yes, I have reviewed my code and can see that I accidentally used minting hash instead of policy id. Thank you for pointing me in the right direction!


text:
What is the best (and most secure) way to store private keys in an Express server?
I'm working on a server that will have access to a specific wallet that hold funds and NFTs to submit transactions. Therefore, it will have to manage private keys.
I'm thinking of storing them encrypted as environment variables (.env file), using RSA encryption.
Is this a good practice or is there a better way to do this?

See this post, Best setup of your air-gapped offline machine (cold environment)?.
Also consider the following https://cosd.com/frankenwallet.


text:
problem setting up the plutus environment
Noob here. I am basically just trying to learn plutus on my own I am on week01. When I ran the following command:
[nix-shell:~/plutus-apps/plutus-playground-client]$ npm run start (or even just npm start)
I get this error:

I tried "npm audit fix --force" and it did not help. Is there any suggestion on how I can overcome this issue? Thank you!

Looks like the --inline option was depecated from webpack as per: https://stackoverflow.com/questions/70528429/webpack-cli-error-webpack-cli-error-unknown-option-inline
What build guide are you following? Do they suggest a certain version of webpack to use?
(--inline should still be a valid option within the version that they suggest).
If they don't suggest a webpack version to use then you can go through the various versions on one of the NPM websites to find and install the right one.
Or you might be able to find and remove --inline from the build script, then rerun it.
Or work off of a different/more recent build guide maybe?

Hey @MC_Brisbane, I tried all your suggestions: 1) I used the latest iteration of plutus-pioneer-program, 2) used older versions of webpack, 3) deleted --inline from package.jason. None of them solved the issue. Deleting --inline actually threw out a different error.
I just really wonder how it's working for others but not for me? I followed all the build instructions to the tee.

Hi John, can you provide a link to the guide that you are following. Also which was the latest version of webpack that you tried that has --inline included?

Hi MC_Brisbane, thank you for trying to help me with this issue. I basically watch Lars' plutus tutorial videos as well as tutorials from other youtubers. I did not follow the plutus docs because it is outdated and there was no mention about the issue that I am currently having. The third video below really helped me overcome previous issues I've encountered.

Lars - https://www.youtube.com/watch?v=AnID8hn68DA&list=PLK8ah7DzglhhM57VKQTMIGDZj5OnmfgOX
https://www.youtube.com/watch?v=mnfItts6VbU
https://www.youtube.com/watch?v=CXHmbOkoVG8&list=WL&index=1

Also, the "--inline" that I deleted is not within webpack (I am using 5.72.1) but from the package.json file within the plutus-playground-client folder of plutus-apps. I am not sure if this is what I should delete(?)
Thank you again for helping!

At lot has changed since those 2021 videos were put together, but I'm sure they still have useful info. Looking at the 'PPP 030103' Jan 2022 videos (https://www.youtube.com/watch?v=zPaDp4R9X7o), Lars mentions that you need to set up NIX and start by cloning https://github.com/input-output-hk/plutus-pioneer-program and https://github.com/input-output-hk/plutus-apps (NOTE: this is not the main plutus codebase) Can you confirm that you followed each of these installation instructions? If not I'd lean towards starting over and following the IOHK github instructions and guidance from Lars' videos.

Can you post the full error details from the 'npm start' command. Also, I presume that the PP Server is running correctly when you run 'npm start' - can you please confirm, just in case?

Hello MC_Brisbane, my apologies if I have not responded to you earlier. I've been putting off some of my activities as I've been focusing on finding a job. It's very stressful but when I squared this problem away, I will be back to learning Plutus. I really appreciate your help!

No problem, John. We can pick this up again later. Best of luck with the job search.

@MC_Brisbane-JUSTPool migth sound silly but have you tryied running npm install before?

Hay man the best way is to spin up a VM like VirtualBox and make sure your dependencies match. Your problem here is that you are using a version of Webpack not compatible with your version of Plutus.
Step 1)
set up Ubuntu VM (recommend Ubuntu 20.4 LTS its the one I'm using so it works). optional setup vscode its pretty good.
Step 2)
Clone Plutus-apps repo
Step 3)
Clone plutus pioners program
Step 4)
install ghc and nixos
step 5)
open up the cabal build file from the week of the PPP your on. Press ctrl + F and look up apps. there should be a plutus-apps now highlighted in the file copy the commit reference right below it.
step 6)
cd into your plutus-apps dir and git checkout <refrance you just copied>
Step 7)
nix-shell
Step 8)
cd to the correct week of Plutus pioneers program
cabal build
code .
you should now be in the environment inside vscode in the correct location ready to code.
to set up the client and server for the playground and the documentation look up the Plutus Env_ Setup Starter Pack.pdf


text:
How can I start a Hydra Node in devnet?
I have been researching on how to start a Hydra node in devnet using Docker and I found this link with these two simple commands:
docker pull ghcr.io/input-output-hk/hydra-node:latest
docker run --rm ghcr.io/input-output-hk/hydra-node --help

The problem is that, when I execute this, I get:
hydra-node - A prototype of Hydra Head protocol

Usage: hydra-node [-q|--quiet] [-n|--node-id INTEGER] [-h|--host IP]
                  [-p|--port PORT] [-P|--peer ARG] [--api-host IP]
                  [--api-port PORT] [--monitoring-port PORT]
                  [--hydra-signing-key FILE] [--hydra-verification-key FILE]
                  [--network-id INTEGER] [--node-socket FILE]
                  [--cardano-signing-key FILE] [--cardano-verification-key FILE]
                  [--start-chain-from SLOT.HEADER_HASH] [--ledger-genesis FILE]
                  [--ledger-protocol-parameters FILE] [--version]
                  [--script-info]

  Starts a Hydra Node

Available options:
  -q,--quiet               Turns off any logging
  -n,--node-id INTEGER     Sets this node's id
  -h,--host IP             The address this node listens on for Hydra network
                           peers connection (default: 127.0.0.1)
  -p,--port PORT           The port this node listens on for Hydra network peers
                           connection (default: 5001)
  -P,--peer ARG            A peer address in the form <host>:<port>, where
                           <host> can be an IP address, or a host name
  --api-host IP            The address this node listens on for client API
                           connections (default: 127.0.0.1)
  --api-port PORT          The port this node listens on for client API
                           connections (default: 4001)
  --monitoring-port PORT   The port this node listens on for monitoring and
                           metrics. If left empty, monitoring server is not
                           started
  --hydra-signing-key FILE Our Hydra multisig signing key.
  --hydra-verification-key FILE
                           Other party multisig verification key.
  --network-id INTEGER     A test network with the given network magic.
  --node-socket FILE       Local (Unix) socket path to connect to cardano node.
  --cardano-signing-key FILE
                           Signing key for the internal wallet use for Chain
                           interactions.
  --cardano-verification-key FILE
                           Cardano verification key of other Hydra participant's
                           wallet.
  --start-chain-from SLOT.HEADER_HASH
                           The point at which to start on-chain component.
                           Defaults to chain tip at startup time.
  --ledger-genesis FILE    Path to a Shelley-compatible genesis JSON file.
  --ledger-protocol-parameters FILE
                           Path to a JSON file describing protocol parameters
                           (same format as returned from 'cardano-cli query
                           protocol-parameters')
  -h,--help                Show this help text
  --version                Show version
  --script-info            Dump script info as JSON

This doesn't seem to start anything.
What is the correct way to start hydra-node?

This is how you run hydra-node in Devnet. You need to have Docker installed.
Keep in mind that, at the moment, this is just a POC:

git clone https://github.com/input-output-hk/hydra-poc
cd hydra-poc/demo/
./prepare-devnet.sh
./run-docker.sh

This will start 1 instance of cardano-node and 3 instances of hydra-node.
If you open a new terminal, you can check they are working correctly with this command (you need to be in the hydra-poc/demo directory):
docker-compose ps
Once this is done, you can check the initial state of the network using this command:
docker-compose exec cardano-node cardano-cli query utxo --testnet-magic 42 --whole-utxo

You can also send some ada to Alice, Bob and Carol addresses using:
./seed-devnet.sh
Now, if you check the status of the network again, you'll see something like this:
                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
0ad134cc87cdf66a6863464b4393501eda7632f7c268b068c48b2aaf84f20e51     1        250000000 lovelace + TxOutDatumNone
2e80d483600acf194661e89bb08aee0cbb2844cf237e43d5e949d11038db9a96     1        100000000 lovelace + TxOutDatumHash ScriptDataInAlonzoEra "a654fb60d21c1fed48db2c320aa6df9737ec0204c0ba53b9b94a09fb40e757f3"
3eeea5c2376b033d5bdeab6fe551950883b04c08a37848c6d648ea03476dce83     1        1000000000 lovelace + TxOutDatumNone
648d71c1cbd835f6e1966c06ba0ad4347c3b399ef00576e59aee18b9e1ec9489     0        897949001186 lovelace + TxOutDatumNone
648d71c1cbd835f6e1966c06ba0ad4347c3b399ef00576e59aee18b9e1ec9489     1        100000000 lovelace + TxOutDatumHash ScriptDataInAlonzoEra "a654fb60d21c1fed48db2c320aa6df9737ec0204c0ba53b9b94a09fb40e757f3"
6db235b8759454654d19baf3ef601a2cb0e4ea3ebdc5e9db466dd07bccf53c7d     1        500000000 lovelace + TxOutDatumNone
94f16fc2a16b7ffa96c7929cbfc1e2f05424b6508612d4513fa23eaf458dc14b     1        100000000 lovelace + TxOutDatumHash ScriptDataInAlonzoEra "a654fb60d21c1fed48db2c320aa6df9737ec0204c0ba53b9b94a09fb40e757f3"

If at any point you'll like to restart the docker containers, I suggest you run the following:
docker-compose stop
docker-compose rm -f

Then you'll be able to do ./run-docker.sh again.
There's also a client which you can use to play a little with the Hydra heads:
docker-compose --profile tui run hydra-tui-1

You can change between hydra-tui-1, hydra-tui-2 and hydra-tui-3, depending on which hydra-node you want to connect with. Only when you close a head you'll see the changes committed to the main chain (cardano-node).

Here you can find the official documentation on Hydra.
There is also a demo section where it is explained how to use it

You are running with the --help option: 'docker run --rm ghcr.io/input-output-hk/hydra-node --help'
This will only ever show you the help information.


text:
How to compare BuiltinByteStrings onchain?
I want to check on-chain if a given TokenName is of a specific pattern, for example:

aaa1
aaa2
aaa3

I have something like this, but it throws an interpreter exception:
checkValidMint :: TokenName -> Integer -> Bool
checkValidMint tn count  = tn == (TokenName $ "aaa" <> (integerToByteString count))

integerToByteString :: Integer -> BuiltinByteString
integerToByteString n
    | n == 0 = "0"
    | n == 1 = "1"
    | n == 2 = "2"
    | n == 3 = "3"
    | n == 4 = "4"
    | n == 5 = "5"
    | n == 6 = "6"
    | n == 7 = "7"
    | n == 8 = "8"
    | n == 9 = "9"
    | otherwise = integerToByteString (n `P.divide` 10) P.<> integerToByteString (n `P.modulo` 10)

Update 2
Also tried:
integerToByteString n
            | (Builtins.equalsInteger n 0) = "0"
            | (Builtins.equalsInteger n 1) = "1"
            | (Builtins.equalsInteger n 2) = "2"
            | (Builtins.equalsInteger n 3) = "3"
            | (Builtins.equalsInteger n 4) = "4"
            | (Builtins.equalsInteger n 5) = "5"
            | (Builtins.equalsInteger n 6) = "6"
            | (Builtins.equalsInteger n 7) = "7"
            | (Builtins.equalsInteger n 8) = "8"
            | (Builtins.equalsInteger n 9) = "9"
            | otherwise = integerToByteString (n `PlutusTx.Prelude.divide` 10) PP.<> integerToByteString (n `PlutusTx.Prelude.modulo` 10)

I keep getting an interpreter error:
GHC Core to PLC plugin: E042:Error: Unsupported feature: Use of Haskell Integer equality, possibly via the Haskell Eq typeclass Context: Compiling expr: GHC.Integer.Type.eqInteger# Context: Compiling expr: GHC.Integer.Type.eqInteger# x Context: Compiling expr: GHC.Integer.Type.eqInteger# x y Context: Compiling expr: case GHC.Integer.Type.eqInteger# x y of wild [Occ=Once] { __DEFAULT -> GHC.Prim.tagToEnum# @ GHC.Types.Bool wild } Context: Compiling expr: \ (y [Occ=Once] :: GHC.Integer.Type.Integer) -> case GHC.Integer.Type.eqInteger# x y of ...

This is how I've done the integer conversion in the past. Might need some minor updating:
{-# INLINEABLE intToString #-}
intToString :: Integer -> Builtins.String
intToString i = Prelude.foldr Builtins.appendString "" strings
  where
    ints = intToInts i
    strings = map (Builtins.charToString . intToChar) ints

{-# INLINEABLE intToChar #-}
intToChar :: Integer -> Haskell.Char
intToChar i
  | (Builtins.equalsInteger i 0) = '0'
  | (Builtins.equalsInteger i 1) = '1'
  | (Builtins.equalsInteger i 2) = '2'
  | (Builtins.equalsInteger i 3) = '3'
  | (Builtins.equalsInteger i 4) = '4'
  | (Builtins.equalsInteger i 5) = '5'
  | (Builtins.equalsInteger i 6) = '6'
  | (Builtins.equalsInteger i 7) = '7'
  | (Builtins.equalsInteger i 8) = '8'
  | (Builtins.equalsInteger i 9) = '9'
  | otherwise = '0' -- Fix this

Then instead of checkValidMint, you can just check that the expected amount of your new token is included in the output value in the policy ctx, like here in the Uniswap example.

Unfortunately, I cannot get this code to run. It seems like charToString is not part of the API anymore. And String has been replaced with BuiltinString.
I am not sure how to make use of this code. Any other suggestions?

Make sure you are using INLINEABLE on your code, try using equalsInteger instead of ==, and see where that lands you. You might need to dig and see what methods on char there are instead of charToString. I'd need to do some digging to say for sure what all has changed.

You may want to checkout the utils package I used for the open source cardano lottery located here: https://github.com/lley154/cardano-lottery/blob/main/src/Utils.hs.   This code has been tested and works on the testnet.
Also, there was a similar post that may help if you having issues and need to be aware of the encoding of builtinbytestrings in plutus.  How to get a base 16 hex BuiltinString from getTxId

After testing out many different variations, changing imports to make sure the correct functions of Prelude and PlutusTx.Prelude are used, I've found the problem:

I made sure this pragma is present: {-# LANGUAGE NoImplicitPrelude #-}
I imported both Preludes in a qualified way:

import           PlutusTx.Prelude as PP
import           Prelude          as P

which let's me clearly distinguish what operators to use when it comes to Integer comparisons. I subsequently replaces all == with either PP.== for on-chain and P.== for off-chain code.

Lastly, I found one more error where I used Integer pattern matching on-chain like so:

checkMint :: String -> Integer -> Bool
checkMint s (1)  = ...
checkMint s (-1) = ...
checkMint _ _    = False

The pattern matching seems to default to P.== for this on-chain code, so I replace it with an if-then-else and it worked fine.
checkMint s amt =
    if amt PP.== 1 then ...
    else if amt PP.== -1 then ...
    else ...


text:
What is Layer 0?
Someone told me that in a previous video Charles said cardano has the best layer 0. Did he mean Layer 1 or was this intentional?
Either way, what is a layer 0? And how do you interface with it from Layer 1 or from Layer 2?

https://coinmarketcap.com/alexandria/glossary/layer-0
https://insights.tokenmetrics.com/layer-0-blockchain-protocols/
https://dappradar.com/blog/horizen-and-the-importance-of-layer-0-blockchains
A few links to articles detailing 'Layer 0', hope this is insightful.
According to Benjamin Diggles, the co-founder and CSO of Constellation Network,

"Layer 0 protocol is the first layer among all blockchain protocols,
connecting seamlessly with all other protocols to build interconnected
value chains, offering a more robust and evolved alternative to smart
contracts."

When referencing external docs, please follow the guidelines in the help. https://cardano.stackexchange.com/help/referencing

The only true "layer 0" I am aware of is Polkadot.
The parachains are the "layer 1" and the relay chain is the "layer 0" that simply performs one function and one function only, relaying the XCM requests between the parachains.
I'm sure he meant layer 1.

Lets start by saying that all of these "Layer X" terms are non-technical and the differences are not clearly defined. Generally, a Layer 1 (L1) protocol is one with its own ledger & consensus mechanisms, whereas a Layer 2 (L2) protocol is one that builds on and leverages these mechanisms for (more) specific use cases. Things get confusing because this L2 definition applies to and has been used to describe everything from payment/state channels (i.e. Lightning/Hydra for Bitcoin/Cardano, respectively), sidechains (i.e. Milkomeda), rollups (i.e. Polygon for Ethereum), e.t.c., even though all of these are very different from each other.
Following this, intuition suggests that "Layer 0" is also a bit of an ambiguous term that refers to the system(s) that L1s build and depend on for their functioning. TCP/IP and the internet itself is one component of this "Layer 0". The legacy fiat monetary system can also be thought of as a part of this Layer 0 since most people (at least for now), must use it to onboard to crypto.
Layer 0 has also been used to define projects like Cosmos or Polkdadot, which focus on solving the interoperability problem by creating a "blockchain of blockchains". Charles may have commented on Cardano being the "Perfect Layer 0" because of its (future) native support for interoperability, using the main L1 chain for secure settlement.


text:
Python equivalent to Ogmios?
Has somebody written a library equivalent to Ogmios, that has the same functionalities, including a chain sync protocol, but entirely written in Python?

I just put this library together as I needed to access Ogmios from a Python application. It is still a work in progress, but it is working.
https://pypi.org/project/pyogmios/

I accepted your answer and gave a look at the repo. Very impressive that you built this. Will there be more documentation available over time? For example, how to store UTxO/asset data in SQL(ite) databases/dealing with chain rollbacks?

Thanks for accepting the answer. I am currently rewriting it to work with the latest version of Ogmios (v6.0.*). I can include some example code on handling the cases you mentioned, but the implementation details may differ as I am using MongoDB for the database.

https://pypi.org/project/pycardano/
I think this is as close as it gets with Python so far...


text:
Is there an API for Cardano Blockchain Insights?
I'm looking for any API or any source that would allow me to export data & statistics?
(Specifically Blockchain load per day)
I found that DataStudio has stats, yet it doesn't have any export options.
And I found that Blockfrost also has an API but I didn't find Blockchain load per day option there.
Cheers

You should upvote the answer when you accept it.

@gRebel I don't have enough reputation to upvote answers, however I did tag it as accepted answer.

If you don't want to run a node or services yourself you can use https://api.koios.rest/#overview
If you run your own node or are friendly with someone who does you can use DB-Sync.
DB-Sync is a PostgreSQL relational DB of Cardano blockchain data.
You can query it using standard SQL.
DB-Sync:
https://github.com/input-output-hk/cardano-db-sync
DB Schema:
https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/schema.md
Example queries:
https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/interesting-queries.md
Docs:
https://docs.cardano.org/cardano-components/cardano-db-sync

Thanks a lot :)


text:
transaction build Error: Non-Ada assets are unbalanced (sending native asset to smart contract via cardano-cli 1.34.1)
I have a wallet with the following two UTXOs:

a2e38168473ae7f42e86ac274733004b36a1e119b665a5dae9a799e3a6a9c47a#1 Contains pure ADA balance
942bd39f32524c83973fe3c6b5a9157f6fde5e9b5a30cd6cad8e92145eb2740d#1 Contains multiple native-assets

JSON dump of my wallet UTXO: https://pastebin.com/raw/rVpy9HSk
I would like to send one 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303130 into a smart contract, so I have built the transaction like this:
cardano-cli transaction build \
        --alonzo-era \
        --protocol-params-file tmp/protocol.json \
        --invalid-hereafter 99999999 \
        --out-file tmp/tx.draft \
        --change-address addr_test1qqh04eamdak8x5c5gwxyfxd4uh6cfw2ju3t2ch64an4g3sdzljz3waey7ew4ezg0uvqtrs0rpxuc25w0yptv4ke7z0sqv68nde \
        --tx-in 942bd39f32524c83973fe3c6b5a9157f6fde5e9b5a30cd6cad8e92145eb2740d#1 \
        --tx-in a2e38168473ae7f42e86ac274733004b36a1e119b665a5dae9a799e3a6a9c47a#1 \
        --tx-out="addr_test1wzlvtds2fp3c47p8ut7uumh8splsce70gnqxd8vsk9alcsc92es7p + 1758582 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303130" \
        --tx-out-datum-embed-file create_sale_datum.json \
        --testnet-magic 1097911063

As you can see, I am using using both UTXOs as input and one output (with datum) into SC address - the above results in the following error:

Command failed: transaction build  Error: Non-Ada assets are unbalanced: 129193426 lovelace + 1000 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.436972636c65436f696e + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.546573744c6f6e6744657363 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303035 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303036 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303037 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303039 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303131 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303132 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303133 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303134 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303135 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303136 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303137 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303138 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303139 + 1 9c2f2bd159a50fd8c8ba251c8a488c4ceef42c2cf53c3d7231589f34.57656c6c446f6e65536572696573303230

OS: Ubutunu
Node: 1.34.1 (Testnet)
Any ideas? It looks like it's failing to figure out the change correctly?

The cardano-cli transaction build --help mentions that the order of some options is crucial. In your command can you put --out-file last & --change-address after --tx-out & --testnet-magic after --alonzo-era and give it another crack. This might help --change-address

@MC_Brisbane-JUSTPool I tried changing the order of options as suggested, still returning same error about non-ada asset unbalanced: https://pastebin.com/raw/SDc1zDtV

Thanks for the update. One alternative is to try using build-raw instead of build but this would require you to calculate the fee and include it using --fee . It's not difficult, but is extra steps. Could be a good last resort if no one else is about to help.

Yes I have already planned use build-raw and manually workout the input/output & change. I just wanted to double check I wasn't doing anything silly trying to use the build. It does look like the CLI doesn't seem be able to handle utxo with multiple asset well sadly.

It will be interesting to see if someone has a solid answer to this using build.

Quinn on my team tells me this has always been the case, maybe this is a long overdue upgrade (handle change properly) to the cardano-cli

Good to know, thanks. It might be best to create an answer to your question and accept it. This will help save time for the next person looking for this info.


text:
How to test the serialisation of a transaction?
When using the Cardano serialisation library by emurgo, how do you test the output works as intended? Would this change when using parameterised contracts?

Without using an API service like BlockFrost https://blockfrost.io/ you can utilise the Transaction output (cborHex) string from the completed Serialization Library build process by copying it into an existing Cardano-Cli Signed Transaction and submit it via the Cli.
Signed Cli Transaction Format for file tx_1.signed:
{
    "type": "Tx AlonzoEra",
    "description": "",
    "cborHex": "<insert the cborHex string created by the serialization-lib here and submit via cli command"
}

Cli Command format for testnet
cardano-cli transaction submit --tx-file /Users/someuser/cardano-src/*tx_1.signed* --testnet-magic 1097911063

There is also a simple boolean function for testing if the Transaction is valid:
pub fn is_valid(&self) -> bool {
        self.is_valid.clone()
    }

https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/src/lib.rs
Hope this helps.


text:
Running nix-shell on Mac M1
I successfully installed NixOS on a Mac M1. However, running either nix-shell or GC_DONT_GC=1 nix-shell from within /marlowe-cardano (in the marlowe-pioneers branch) produces:
error: cannot bootstrap GHC on this platform ('aarch64-darwin' with libc 'defaultLibc')

Any ideas on how to get past this?

It seems that you did a multi-user w/ daemon installation. I am aware that a functioning guide is here
so get nix using the darwing unencrypted label
sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

edit your sudo nano /etc/nix/nix.conf  file, by adding IOHK's binaries:
build-users-group = nixbld

substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=

system = x86_64-darwin
extra-platforms = x86_64-darwin aarch64-darwin

sandbox = false
extra-sandbox-paths = /System/Library/Frameworks /System/Library/PrivateFrameworks /usr/lib /private/tmp /private/var/tmp /usr/bin/env
experimental-features = nix-command
extra-experimental-features = flakes

reboot and you should be good to go.
note I am no Nix expert nut if the problem persists then you might need to completely uninstall Nix first, which is not so trivial.

This was spot on, thanks!
I did have to uninstall nix first. Also needed to be in the /marlowe-cardano directory during installation in order to be able to run nix-shell.

Glad it worked! If you upvote and mark my answer as solved it will help other people find it ;)


text:
Where does Nami store private keys?
I would like to access my private key from Nami wallet. Where are they supposed to be stored?

Here is the GitHub for Nami, as it is open source.
Looks like it uses chrome local storage. I believe chromes local data is located in %AppData%\Google\Chrome\User Data\Default\Local Storage atleast for windows users.

In which file ? It's filled with predominantly log files for me

You'd have to check your extension ID (you can check that in Dev Tools), and go to <Browser AppData Path>/User Data/Default/Local Extension Settings/<extension ID>.
In there you'd see a LDB file (viewing it in ASCII viewer will still show you the encrypted private key, that can only be decrypted using your spending password).
But in general, you're better off using mnemonics instead of trying to use decrypted private keys

Last time I had only my mnemonic key and when the coin was no longer supported by the wallet i had to find a private key to get access which I did not write down because I thought mnemonic was enough. I was never able to retrieve those coins after that even though i had the mnemonic and spoke to the tech team. That was with the Guarda Wallet. I think you need both private key and mnemonic as a backup. And this option should be in the wallet interface like every other wallet has. should not have to fish around for it.


text:
How can I build a transaction to send different assets (not just ada) using Cardano Serialization Lib?
I have followed this example on how to create a transaction to send ada and I had no issues so far.
What I would like to do next is to add different assets to this same transaction.
Is there an example on how to do that?

If you are open to use other packages, https://github.com/StricaHQ/typhonjs is a package which you can use to build transactions, It's easy to explore this as this is written in TS.

This is how you build a multi-token transaction using cardano-serialization-lib:
export async function buildMultiAssetTx(
  fromAddress: string,
  toAddress: string,
  policy: string,
  assetName: string,
  amount: string,
  privateKey: CardanoWasm.PrivateKey
) {

  const params = await getParameters();

  const linearFee = CardanoWasm.LinearFee.new(
    CardanoWasm.BigNum.from_str(params.data.genesis.shelley.protocolParams.minFeeA.toString()),
    CardanoWasm.BigNum.from_str(params.data.genesis.shelley.protocolParams.minFeeB.toString())
  );

  const txBuilderConfig = CardanoWasm.TransactionBuilderConfigBuilder.new()
    .fee_algo(linearFee)
    .pool_deposit(CardanoWasm.BigNum.from_str(params.data.genesis.shelley.protocolParams.poolDeposit.toString()))
    .key_deposit(CardanoWasm.BigNum.from_str(params.data.genesis.shelley.protocolParams.keyDeposit.toString()))
    .max_value_size(params.data.genesis.alonzo.maxValueSize)
    .max_tx_size(params.data.genesis.shelley.protocolParams.maxTxSize)
    .coins_per_utxo_word(CardanoWasm.BigNum.from_str(params.data.genesis.alonzo.lovelacePerUTxOWord.toString()))
    .build();

  // instantiate the tx builder with the Cardano protocol parameters - these may change later on
  const txBuilder = CardanoWasm.TransactionBuilder.new(txBuilderConfig);

  const unspentOutputs = await getTxUnspentOutputs(fromAddress);

  // pointer address
  const shelleyChangeAddress = CardanoWasm.Address.from_bech32(fromAddress);

  const minter = CardanoWasm.Address.from_bech32(toAddress);

  var txOutputBuilder = CardanoWasm.TransactionOutputBuilder.new();
  txOutputBuilder = txOutputBuilder.with_address(minter);
  var txOutputAmountBuilder = txOutputBuilder.next();

  const multiAsset = CardanoWasm.MultiAsset.new()

  const assets = CardanoWasm.Assets.new()
  assets.insert(
    CardanoWasm.AssetName.new(Buffer.from(assetName, "hex")), // Asset Name
    CardanoWasm.BigNum.from_str(amount) // How much to send
  );
  multiAsset.insert(
    CardanoWasm.ScriptHash.from_bytes(Buffer.from(policy, "hex")), // PolicyID
    assets
  );

  txOutputAmountBuilder = txOutputAmountBuilder.with_asset_and_min_required_coin(multiAsset, CardanoWasm.BigNum.from_str(params.data.genesis.alonzo.lovelacePerUTxOWord.toString()))
  const txOutput = txOutputAmountBuilder.build();

  txBuilder.add_output(txOutput)

  // add a keyhash input - for ADA held in a Shelley-era normal address (Base, Enterprise, Pointer)
  txBuilder.add_inputs_from(unspentOutputs, 3); // LargestFirstMultiAsset

  // set the time to live - the absolute slot value before the tx becomes invalid
  const slot = await getSlotNo();
  txBuilder.set_ttl(slot.data.cardano.tip.slotNo + 10000);

  // calculate the min fee required and send any change to an address
  txBuilder.add_change_if_needed(shelleyChangeAddress)

  // once the transaction is ready, we build it to get the tx body without witnesses
  const txBody = txBuilder.build()
  const txHash = CardanoWasm.hash_transaction(txBody);
  const witnesses = CardanoWasm.TransactionWitnessSet.new();
  const vkeyWitnesses = CardanoWasm.Vkeywitnesses.new();
  const vkeyWitness1 = CardanoWasm.make_vkey_witness(txHash, privateKey);

  vkeyWitnesses.add(vkeyWitness1);

  witnesses.set_vkeys(vkeyWitnesses);
  witnesses.set_native_scripts(CardanoWasm.NativeScripts.new());

  // create the finalized transaction with witnesses
  const transaction = CardanoWasm.Transaction.new(
    txBody,
    witnesses,
    undefined, // transaction metadata
  );

  return toHexString(transaction.to_bytes());

}

https://github.com/ozgrakkurt/cardano-mint-nft/blob/master/index.js
The example above from Özgür Akkurt on GitHub demonstrates how to mint native tokens in JS, assuming you are looking for that language.
https://github.com/Emurgo/cardano-serialization-lib/blob/master/doc/getting-started/minting-nfts.md
This is the next example directly from the Emurgo library is the next example in sequence from the previous example you followed.
Is it Native tokens you are looking to send?

Referencing guidelines: https://cardano.stackexchange.com/help/referencing


text:
Is there a way to start a Cardano node in Devnet?
I'd like to start a Cardano node in Devnet (not Testnet).
I looked for the configuration files in here, but it seems they are not available.
Is this even possible?

Is there even a devnet?

Yes, I know there is a Devnet because the Hydra POC should be run in Devnet using Docker (check this repo: https://github.com/input-output-hk/hydra-poc). What I don't know if it is possible to run cardano-node in Devnet without Docker.

Looks like devnet refers to your local/private environment.
The Hydra-POC docs refer to it as 'a single Cardano node producing blocks used as a local devnet'
More details about Hydra-POC set up here:
https://hydra.family/head-protocol/docs/getting-started/demo/with-docker/
There are 'With Docker' and 'Without Docker' instructions.
The 'With Docker' portion notes: 'From there, we can run the ./prepare-devnet.sh script to create an initial configuration for our development network'.


text:
How can I stop Cardano Node correctly without running it as a service?
Is there a way to correctly stop cardano-node different than making it run as a service?
I have noticed that, since version 1.34.1, I'm getting the message Validating chunk no. X out of Y. every time I restart it.
I assume this is happening because I'm not stopping it correctly.
I'm using tmux and I just use kill-session command to stop my node.

I'm using tmux and I just use kill-session command to stop my node.

That is probably not a safe shutdown.
For a safe shutdown you should go to the terminal where the node is running and send Control-C. You will then get a message like:
[mainnet:cardano.node.ChainDB:Info:5] [2022-05-30 05:32:03.82 UTC] Closed db with
 immutable tip at 1000a37390ad4590c317da8ec0b456b7d2a50b5a07ad6162cd3fb0b5f5862a7a
 at slot 62277555 and
 tip b1b90587bf4e55e88a0f59ebfd0e4010aabfcd4c5209921a77bb12f479f32df0
 at slot 62322410

Shutting down..

This indicts a correct and safe shutdown.

I think you should resume the session and press Control-C to stop cardano-node when you are running it in tmux.

I've seen people suggest kill -2 <PID> as it sends a SIGINT (similar to CTRL-C), but it never quite completes for me. There is always 1 external network connection active and the main node process is still running, which I then kill <PID> after 10-15 minutes.
Although doing it this way does start up more quickly and avoids most of the Validating chunk X of Y work.


text:
What's the correct way of submitting a transaction using cardano-graphql?
I'm getting this error when trying to submit a transaction using graphql:
{
  "errors": [
    {
      "message": "Deserialization failed in Transaction.metadata because: Expected null, found other type",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "submitTransaction"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: Deserialization failed in Transaction.metadata because: Expected null, found other type",
            "    at Object.<anonymous> (/app/packages/api-cardano-db-hasura/dist/executableSchema.js:77:43)",
            "    at Generator.throw (<anonymous>)",
            "    at rejected (/app/packages/api-cardano-db-hasura/dist/executableSchema.js:6:65)",
            "    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
          ]
        }
      }
    }
  ],
  "data": null
}

What is this trying to say?
The transaction has been built using cardano-serialization-lib.
I'm 100% sure the transaction is correct because it's been accepted using other methods.

I don't suggest using cardano-graphql to submit a transaction: every time the node gets behind the tip of the blockchain, it fails.
ogmios is much more reliable for this regard.
You can submit a transaction using the following code:
const WebSocket = require('ws');
const client = new WebSocket("wss://ogmios-api.testnet.dandelion.link");

function wsp(methodname, args) {
    client.send(JSON.stringify({
        type: "jsonwsp/request",
        version: "1.0",
        servicename: "ogmios",
        methodname,
        args
    }));
}

client.once('open', () => {
    const submit =
      "g6QAgYJYIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGCglg5AQEBAQEBAQEB"+
      "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBGgAehICC"+
      "WDkBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC"+
      "AgICAgIaAHgXXAIaAAH6pAMZHkahAIGCWCABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+
      "AAAAAFhA169grjPSrzUUEcFEXHlZBSaZC/pzy7NzK1TvMi2qFC5ohAI0EPi+PBbpvVIHbyuz"+
      "a/ON/gNKnwRljp9WGXq4D/Y=";

    wsp("SubmitTx", { submit });
});

client.on('message', function(msg) {
    const response = JSON.parse(msg);
    console.log(response);
    client.close();
});

Keep in mind that, in this example, the transaction is already in base64 format (submit variable). To convert from hex to base64, you need to use these helpers:
const arrayBufferToBase64=( buffer )=> {
  var binary = '';
  var bytes = new Uint8Array( buffer );
  var len = bytes.byteLength;
  for (var i = 0; i < len; i++) {
      binary += String.fromCharCode( bytes[ i ] );
  }
  return Buffer.from(binary, "binary").toString("base64");
}

const fromHex=(hex)=>Buffer.from(hex,"hex");

const bytes = arrayBufferToBase64(fromHex(txHex));

Then you can pass bytes to wsp function.


text:
Rust Serialization Lib Minting NFT - Missing Key Witnesses Error on Submission
I am running into an error with the CSL Rust Lib when submitting a minting NFT tx.  I am following a minimal example in JS https://gist.github.com/lovalabs/83d08796ab9ff65cbf188fbca8d03343 as a guide for the RUST library.  I receive the following error when attempting to submit the built tx via the cardano-CLI:
Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (MissingScriptWitnessesUTXOW (fromList [ScriptHash "d47c1b40ca47ac8f1b0c0f01941acbc634dbd5896239a2ade9548557"]))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (UtxosFailure (CollectErrors [NoRedeemer (Minting (PolicyID {policyID = ScriptHash "d47c1b40ca47ac8f1b0c0f01941acbc634dbd5896239a2ade9548557"})),NoWitness (ScriptHash "d47c1b40ca47ac8f1b0c0f01941acbc634dbd5896239a2ade9548557")]))))])

My RUST declarations are as follows:
Policy NativeScripts
 //Initialize 'NativeScript' for NFT Policy
    let mut native_scripts = NativeScripts::new();
    let script_public_key = NativeScript::new_script_pubkey(&ScriptPubkey::new(&policy_public_key_hash));

    //Initialize 'TimelockExpiry' and 'NativeScript'
    let timelock_expiry_fmt = TimelockExpiry::new_timelockexpiry(&BigNum::from_str("59634480").unwrap());
    let script_timelock = NativeScript::new_timelock_expiry(&timelock_expiry_fmt);

    //Add Public Key and Timelock 'NativeScript' to Collection of 'NativeScripts'
    native_scripts.add(&script_public_key);
    native_scripts.add(&script_timelock);

    //Initialize 'ScriptAll' type of 'NativeScript' & Add 'NativeScripts' with script public key and timelock expiry
    let policy_script = NativeScript::new_script_all(&ScriptAll::new(&native_scripts));

    //Initialize 'PolicyID', 'AssetName', and 'Amount'
    let asset_name = AssetName::new("Rust-CSL-NFT-Mint".as_bytes().to_vec()).unwrap();
    let amount = Int::new(&BigNum::from_str("1").unwrap());

Builder & Witnesses
//Add 'NativeScript', 'AssetName', 'Amount' (Int), and 'TransactionOutputAmountBuilder' to 'TransactionBuilder'
    tx_builder.add_mint_asset_and_output_min_required_coin(&policy_script, &asset_name, amount, &tx_output_amount_builder).unwrap();

    //Set 'ttl' for 'Transaction'
    tx_builder.set_ttl_bignum(&BigNum::from_str("59634480").unwrap());

    //Add 'TransactionInputs'
    tx_builder.add_key_input(&input_public_key_hash, &tx_input_1, &tx_value);

    //Add Change Wallet
    tx_builder.add_change_if_needed(&addr_1).unwrap();

    //Build Transaction
    let transaction = tx_builder.build_tx().unwrap();

    //Set 'TransactionWitnessSet'
    let mut vkey_witnesses: Vkeywitnesses = Vkeywitnesses::new();
    let tx_hash = hash_transaction(&transaction.body());
    let vkey_witness_wallet = make_vkey_witness(&tx_hash, &input_private_key);
    let vkey_witness_policy = make_vkey_witness(&tx_hash, &policy_private_key);
    vkey_witnesses.add(&vkey_witness_wallet);
    vkey_witnesses.add(&vkey_witness_policy);
    let mut tx_witness_set = TransactionWitnessSet::new();
    tx_witness_set.set_vkeys(&vkey_witnesses);
    tx_witness_set.set_native_scripts(&native_scripts);

    //Sign Transaction
    let signed_transaction = Transaction::new(&transaction.body(), &tx_witness_set, None);

I hope that I am missing something simple here.  I have added the input and policy keys as witnesses and I have added the policy nativescripts to the tx_witness_set but have not had any success resolving the error.  There is more than enough Test Ada in the utxo and I understand that the add_mint_asset_and_output_min_required_coin() handles the min fee and defines the PolicyID associated with the tx.  Any help or guidance is greatly appreciated as I have not found any rust tutorials or examples for the CSL.

I was able to complete the NFT Minting successfully following a different JS demo as a reference https://github.com/Emurgo/cardano-serialization-lib/blob/master/doc/getting-started/minting-nfts.md There are zero RUST examples online for using the Cardano Serialization Library so I will post the code for any future Rustaceans in search of help.
//------------------------------------------NFT Policy------------------------------------------
    //Initialize 'NativeScript' for NFT Policy
    let mut native_scripts = NativeScripts::new();

    //let script_public_key = NativeScript::new_script_pubkey(&ScriptPubkey::new(&policy_public_key_hash));
    let policy_addr = BaseAddress::new(NetworkInfo::testnet().network_id(), &StakeCredential::from_keyhash(&policy_public_key_hash), &StakeCredential::from_keyhash(&policy_public_key_hash)).to_address();
    let policy_keyhash = BaseAddress::from_address(&policy_addr).unwrap().payment_cred().to_keyhash().unwrap();
    let key_hash_script = NativeScript::new_script_pubkey(&ScriptPubkey::new(&policy_keyhash));
    native_scripts.add(&key_hash_script);

    //Initialize 'TimelockExpiry' and 'NativeScript'
    let timelock_expiry_fmt = TimelockExpiry::new_timelockexpiry(&BigNum::from_str("59634480").unwrap());
    let script_timelock = NativeScript::new_timelock_expiry(&timelock_expiry_fmt);
    native_scripts.add(&script_timelock);

    let mint_script = NativeScript::new_script_all(&ScriptAll::new(&native_scripts));

    let addr = BaseAddress::new(NetworkInfo::testnet().network_id(), &StakeCredential::from_keyhash(&input_public_key_hash), &StakeCredential::from_keyhash(&input_public_key_hash)).to_address();
    let private_key_hash = BaseAddress::from_address(&addr).unwrap().payment_cred().to_keyhash().unwrap();

 //--------------------------------------Transaction Builder--------------------------------------
    //Initialize 'TransactionBuilder' from 'TransactionBuilderConfig'
    let mut tx_builder = TransactionBuilder::new(&tx_builder_config);

    //Add 'TransactionInputs'
    tx_builder.add_key_input(&private_key_hash, &tx_input_1, &tx_value);

    //Initialize 'PolicyID', 'AssetName', and 'Amount'
    let asset_name = AssetName::new("Rust-CSL-NFT-Mint".as_bytes().to_vec()).unwrap();
    let amount = Int::new(&BigNum::from_str("1").unwrap());

//------------------------------------Outputs (Wallet Addresses)---------------------------------
     //Initialize 'TransactionOutputAmountBuilder' from 'TransactionOutputBuilder'
     let tx_output_builder = TransactionOutputBuilder::new();
     let tx_output_amount_builder = tx_output_builder.with_address(&addr).next().unwrap();

    //Add 'NativeScript', 'AssetName', 'Amount' (Int), and 'TransactionOutputAmountBuilder' to 'TransactionBuilder'
    tx_builder.add_mint_asset_and_output_min_required_coin(&mint_script, &asset_name, amount, &tx_output_amount_builder).unwrap();

    //------------------------------------------NFT METADATA------------------------------------------
    //Generate Policy ID and Metadata
    let _policy_id = hex::encode(mint_script.hash().to_bytes());
    let metadata_input_string = String::from("{\"[d47c1b40ca47ac8f1b0c0f01941acbc634dbd5896239a2ade9548557]\": {\"[Rust-CSL-NFT-Mint]\": {\"name\": \"Rust-CSL-NFT-Mint-Example\",\"description\": \"Rust CSL NFT\",\"image\": \"bafkreibsko7qh472qkkwmk6fcfhbrhiuvzna5fkqzvak7gvgqosasaubi4\",\"type\": \"image\"}}}");
    let metadata = encode_json_str_to_metadatum(metadata_input_string.clone(), csl::metadata::MetadataJsonSchema::BasicConversions).expect("encode failed");
    let metadata_output_string = decode_metadatum_to_json_str(&metadata, csl::metadata::MetadataJsonSchema::BasicConversions).expect("decode failed");
    //println!("{}", metadata_output_string);

    //Set 'ttl' for 'Transaction'
    tx_builder.set_ttl_bignum(&BigNum::from_str("59634480").unwrap());

    //Set NFT 'MeatadatumLabel' (721)
    tx_builder.add_json_metadatum(&BigNum::from_str("721").unwrap(),metadata_output_string).unwrap();

        //Add Change Wallet
    tx_builder.add_change_if_needed(&addr).unwrap();

    let tx_body = tx_builder.build().unwrap();
    let tx_hash = hash_transaction(&tx_body);
    //println!("{:?}", hex::encode(&tx_hash.to_bytes()));

    let mut tx_witness_set = TransactionWitnessSet::new();
    let mut vkey_witnesses: Vkeywitnesses = Vkeywitnesses::new();
    vkey_witnesses.add(&make_vkey_witness(&tx_hash, &policy_private_key));
    vkey_witnesses.add(&make_vkey_witness(&tx_hash, &input_private_key));
    tx_witness_set.set_vkeys(&vkey_witnesses);
    tx_witness_set.set_native_scripts(&native_scripts);

    let mut witness_scripts = NativeScripts::new();
    witness_scripts.add(&mint_script);
    tx_witness_set.set_native_scripts(&witness_scripts);

    let unsigned_transaction = tx_builder.build_tx().unwrap();

    let signed_transaction = Transaction::new(&unsigned_transaction.body(), &tx_witness_set, unsigned_transaction.auxiliary_data());

https://explorer.cardano-testnet.iohkdev.io/en/address.html?address=addr_test1qpus2z0svc6n6dv64cryzdc695430lpkqvk5dsp6lltn8zteq5ylqe34856e4tsxgym35tftzl7rvqedgmqr4l7hxwys99g6gw
Hope this is useful for someone, I spent awhile searching for RUST examples and came up empty-handed.


text:
Plutus: how to obtain wallet details. Do I have to use the wallet web interface or there is some direct library call?
I need to know the amount of Ada remaining in an account in a off-chain Haskell plutus program. Should I use the wallet web interface of the kind:
http://localhost:8090/v2/wallets/$WALLET_ID
or there is some direct Plutus library call or haskell serialization library for that?

Assuming you are using React in the front-end,you can use the serialization library created by emurgo.After installing their library you first connect to a wallet like this. I will be connecting to a yoroi wallet , for any other wallet you can just swap out the name and it works same way.
import {Value} from "@emurgo/cardano-serialization-lib-asmjs"
let Buffer = require('buffer/').Buffer

const [balance,setBalance] = useState()
let API = ""
const connectToWallet = async () =>{
        try {
            API = await window.cardano.yoroi.enable();
        } catch(err) {
            console.log(err);
        }
}

After you enable it , it will return a api key. You can then use the API key to get the balance of wallet.
    getBalance = async () => {
        try {
            const balanceCBORHex = await API.getBalance();
            const balance = Value.from_bytes(Buffer.from(balanceCBORHex, "hex")).coin().to_str();
            setBalance(balance)

        } catch (err) {
            console.log(err)
        }

    }

Thanks @hang9921 that would be useful in the future. At this moment I'm programming in Haskell in the server. I need to access a server wallet like daedalus or the  cardano-wallet in https://github.com/input-output-hk/plutus-apps

Have you check out Cardano-transaction-library. https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/doc/getting-started.md


text:
Tutorial for Haskell Restful-API Webserver
Using free and open source Haskell and with minimal or ideally no external libraries, I need to build a very simple RESTful-API/database server and a CLI to manage it. I need to use it for serving up webpages, text files, or selected lines of json from a text file. After this is done, I would like to give it a GUI. My problem is I can't find any tutorials that explain how to do any of this.
Does anyone know of any tutorials that fit these requirements?
Much thanks

There are at least 3 web frameworks in the Haskell ecosystem, from simplest to most complex; Scotty, Yesod and Snap.
A google search shows up a bunch of tutorials: https://www.google.com/search?client=firefox-b-d&q=haskell+rest+web+server+howto

Thank you @ErikdeCastroLopo. I had been searching and searching but never thought to use the keyword howto. That was the charm.


text:
What's the correct way of deserializing a UTxO?
I'm getting the following error when trying to deserialize a UTxO obtained using cardano-graphql:
Deserialization failed in TransactionUnspentOutput because: No variant matched

This is the code that it's failing:
for (const rawUtxo of rawUtxos) {
      const utxo = CardanoWasm.TransactionUnspentOutput.from_bytes(
        Buffer.from(rawUtxo.transaction.hash, "hex")
      )
      const input = utxo.input()
      const txid = input.transaction_id().to_bytes().toString();
      const txindx = input.index()
      const output = utxo.output()
      const amount = output.amount().coin().to_str() // amount in lovelace
      const multiasset = output.amount().multiasset()

What am I doing wrong?

This is the code to deserialize the UTxOs of an address:
for (const rawUtxo of rawUtxos) {
      const utxo = C.TransactionUnspentOutput.from_bytes(Buffer.from(rawUtxo, "hex"));
      const input = utxo.input();
      const txid = Buffer.from(input.transaction_id().to_bytes(), "utf8").toString("hex");
      const txindx = showPtrInHex(input.index());
      const output = utxo.output();
      const amount = output.amount().coin().to_str(); // ADA amount in lovelace
      const multiasset = output.amount().multiasset();
      let multiAssetStr = "";

      if (multiasset) {
        const keys = multiasset.keys() // policy Ids of thee multiasset
        const N = keys.len();

        for (let i = 0; i < N; i++) {
          const policyId = keys.get(i);
          const policyIdHex = Buffer.from(policyId.to_bytes(), "utf8").toString("hex");
          const assets = multiasset.get(policyId)
          const assetNames = assets.keys();
          const K = assetNames.len()

          for (let j = 0; j < K; j++) {
            const assetName = assetNames.get(j);
            const assetNameString = Buffer.from(assetName.name(), "utf8").toString();
            const assetNameHex = Buffer.from(assetName.name(), "utf8").toString("hex")
            const multiassetAmt = multiasset.get_asset(policyId, assetName)
            multiAssetStr += ` + ${multiassetAmt.to_str()} ${policyIdHex} . ${assetNameHex} (${assetNameString})`
          }
        }
      }

      const obj = {
        txid: txid,
        txindx: txindx,
        amount: amount,
        str: `${txid} # ${txindx} = ${amount}`,
        multiAssetStr: multiAssetStr,
        TransactionUnspentOutput: utxo
      }

      utxos.push(obj);


text:
What is the total size of cexplorer on Postgres?
I have a relay node fully synced with the tip of the mainnet chain and DB-sync filling the Postgres database. DB-sync is currently syncing on epoch 321 and the database takes 103 GB of disk space. I noticed that as epochs move forward more storage space is required (and syncing is much slower).
I currently have only Postgres filling up a disk volume on Linux of total 187 GB.
My question is, what will be the total size of the cexplorer (for mainnet) database? Do I need more than 187 GB? Currently the chain is on epoch 342.

I noticed that as epochs move forward more storage space is required (and syncing is much slower).

Yes, that is the unfortunate reality.

I currently have only Postgres filling up a disk volume on Linux of total 187 GB.

It will continue growing. There is an SQL query that will tell you the size of the database. Last time I ran that on a fully synced database it was 140G.

Thanks for the reply. So it is 140GB in total (currently), that's good!
I use that query as well to check the size.

Its is 140G at epoch 336 and we are currently at epoch 342 so its a bit bigger than 140G (and its constantly growing).


text:
How to install the Marlowe Pioneers Daedalus bin in NixOS?
To enhance my education during the Marlowe Pioneers program (with simultaneous Emurgo Haskell Dev Pro course), I've been running NixOS as my daily driver for full immersion over the past two weeks or so (and loving it).
My google-foo is failing me regarding a declarative installation of the provided daedalus-4.10.0-marlowe_pioneers-21765.bin. While I'd prefer somehow declaring it globally in /etc/nixos/configuration.nix for now, alternative solutions are more than welcome.

the download is an installer. Running the installer will put an executable in ~/.local/bin/.
When I ran this executable I got an error. It's expecting a file /etc/localtime which I don't have and seems that it isnt standard on nixos.
You can edit this script (~/.local/bin/daedalus-marlowe_pioneers) to work around this.
On line 9 perform the following diff.
- cat /etc/localtime > etc/localtime
+ echo "TZif2UTCTZif2UTC\rUTC0" > etc/localtime

This sets it to utc. I got this off another linux machine
I haven't done any more than launch the app. It does however now launch

Thanks. I was looking for a way to install it declaritively. NixOS generations are a (re)configuration feature I'm loving.

By the way, I think you can set your timezone in /etc/nixos/configuration.nix and it will place that localtime link for you. I put time.timeZone = "America/Phoenix"; into the config of a fresh NixOS install, and a link localtime -> /etc/zoneinfo/America/Phoenix is now found in /etc.

Given that the binary is not available from a standard repo, you cannot do this with ease afaik.
(Like you can with, say, firefox or a project on github setup for nixos).
Cheers for the headsup on timezone


text:
How to get blockchain block load from blockfrost?
I'm currently going through Blockfrost documentation and trying to figure out if there is a way to fetch block load for each day.
Seems like they don't have such option, in that case: Is there a way to calculate block load?

No Blockfrost endpoint retrieves this information.
As per this tweet, the current size of blocks is 88KB.
So, you can calculate the % of block load for each block this way:
( cardano_node_metrics_blockfetchclient_blocksize / (88 * 1024) ) * 100

cardano_node_metrics_blockfetchclient_blocksize is a metric exposed by Prometheus in the cardano-node. You can query it using Grafana. Unfortunately, you will need to run your own node for this.
This is a very useful link on how to setup the Grafana Dashboard: https://developers.cardano.org/docs/stake-pool-course/handbook/grafana-dashboard-tutorial/

Thank you! However, there is no APIs that will not require to run node? I assume I just need to fetch size of the block and then make calculations myself

The problem is that, in order to fetch the size of the block (cardano_node_metrics_blockfetchclient_blocksize), you need to use Grafana. And Grafana is a tool made to monitor your own node: you can't plug it to an API.

Since you're looking for a way without running a node, example using Koios (am sure blockfrost offers similar endpoints too):

Max size of block from current protocol can be found using epoch_params

I am not sure if I fully understand the term block load , but I assume you mean average size of blocks for a specific time range. You can get a filtered list of size and time using blocks endpoint, the list is - ofcourse - paginated, which you can find an average of.
Sample: here


text:
Where can I find the max block size in the protocol parameters?
I know the actual block size is 88KB but I can't find this value in the protocol parameters.
I have ran this command in Testnet and got the following:
$ cardano-cli query protocol-parameters --testnet-magic 1097911063
{
    "maxValueSize": 5000,
    "minUTxOValue": null,
    "minPoolCost": 340000000,
    "monetaryExpansion": 3.0e-3,
    "stakeAddressDeposit": 2000000,
    "txFeeFixed": 155381,
    "poolRetireMaxEpoch": 18,
    "stakePoolDeposit": 500000000,
    "maxBlockExecutionUnits": {
        "memory": 80000000,
        "steps": 40000000000
    },
    "extraPraosEntropy": null,
    "stakePoolTargetNum": 500,
    "maxBlockHeaderSize": 1100,
    "maxCollateralInputs": 3,
    "txFeePerByte": 44,
    "treasuryCut": 0.2,
    "protocolVersion": {
        "minor": 0,
        "major": 6
    },
    "collateralPercentage": 150,
    "poolPledgeInfluence": 0.3,
    "costModels": {
        "PlutusScriptV1": {
            "mapData-memory-arguments": 32,
            "lessThanInteger-memory-arguments": 1,
            "sha3_256-cpu-arguments-slope": 82363,
            "bData-cpu-arguments": 150000,
            "equalsByteString-cpu-arguments-intercept": 112536,
            "equalsString-cpu-arguments-constant": 1000,
            "modInteger-memory-arguments-slope": 1,
            "equalsInteger-memory-arguments": 1,
            "trace-cpu-arguments": 150000,
            "iData-cpu-arguments": 150000,
            "equalsByteString-memory-arguments": 1,
            "unIData-memory-arguments": 32,
            "consByteString-memory-arguments-intercept": 0,
            "cekLamCost-exBudgetCPU": 29773,
            "indexByteString-cpu-arguments": 150000,
            "cekStartupCost-exBudgetMemory": 100,
            "listData-memory-arguments": 32,
            "divideInteger-cpu-arguments-constant": 148000,
            "lessThanInteger-cpu-arguments-intercept": 179690,
            "verifySignature-cpu-arguments-slope": 1,
            "appendString-memory-arguments-intercept": 0,
            "equalsString-cpu-arguments-slope": 1000,
            "blake2b-cpu-arguments-intercept": 2477736,
            "encodeUtf8-cpu-arguments-slope": 1000,
            "mapData-cpu-arguments": 150000,
            "equalsByteString-cpu-arguments-slope": 247,
            "multiplyInteger-cpu-arguments-intercept": 61516,
            "cekStartupCost-exBudgetCPU": 100,
            "sndPair-memory-arguments": 32,
            "sha3_256-cpu-arguments-intercept": 0,
            "addInteger-cpu-arguments-slope": 0,
            "constrData-memory-arguments": 32,
            "divideInteger-memory-arguments-intercept": 0,
            "cekForceCost-exBudgetCPU": 29773,
            "equalsByteString-cpu-arguments-constant": 150000,
            "modInteger-cpu-arguments-model-arguments-intercept": 425507,
            "sliceByteString-memory-arguments-slope": 1,
            "equalsString-memory-arguments": 1,
            "cekLamCost-exBudgetMemory": 100,
            "lessThanEqualsInteger-cpu-arguments-intercept": 145276,
            "quotientInteger-memory-arguments-minimum": 1,
            "consByteString-cpu-arguments-intercept": 150000,
            "appendByteString-memory-arguments-slope": 1,
            "lessThanByteString-cpu-arguments-slope": 248,
            "lessThanByteString-memory-arguments": 1,
            "multiplyInteger-cpu-arguments-slope": 11218,
            "cekVarCost-exBudgetCPU": 29773,
            "cekDelayCost-exBudgetMemory": 100,
            "blake2b-cpu-arguments-slope": 29175,
            "mkNilData-cpu-arguments": 150000,
            "appendByteString-cpu-arguments-slope": 621,
            "appendString-memory-arguments-slope": 1,
            "lessThanInteger-cpu-arguments-slope": 497,
            "chooseUnit-memory-arguments": 32,
            "divideInteger-cpu-arguments-model-arguments-slope": 118,
            "decodeUtf8-cpu-arguments-slope": 1000,
            "chooseData-cpu-arguments": 150000,
            "verifySignature-cpu-arguments-intercept": 3345831,
            "modInteger-memory-arguments-minimum": 1,
            "lessThanEqualsByteString-memory-arguments": 1,
            "quotientInteger-cpu-arguments-constant": 148000,
            "consByteString-memory-arguments-slope": 1,
            "tailList-memory-arguments": 32,
            "divideInteger-cpu-arguments-model-arguments-intercept": 425507,
            "decodeUtf8-cpu-arguments-intercept": 150000,
            "lessThanEqualsInteger-memory-arguments": 1,
            "appendByteString-cpu-arguments-intercept": 396231,
            "unMapData-memory-arguments": 32,
            "chooseList-cpu-arguments": 150000,
            "divideInteger-memory-arguments-minimum": 1,
            "unListData-memory-arguments": 32,
            "remainderInteger-cpu-arguments-constant": 148000,
            "addInteger-memory-arguments-slope": 1,
            "sha3_256-memory-arguments": 4,
            "lessThanByteString-cpu-arguments-intercept": 103599,
            "modInteger-cpu-arguments-constant": 148000,
            "lessThanEqualsInteger-cpu-arguments-slope": 1366,
            "appendByteString-memory-arguments-intercept": 0,
            "listData-cpu-arguments": 150000,
            "ifThenElse-memory-arguments": 1,
            "cekApplyCost-exBudgetMemory": 100,
            "sliceByteString-memory-arguments-intercept": 0,
            "unIData-cpu-arguments": 150000,
            "modInteger-cpu-arguments-model-arguments-slope": 118,
            "equalsData-cpu-arguments-intercept": 150000,
            "mkNilPairData-memory-arguments": 32,
            "cekConstCost-exBudgetCPU": 29773,
            "indexByteString-memory-arguments": 1,
            "blake2b-memory-arguments": 4,
            "lessThanEqualsByteString-cpu-arguments-slope": 248,
            "cekDelayCost-exBudgetCPU": 29773,
            "multiplyInteger-memory-arguments-slope": 1,
            "remainderInteger-memory-arguments-slope": 1,
            "subtractInteger-cpu-arguments-slope": 0,
            "iData-memory-arguments": 32,
            "cekBuiltinCost-exBudgetCPU": 29773,
            "mkNilData-memory-arguments": 32,
            "cekForceCost-exBudgetMemory": 100,
            "trace-memory-arguments": 32,
            "encodeUtf8-cpu-arguments-intercept": 150000,
            "sha2_256-cpu-arguments-intercept": 2477736,
            "headList-memory-arguments": 32,
            "unBData-cpu-arguments": 150000,
            "remainderInteger-memory-arguments-minimum": 1,
            "unMapData-cpu-arguments": 150000,
            "sha2_256-cpu-arguments-slope": 29175,
            "modInteger-memory-arguments-intercept": 0,
            "ifThenElse-cpu-arguments": 1,
            "tailList-cpu-arguments": 150000,
            "multiplyInteger-memory-arguments-intercept": 0,
            "remainderInteger-memory-arguments-intercept": 0,
            "consByteString-cpu-arguments-slope": 1000,
            "lengthOfByteString-memory-arguments": 4,
            "fstPair-memory-arguments": 32,
            "mkPairData-cpu-arguments": 150000,
            "appendString-cpu-arguments-intercept": 150000,
            "verifySignature-memory-arguments": 1,
            "sliceByteString-cpu-arguments-intercept": 150000,
            "equalsData-cpu-arguments-slope": 10000,
            "lessThanEqualsByteString-cpu-arguments-intercept": 103599,
            "chooseList-memory-arguments": 32,
            "nullList-memory-arguments": 32,
            "unListData-cpu-arguments": 150000,
            "equalsData-memory-arguments": 1,
            "quotientInteger-cpu-arguments-model-arguments-slope": 118,
            "sha2_256-memory-arguments": 4,
            "quotientInteger-cpu-arguments-model-arguments-intercept": 425507,
            "encodeUtf8-memory-arguments-intercept": 0,
            "quotientInteger-memory-arguments-slope": 1,
            "unConstrData-cpu-arguments": 150000,
            "sliceByteString-cpu-arguments-slope": 5000,
            "cekBuiltinCost-exBudgetMemory": 100,
            "equalsInteger-cpu-arguments-slope": 1326,
            "subtractInteger-memory-arguments-slope": 1,
            "mkCons-cpu-arguments": 150000,
            "chooseUnit-cpu-arguments": 150000,
            "chooseData-memory-arguments": 32,
            "bData-memory-arguments": 32,
            "appendString-cpu-arguments-slope": 1000,
            "decodeUtf8-memory-arguments-slope": 8,
            "fstPair-cpu-arguments": 150000,
            "unConstrData-memory-arguments": 32,
            "sndPair-cpu-arguments": 150000,
            "addInteger-memory-arguments-intercept": 1,
            "cekConstCost-exBudgetMemory": 100,
            "remainderInteger-cpu-arguments-model-arguments-intercept": 425507,
            "equalsString-cpu-arguments-intercept": 150000,
            "mkCons-memory-arguments": 32,
            "mkPairData-memory-arguments": 32,
            "lengthOfByteString-cpu-arguments": 150000,
            "remainderInteger-cpu-arguments-model-arguments-slope": 118,
            "cekApplyCost-exBudgetCPU": 29773,
            "constrData-cpu-arguments": 150000,
            "nullList-cpu-arguments": 150000,
            "headList-cpu-arguments": 150000,
            "decodeUtf8-memory-arguments-intercept": 0,
            "subtractInteger-cpu-arguments-intercept": 197209,
            "subtractInteger-memory-arguments-intercept": 1,
            "encodeUtf8-memory-arguments-slope": 8,
            "equalsInteger-cpu-arguments-intercept": 136542,
            "quotientInteger-memory-arguments-intercept": 0,
            "cekVarCost-exBudgetMemory": 100,
            "unBData-memory-arguments": 32,
            "addInteger-cpu-arguments-intercept": 197209,
            "mkNilPairData-cpu-arguments": 150000,
            "divideInteger-memory-arguments-slope": 1
        }
    },
    "maxTxExecutionUnits": {
        "memory": 16000000,
        "steps": 10000000000
    },
    "executionUnitPrices": {
        "priceSteps": 7.21e-5,
        "priceMemory": 5.77e-2
    },
    "decentralization": 0,
    "utxoCostPerWord": 34482,
    "maxTxSize": 16384,
    "maxBlockBodySize": 98304
}

I have looked for 90112 (since that's 88 * 1024 - in bytes), but no luck either.
What's the right way of getting the max block size from here?

You can get this info from the live chain protocol-parameters and filter on the string block, as per below:
$ cardano-cli query protocol-parameters --mainnet |grep -i block
    "maxBlockExecutionUnits": {
    "maxBlockHeaderSize": 1100,
    "maxBlockBodySize": 90112

90112 / 1024 = 88KB

Ok, this is exactly what I was doing. So basically what this is telling me is that the maxBlockBodySize in Testnet is 96KB (98304 / 1024) instead of 88KB bytes. Is this correct?

I haven't tried this on testnet, but if you're getting 98304 then yeah it looks like they are running with a larger block size when compared to mainnet.

Yes, that's it. Cheers!

You are looking in the wrong place. You are looking at the genesis config for one of the eras (Alonzo maybe?).
The max_block_size is set in the on-chain epoch paramaters which cardano-db-sync stores in the epoch_param table. My db-sync is only synced to epoch 336 so I do not get the latest epochs:
select epoch_no, max_block_size from epoch_param where epoch_no >= 320 order by epoch_no ;
 epoch_no | max_block_size
----------+----------------
      320 |          81920
      321 |          81920
      322 |          81920
      323 |          81920
      324 |          81920
      325 |          81920
      326 |          81920
      327 |          81920
      328 |          81920
      329 |          81920
      330 |          81920
      331 |          81920
      332 |          81920
      333 |          81920
      334 |          81920
      335 |          90112
      336 |          90112
(17 rows)


text:
AMD64 Error Warning When Setting Up Grapgql Docker in Mac M1
I am following the following guide to set up graphql on my M1 Mac. https://github.com/input-output-hk/cardano-graphql#overview. All the containers are up and running but i can't visit local host to play around with graphql.The containers i am running have a amd64 warning error. Is there a way to get past this warning ? Has anyone else been able to setup cardano-graphql on M1 Mac?

Took me like 6+ Months to figure out all the requirements and what modules need to get loaded first...
This guide helped a lot https://robferguson.org/blog/2022/02/19/getting-started-with-cardano-graphql/
And he coverers building on mac.
These steps assume you have a docker GraphQL git environment already created and volumes ending in *_db-sync-data and *_postgres-data are empty. If you are tring to sync DB-Sync then remove Postgres and db-sync-data volumes. Ogmios data will be fine.
If you have data in  *_db-sync-data and *_postgres-data, please remove the data. We need a fresh state for all of this to work. See https://github.com/input-output-hk/cardano-graphql/wiki/Docker#rebuild-cardano-db for help. (If you use CGQL only select postgres)
1st
Start Ogmios and let it sync up to 80-99% depending on what
snapshot you download (I suggest waiting until its at least 95%
synced).
`Docker-compose up -d` then `Docker-compose down` finally
`docker-compose start cardano-node-ogmios`

This will only start Ogmios, wait a day or until you are at 70-90%.
2nd
Now we need to sync cardano-db-sync-extended. Go to the IOHK snapshot https://update-cardano-mainnet.iohk.io/cardano-db-sync/index.html#13/ (PS we are in folder 13/ right now, but look in 12/ folder for older snapshots) and choose the latest snapshot (if Ogmios is synced to 95%) or an older snapshot from folder 12/ if you are synced below 95%.
NOTE choosing a snapshot that is before that current sync point of Ogmios is fine, but getting a snapshot that is past Ogmios sync point will cause DB-Sync to delete any blocks past Ogmios sync point and can take a bit longer to delete then re-sync.
Syncing without a snapshot can take 3+ Days, I tried once and Ogmios was fully synced it took DB-sync 3 days to only get to ~70% and I have SSDs.
If you look at the Ogmios logs you should see one saying what slot & block it is currently at:
[3d54f2c4:cardano.node.ChainDB:Notice:2262] [2022-06-05 16:59:45.33 UTC] Chain extended, new tip: b57fbffcfccc13b56f0f869bf0b1dc699c4b020217ff9292d3504f56b83448bf at slot 62882094 {"severity":"Info","timestamp":"2022-06-05T16:59:45.341328986Z","thread":"3454","message":{"Health":{"tag":"HealthTick","status":{"startTime":"2022-06-04T13:55:56.922570134Z","lastKnownTip":{"slot":62882094,"hash":"b57fbffcfccc13b56f0f869bf0b1dc699c4b020217ff9292d3504f56b83448bf","blockNo":7337678},"lastTipUpdate":"2022-06-05T16:59:45.341113964Z","networkSynchronization":1.00000,"currentEra":"Alonzo","metrics":{"sessionDurations":{"max":0,"min":0,"mean":244854.64556962025},"totalMessages":6957619,"runtimeStats":{"currentHeapSize":2551,"maxHeapSize":10242,"gcCpuTime":522927267999,"cpuTime":5356749610627},"activeConnections":5,"totalUnrouted":0,"totalConnections":84},"connectionStatus":"connected","currentEpoch":343,"slotInEpoch":69294}}},"version":"v5.1.0"}
Which shows I am at Block: 7337678 and Blockchain Slot: 62882094
So I know I use the latest release "db-sync-snapshot-schema-13-block-7334319-x86_64.tgz" since 7337678 > 7334319.
Now we need to start DB-Sync:
There are 2 ways to do this.
One way is to let db-sync download the file from IOHK but there is a chance that the download can become interrupted and will not finish or continue after. (easiest but may not work..)
The other way is to manually download the snapshot and edit docker-compose.yml to have DB-sync load it from a local file instead of downloading(suggested)
Way 1 - not-recommended
export NETWORK=mainnet &&\ RESTORE_SNAPSHOT=https://update-cardano-mainnet.iohk.io/cardano-db-sync/12/db-sync-snapshot-schema-12-block-6764999-x86_64.tgz \ docker-compose up -d &&\ docker-compose logs -f Insert your snapshot link instead of mine.
Then wait ~2 hours and the download should be down and the system should start adding/altering tables in the DB-sync log.
If you see messages saying download was interrupted or stopped and it can not resume. Then try Way 2 and delete volumes *_postgres-data and .
https://github.com/input-output-hk/cardano-graphql/wiki/Docker#rebuild-cardano-db for help on removing volumes
Way 2 - Recommended
Navigate to container folder, then create a "snapshots" directory and give it access to all users (777).
Now we download the snapshot to "snapshots" using wget:
 wget https://update-cardano-mainnet.iohk.io/cardano-db-sync/13/db-sync-snapshot-schema-13-block-7334319-x86_64.tgz
Next, we need to edit docker-compose.yml, look for "cardano-db-sync-extended" then the volumes should look like this:
   volumes:
    - ./config/network/${NETWORK:-mainnet}:/config
    - db-sync-data:/var/lib/cdbsync
    - node-ipc:/node-ipc
    - db-sync-tmp:/tmp
    - ./snapshots:/snapshots

Finally at the bottom of Docker-compose.yml, look for and edit the Volumes array.
It should look like this:
volumes:
  db-sync-data:
  node-db:
  node-ipc:
  postgres-data:
  db-sync-tmp:

Now we can start DB Sync and Postgres
export NETWORK=mainnet && \ export RESTORE_SNAPSHOT=/snapshots/*FILE_NAME* && \ docker-compose up -d
which will start Postgres, Hasura, DB-Sync, GraphQL and Ogmios (if not already running).
Let DB Sync run for a day or so then it should be down unpacking. If you see anything saying that DB-sync is rolling back to genesis and the amount of block to be deleted is >2-5K then your snapshot was too far ahead and you need to wait for DB-sync to delete all those Blocks, before it uses to Hasura to continue syncing.
At this point, it might be worth it to restart the DB-sync process with older snapshot, But it is hard to say how long the deletion will take and depends on your system setup. If it is more than 5-10K of blocks that need to be deleted then I say re-start the DB-sync process with a older snapshot, or close DB-sync and wait for Ogmios to sync more.
GraphQL may come up with a fresh install after running the docker-compose up command from Github, but db-sync never fully syncs so it is never usable for me.
After DB-sync is done, if GraphQL port is still not online then restart the GraphQL module only and wait a day. docker-compose restart cardano-graphql
the GraphQL port and interface should come up after 1-3 hrs after DB Sync is fully synced and Ogmios is around 99-100%
Errors I saw
`psql:/tmp/db-sync-snapshot-hc6bN9lE7U/db-sync-snapshot-schema-12-block-6451499-x86_64.sql:238416086: ERROR:  could not extend file "base/16384/214298": No space left on device
HINT:  Check free disk space.
psql:/tmp/db-sync-snapshot-hc6bN9lE7U/db-sync-snapshot-schema-12-block-6451499-x86_64.sql:238416150: ERROR:  could not write block 35045 of temporary file: No space left on device
CONTEXT:  parallel worker`
https://robferguson.org/blog/2022/02/19/getting-started-with-cardano-graphql/
Be carful using docker image prune since it could delete your Ogmios data and add an extra day or two to the whole sync process. But normally the Check Free disk Space error is because the system can not unzip the snapshot because of space limitations.
Even if you should have enough space, I found that sometimes I needed to delete all my volumes to get it to work.
Background
Ive been trying to get GraphQL to work for months now... I've tried on a few different servers over the months, but I just recently have been able to get it online.
Also make sure your system has the requirement to run the full stack (32GB Ram needed and SSDs strongly encouraged):
https://github.com/input-output-hk/cardano-graphql/releases
Hope this helps and saves people some months like me XD


text:
When is Contract instance actually finished running?
I'm trying to write tests for my smart contracts.
I want to test if my contract has finished running by using this predicate:
-- | A 'TracePredicate' checking that the wallet's contract instance finished
--   without errors.
assertDone
    :: forall contract w s e a.
    ( Monoid w
    , IsContract contract
    )
    => contract w s e a
    -> ContractInstanceTag
    -> (a -> Bool)
    -> String
    -> TracePredicate
assertDone contract inst pr = assertOutcome contract inst (\case { Done a -> pr a; _ -> False})

But i'm getting this at the beginning of the test:
    Outcome of Wallet W872c:
      False
    Failed 'asserting contract is done'
    Test failed.
    Emulator log:
    [INFO] Slot 0: TxnValidate a43ac4a162e963b6ccdbece83f96cabefd53df73c8de6b242aedbeb2ca8b8f80
    [INFO] Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:

and at the end of the test:
    [INFO] Slot 5: 00000000-0000-4000-8000-000000000001 {Wallet W872c}:
                     Contract log: String "End of contract"
    [INFO] Slot 5: 00000000-0000-4000-8000-000000000001 {Wallet W872c}:
                     Contract instance stopped (no errors)
      src/Plutus/Contract/Test.hs:270:
      Check if contract is done

    Use -p '/Check if contract is done/' to rerun this test only.

1 out of 2 tests failed (0.19s)
Test suite myTests: FAIL

I have put: logInfo @String "End of contract" at the end of my contract so we can clearly see that all of my statements written in my Contract instance goes trough.
I was expecting assertDone to return me True, since no error was thrown, but I still got a False.
So the question is, why my contract is not producing Done output and is still waiting for input?
data Outcome e a =
    Done a
    -- ^ The contract finished without errors and produced a result
    | NotDone
    -- ^ The contract is waiting for more input.
    | Failed e
    -- ^ The contract failed with an error.
    deriving (Eq, Show)


text:
CNFT metadata structure
So I am working on a NFT minting and I checked the CIP-25 for metadata descriptions and I am confused regarding the naming of the NFT.
What is really the name of the NFT? (as in recognized by JPG.store) Is it the TokenName that is recognized by smart contracts or is it the name specified in the metadata?

For display purpose, people generally use the "name" attribute from the CIP-25 metadata, not the <asset_name>.
https://cips.cardano.org/cips/cip25/:
{
  "721": {
    "<policy_id>": {
      "<asset_name>": {
        "name": <string>,
        "image": <uri | array>
      }
    }
  }
}

Is the asset name attached to the TokenName variable used in smart contracts