text:
Error signer not found - txInfoSignatories
I'm trying to implement lock and withdraw of an NFT, but when I tried to check the signer on-chain with the function:
signer :: PubKeyHash
signer = case txInfoSignatories (scriptContextTxInfo ctx) of
            [pkh] -> pkh
            _ -> traceError "Signer could not be found."

It gets always signer could not be found. Why it is not found? It worked on playground until today, but I don't know if there were some updates on plutus.

Make sure the transaction has the correct required witness.

It worked on playground until today

It sounds like you had this working at some point but now you don't, what's changed? There have been no changes to that repo for a few days now. Try finding the exact commit that supposedly broke this.

when I tried to check the signer on-chain
Blockquote

If you're using a real blockchain network then perhaps you're using cardano-cli? You need to build a transaction with required-signer flag.

Maybe there was some change in some days ago, I have to check . because now in the playground, when the script has a validation with error, the transaction appears between the wallet in the same way, and in the other version the transaction does not happen because it is not validated. I don't understand... it does not make sense to change a lot of things.


text:
Meaning of Index of Redeemer in Serialization Lib 10.4
What is the meaning of the index in the redeemer ?
redeemer = [ tag: redeemer_tag, index: uint, data: plutus_data, ex_units: ex_units

for context see:
https://github.com/input-output-hk/cardano-ledger/blob/master/eras/alonzo/test-suite/cddl-files/alonzo.cddl
I think in Serialization version 9 it used to be the index of the inputs. There was even a method for getting the index of the input in the class Transaction Builder. But now in 10.4 this method is not longer available and in fact for the experiments i have done so far the index of the redeemer needed for the transaction to be validated by the node seems not to be the same as the index of the input in the transaction, so I have not a method for computing the index that i should attach to the redeemer.

did you figure this out .?

Yes, order them by alphanumeric... Y Not by the order they are added

I was digging in this topic because I struggled with some transactions. I was reading the CDLL, the serialization lib, docs, etc.. but I couldn't find anything about the meaning of this index.
After some research in the cardano node source code, I found that the index is referred to the TxIn but those must be ordered alphabetical.
Here is some code from the cardano-node:
    scriptWitnessesTxIns
      :: [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
      -> [(ScriptWitnessIndex, AnyScriptWitness era)]
    scriptWitnessesTxIns txins =
        [ (ScriptWitnessIndexTxIn ix, AnyScriptWitness witness)
          -- The tx ins are indexed in the map order by txid
        | (ix, (_, BuildTxWith (ScriptWitness _ witness)))
            <- zip [0..] (orderTxIns txins)
        ]

My problem was that I was using this index according to the add order with the add_plutus_script_input and add_input method.
I hope it helps.

What tool are you using to make the transactions?

I'm using the Cardano serialization lib and a own version of the cardano-js-sdk from IOHK

source: Stack Exchange

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

sort: votes


text:
How can I issue an operational certificate using cardano-serialization-lib?
Cardano Serialization Lib has this class:
export class OperationalCert {
  free(): void;
/**
* @returns {Uint8Array}
*/
  to_bytes(): Uint8Array;
/**
* @param {Uint8Array} bytes
* @returns {OperationalCert}
*/
  static from_bytes(bytes: Uint8Array): OperationalCert;
/**
* @returns {KESVKey}
*/
  hot_vkey(): KESVKey;
/**
* @returns {number}
*/
  sequence_number(): number;
/**
* @returns {number}
*/
  kes_period(): number;
/**
* @returns {Ed25519Signature}
*/
  sigma(): Ed25519Signature;
/**
* @param {KESVKey} hot_vkey
* @param {number} sequence_number
* @param {number} kes_period
* @param {Ed25519Signature} sigma
* @returns {OperationalCert}
*/
  static new(hot_vkey: KESVKey, sequence_number: number, kes_period: number, sigma: Ed25519Signature): OperationalCert;
}

How can I generate the KESVKey and the Ed25519Signature required for issuing an OperationalCert using this library?

There's no way, at the moment, to issue a stake pool operational certificate using cardano-serialization-lib.
I suggest using using cardanocli-js instead.
Like this:
const CardanocliJs = require("cardanocli-js");

const shelleyGenesisPath = "/path/to/your/testnet-shelley-genesis.json";
const options = {
  shelleyGenesisPath,
  network: "testnet-magic 1097911063"
};

const cardanocliJs = new CardanocliJs(options);

const nodeOperationalCert = cardanocliJs.nodeIssueOpCert(stakePoolName);

I do not think that Cardano-Serialization-Lib has KES key generation functionality. However, to create an OpCert, you only need the byte string of the KES verification key. If you've already generated the key, then you have the byte string (probably either in bech32 or CBOR format).
The op cert signature is an Ed25519 signature of the KES VKey, the sequence number, and the kes period all concatenated together (in that order) as a string of bytes. The integers are packed as 8-byte BigEndian vectors. The Cardano-Serialization-Lib does have an Ed25519 capability so generating the signature programmatically should be possible.
Update: libcardano is a C++ library that implements this capability. It is possible to pull C++ code into a Rust project if that is needed. Disclaimer: I am the author of libcardano.

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


text:
How can I generate a KES Signature using cardano-serialization-lib?
Cardano Serialization Lib has this class:
export class KESSignature {
  free(): void;
/**
* @returns {Uint8Array}
*/
  to_bytes(): Uint8Array;
/**
* @param {Uint8Array} bytes
* @returns {KESSignature}
*/
  static from_bytes(bytes: Uint8Array): KESSignature;
}

What Uint8Array should I provide to the from_bytes method to obtain a valid KESSignature?

I suggest using cardanocli-js to generate the KES signature file.
You can do it like this:
const CardanocliJs = require("cardanocli-js");

const shelleyGenesisPath = "/path/to/your/testnet-shelley-genesis.json";
const options = {
  shelleyGenesisPath,
  network: "testnet-magic 1097911063"
};

const cardanocliJs = new CardanocliJs(options);

const nodeKeyGenKES = cardanocliJs.nodeKeyGenKES(stakePoolName);


text:
API to get NFT Floor Price
Does anyone know of a public API that I can use to get the floor price for ALL Cardano NFT projects. I have created a Database listing all the Cardano NFT projects (currently there are just over 5000 NFT projects). I have tried https://api.opencnft.io/1/ - which works perfectly and is exactly what I need, however, their limit of 60 requests per min does not allow me to update my DB as the script fails after about 275 requests...

Since the only downside to using the opencnft api seems to be the rate limit, then perhaps you can reach out to them directly and ask for a raise to the limit?
Twitter:
@opencnft
@Kakulukian
I do notice, however, that there hasn't been any activity from either of the above Twitter handles since March 31st.


text:
Convert a script address to Shelley address using Plutus
I have this script address of the type Plutus.V1.Ledger.Address.Address.
Address {addressCredential = ScriptCredential 31559888de4dd413f20557ff39f616eb3e8a52d36528f88e6aef2f8d,
 addressStakingCredential = Nothing}

Is there a way to convert this to a ShelleyAddress of the format addr.. using Plutus?

Found the answer a while after posting this question. So, I am adding it here for reference. Using toCardanoAddress function from module Ledger.Tx.CardanoAPI conversion to ShelleyAddress can be done.
Example:
toCardanoAddress (Testnet $ NetworkMagic 1097911063) scriptAddress

You can unwrap the Either returned above if needed.


text:
How to query for active pool stake for an epoch from cardano-db-sync
I’m attempting to get the active stake value from cardano-db-sync for a pool at a specific epoch so I know how much stake it had for the next snapshot.
I’m currently using the following query
SELECT SUM(amount) FROM epoch_stake

WHERE epoch_stake.epoch_no = $1 AND pool_id = $2

This query seems to work, but my result is quite a bit off when compared to what cardanoscan.io shows as the active stake for the same pool.

Active stake is an instantaneous stake distribution at the current block (and can change with each new block) whereas the epoch_stake table gives the stake distribution for a single epoch.


text:
Starting to learn development on Cardano blockchain platform
I am Wim.
I want to develop dapps on the Cardano blockchain platform.
I have a little bit of programming experience in Java.
So i think i will start from scratch to learn Cardano and the development in its platform.
What is the best place to start to learn the whole chain (Cardano ecosystem to development of dapps with Cardano?
Is there an IDE for installing on a Windows PC that have all the features and the Haskall platform  to start learning?
So where do i start the learning path?
Thanks

Does this help you? https://cardano.stackexchange.com/a/4446/1231

In terms of IDE I think VS Code is used a lot https://code.visualstudio.com For example in the Starter Project see https://github.com/input-output-hk/plutus-starter You will soon learn that Haskell and pure functional programming is the approach with Cardano and Plutus so I recommend that you spend some time every day on Haskell.
Here is intro to Haskell for Plutus and again Visual Studio code is used.
https://www.youtube.com/watch?v=5b-YG558ft8
the developer portal also recommends http://learnyouahaskell.com

Start with the Cardano Developer Portal
It has enough hyperlinks to keep you occupied for a while :)


text:
Metadata transactions / eUTOX TTL / locking up ADA
I'm following this guide on metadata transactions with the cardano wallet server. My goal is to prove the existence of a given IPFS hash at a certain point in time. I don't need to send or receive ADA from anyone so as the guide mentions I'm sending 1,000,000 lovelace to myself. I have these two transactions (one & two) on testnet that have been in a pending state for >1 hour.
The first transaction shows ~900 ADA coming from one of my addrs and then 1 ADA going to my address that I specified and then the remainder going to another addr in my wallet. The second transaction is similar but has 3 inputs and 2 outputs.
I'm trying to understand how the eUTXO model works in this situation, I understand that I'm getting all of the ADA back but while these transactions are pending I apparently can't spend anything because I tried a third transaction but it failed saying I don't the 1 ADA required. After some more research I see that I should've specified a TTL so that it doesn't take forever but I have a few questions about how I should I approach this.

Why is the lockup inconsistent? I only need 1 ADA + fee, so why did the first transaction lock up 900 ADA and then the second locked up the remaining ~90? If it is ok with 90 is it possible to specify a smaller number?

What's with the hour long pending state? I have over 150 confirmations, is this due to congestion on testnet? Any suggestions on a TTL for this type of transaction?

The wallet provides several addresses for privacy but in this application design I don't want privacy, the intention is to make the metadata public so it really shouldn't matter what address I use as long as its consistent right? Is there a typical method for selecting an address for public transparancy or just pick the first one?

EDIT
Just a moment ago I realized my local node was showing it was 99.8% synced and I just sent another transaction that updated to in_ledger status really quickly so I'm guessing the sync was why I was seeing the pending status for so long on my local node but I'm still interested in questions 1 & 3 above.

Seeing as you've solved the mystery around the pending state transactions I will try my best to answer questions 1 and 3.
Question 1: Inconsistent Lockup of UTXOs
Wallets use CIP 2 - Coin Selection Algorithms for Cardano to decide which UTxOs to consume.

There are two main algorithms used by Cardano Wallet:

Largest-First
Random-Improve

In general, Cardano Wallet gives priority to the Random-Improve algorithm, as experimental evidence shows that it
performs better at minimising dust and maintaining a UTxO set with
useful outputs. (See Self Organisation in Coin Selection for more
details.)
However, in rare cases, the Random-Improve algorithm may fail to produce a result. In such cases, Cardano Wallet will fall back to the Largest-First algorithm.

Looking into the transaction history here I can see that the wallet had a limited set of UTxOs to work with, one output with 900 ADA, one with 90 ADA and single ADA outputs here and there. In this case it looks like the random-improve algorithm selected the 900 ADA UTxO first.
Given this knowledge, it does make sense to have multiple evenly distributed UTxOs available for your wallet if you need multiple concurrent transactions between blocks. Wallets like Eternl do this with their "Advanced UTxO Management" feature.
Question 3: Addresses to Use if Privacy isn't needed
Yes it doesn't matter which address you use, as the wallet will always have full control to spend UTxOs across its previously derived addresses. For example wallets like Nami always use the first derived address. It is also worthwhile mentioning that there is no privacy between transactions if all your derived addresses use the same staking key, which is the case for most wallets today. An thread from reddit highlights this.

Great, thanks for the info! When my node is synced the transactions settle in ~30 sec so it won't be an issue but just for my understanding; I think I get why the cardano-wallet has the utxo distribution endpoint now. I'm currently using a high level API that simplifies transaction building but if I wanted more control I could use a lower level client and use one of the algorithms you mentioned or implement my own utxo selection method? It doesn't really matter when transactions are expected to settle in a short period but for certain smart contract durations it might end up being important.

Yeah for ultimate flexibility there are already quite a few options around lower level SDKs or clients depending on the tech stack you are using. I personally find cardano-wallet to be a tad heavy-weight and opinionated so I use cardano-cli for ad-hoc transactions and CardanoSharp with my C# code.


text:
One node surprisingly running out of disk space
I had two cardano-node instances running via kvm on one physical machine.
Both nodes were running on mainnet for a while before I switched them over to testnet (to prepare for turning these into a stake pool).
I gave both environments (labelled BlockProducer and Relay) the same resources, incl. 150 GB of disk space.

When logging into both environments, I noticed that BlockProducer's cardano-node process crashed with a FileSystemError, stating that there is no space left on the device.
Restarting the process (also after rebooting BlockProducer) did not change this.

These are the outputs for df -h and du -h -d 1 in the respective cardano-node directories. Left is the (working) Relay, while the right side shows the BlockProducer environment.
The host system running the kvm daemon still has 210 GB of available disk space.
Did I simply under-provision the virtual disks or what is going on here?
Why is Relay still running though? I installed the same software and configured both environments the same.

Disk space issue:

Each system only has 73GB maximum on / (which is where you are running from).
The live Cardano chain is now 50GB on it's own. I'm not sure of the testdb size.
Make the / volume larger on each system eg 120GB maybe.

Differences between BP and Relay system:

The BP system has used 70GB of / while the Relay has used 65GB of /
So, what has used the extra 5GB somewhere on the BP system?
Left over logs or code?
cd to /home and do a 'du -h .' there to see if you can spot if the space has been used by a different user.
If not obvious there then you will need to review other directories off of / to narrow down where the extra 5GB has been used.
Often /var/log can use a lot of disk space logging things.
Also check /tmp

That's the thing though, I provisioned 150 GB for each of the environments.

Yes, the whole environment may be 150G, but as @MC_Brisbane points out, the partition where the node is storing its data is smaller.

You need to find out which files are filling up the disk.
A command like:
find / -type f -printf "%15s    %p\n" | sort -nr | head -30;

might help.


text:
Best ways to create UTxO snapshots at epoch boundary
I would like to create snapshots of the set of UTxOs at the end of each epoch for a particular address.
What would be best ways to do something like that?
Constraints/ Ideas
The current tools I am aware of is just querying the address' UTxOs using the cardano-cli. But I'd like ensure that I get the exact UTxO set of a specific address at the start of the next epoch and using the cli seems error prone since rollbacks may happen or my node may not have all UTxOs synched during epoch boundaries.

A relatively simple bit of SQL should allow you to grab this from cardano-db-sync. IN the git repo there is a file doc/interesting-queries,md that may give some clues.

Thanks to Erik I've found a query for historical queries for a UTxO set of a specific address that can be found here:
Get historical UTxO set for given timestamp


text:
How to calculate Sundaeswap TVL using DB-sync?
I'm trying to do an exercise where I see if I can calculate Sundaeswap TVL using DB-Sync.
Below is what I have managed to pull out from the database so far regarding Sundaeswap.
However for the UTXOs in the tx_out table I would have expected the payment_cred (which is described in the docs as " For a script-locked address, this is the script hash." to match the script hash. However it doesn't so I'm not sure how to determine the total number of UTXOs locked by Sundaeswap.
Link to the transaction below in case you need it

Ok I wasn't able to reconcile the above but I did find that DeFiLlama post the code they use to calculate TVL (see the Check the code button here: https://defillama.com/protocol/sundaeswap)
So using this I was able to discern the addresses different DApps use and so tracking those intead.


text:
How to determine the order of transaction input (in the order of the TxIds)?
If I have the following transaction:
cardano-cli transaction build                 \
--tx-in dd3dbc1cbd4627da3b74fae8c7bcc3f05f3b41ec36feb33f81cf885390b634d6#0      \
--tx-in 40917b278a9bf960fcc0a3de9eb5945113c025323d7d73c19dd6d26cfe92e04b#0      \
--tx-in e98a07b5ff0b048950ce4ffdfbfb53def61e2b52e9bf39cdd82b3eb91c40e2a6#0 \
--tx-in-script-file plutus/order-v11-buy-token.plutus   \
--tx-in-datum-file 'tmp/batch_datum_file_0.json'   \
--tx-in-redeemer-file 'plutus/match-order-redeemer.json'  \
--tx-in 2c759a6606692c021c266025cbd569a1b451e184fb44e001d18152528a3a2161#0 \
--tx-in-script-file plutus/order-v11-buy-token.plutus   \
--tx-in-datum-file 'tmp/batch_datum_file_1.json'   \
--tx-in-redeemer-file 'plutus/match-order-redeemer.json'  \
--tx-in cfbf555aebbf879e2313c32f4d8b839d63d7f7b12fd1027cb3ccd7e9f790e014#0 \
--tx-in-script-file plutus/order-v11-buy-ada.plutus   \
--tx-in-datum-file 'tmp/batch_datum_file_2.json'   \
--tx-in-redeemer-file 'plutus/match-order-redeemer.json'

I am getting the following error:
Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with:
The Plutus script evaluation failed: An error has occurred:  User error:
The provided Plutus code called 'error'.
Script debugging logs:
the script for transaction input 4 (in the order of the TxIds) failed with:
The Plutus script evaluation failed: An error has occurred:  User error:
The provided Plutus code called 'error'.

How to realize which scripts reported the error, it is saying the script for transaction input 0 and the script for transaction input 4 but with the above command, I cannot find on tx-in position 0 any script. How to determine the order of transaction input (in the order of the TxIds)?

Looks like all --tx-in is not in the order like it is provided in cardano-cli command and rather is order ascending by transaction id.

Not very intuitive behavior. Where did you find that answer?

I just guess it, and then I did sort utxos and that proved my assumption.

I created a PR in the cardano-node repo to make the errors more explicit: https://github.com/input-output-hk/cardano-node/pull/3811


text:
How to Count plutus transactions?
i'm connected to the cardano-db-sync, someone knows how to count the ammout of transactions that use plutus script?
i'm using two methods here
select block.epoch_no,
count(distinct tx.id) as txs_in_epoch,
sum(case when script.type = 'plutus' then 1 else 0 end) as txs_on_plutus_contracts

from tx inner join block on block.id = tx.block_id
left join redeemer on tx.id = redeemer.tx_id
left join script on redeemer.script_hash = script.hash
where epoch_no = 298
group by epoch_no

diff

count(distinct tx.id) as txs_on_plutus_contracts
from...
where script.type = 'plutus'


text:
Type PaymentPubKeyHash not found
I have the following datum type
data ProjectSubmitDatum = ProjectSubmitDatum
  { vProjectOwner :: PaymentPubKeyHash,
    vProjectRegistrationFee :: Integer,
    vProjectCategory :: BuiltinByteString,
    vFundPayIdentifier :: PaymentPubKeyHash
  }
  deriving (Show)

I also have the module imported like this
import Ledger.Address

The following error pops up when i run cabal repl
src/QuadraticVFSC.hs:45:19: error:
    Not in scope: type constructor or class ‘PaymentPubKeyHash’
   |
45 |   { vFundOwner :: PaymentPubKeyHash,
   |                   ^^^^^^^^^^^^^^^^^

you need to import either the whole module like this:
import Ledger

or the specific type like this:
import Ledger (PaymentPubKeyHash)

Still not working when i import the whole module. When i was importing specific type it said it does not export PaymentPubKeyHash.

Also check you have the right git commits (precisely the commit of plutus-apps as found in the cabal.project). PaymentPub... is relatively new. It used to just be Pub...

If it can’t be found, you most probably have an older version of plutus-apps. You can change the tags in the file cabal.project.

You neeed to import PaymentPubKeyHash it like the following:
import Ledger.Address qualified as Address                      (Address, PaymentPubKeyHash(..))
This works for me and you can checkout my working code on testnet here:
https://github.com/lley154/cardano-lottery/blob/main/src/OnChain.hs
Cheers,
Lawrence


text:
How to create a Cardano private network
I need help with a project proposal, but I think this topic could be interesting for many developers and architects.
Does somebody know how to start to build a private Cardano network or where I can find some tutorials?
The idea would be to build a sidechain as layer two, which utilizes the token of the mainnet as the native coin.
Does the idea have sense? Is it possible? Any suggestion?
Many thanks,
Valerio

For what use do you need it? I think you have two options, either utilize hydra which facilitates isomorfic state channels. Or you could setup a side chain just like cardano.

Alternatively/additionally, check out the Making a Shelley Blockchain from Scratch repo.

The easiest way to create a cardano private network (IMHO) is to clone the cardano-node git hub, start up nix shell, and from there you can start a local cluster.   Works well for me I have a used it many times.
git clone https://github.com/input-output-hk/cardano-node.git
Once nix is completed, you will see the following and type start-cluster
Commands:
    * nix flake lock --update-input <iohkNix|haskellNix> - update nix build input
    * cardano-cli - used for key generation and other operations tasks
    * wb - cluster workbench
    * start-cluster - start a local development cluster
    * stop-cluster - stop a local development cluster
    * restart-cluster - restart the last cluster run (in 'run/current')
                        (WARNING: logs & node DB will be wiped clean)

I also included some tips on how to transfer ada from the gensis address etc. if that would be helpful.  You can go to the tips and tricks section of my readme on The Open Source Cardano Lottery project I created.  https://github.com/lley154/cardano-lottery


text:
How to convert from cborHex to VRFKeyHash using both cardanocli-js and cardano-serialization-lib?
I'm using cardanocli-js to create both VRF files for running a stake pool: vrf.vkey and vrf.skey:
const vrfKeyAccount = cardanocliJs.nodeKeyGenVRF("Totem");

Then I want to read the vrf.vkey file and convert the cborHex value to VRFKeyHash format, from the Cardano Serialization Lib. For that, I do:
CardanoWasm.VRFKeyHash.from_hex(JSON.parse(vrfKeyFile).cborHex);

But I'm getting the following error:
/cardano-multiplatform-lib/rust/pkg/package/cardano_multiplatform_lib.js:16780
    throw takeObject(arg0);
    ^
JsValue("Deserialization failed in VRFKeyHash because: Invalid cbor: expected tuple 'hash length' of length 32 but got length Len(34).")
(Use `node --trace-uncaught ...` to show where the exception was thrown)

I have checked that every cborHex on vrf.vkey files starts with the prefix "5820" and every cborHex on vrf.skey files starts with the prefix "5840". If I remove those prefixes from the conversion, then it works:
CardanoWasm.VRFKeyHash.from_hex(JSON.parse(vrfKeyFile).cborHex.substring(4)));

Maybe this could help,
as cborHex is in hex, and you can pass a Uint8Array (bytes) to initialize a VRFKeyHash like in many cardano-serialization-lib objects, in theory you can use Buffer.from(hexValue,"hex"), like this:
CardanoWasm.VRFKeyHash.from_bytes(Buffer.from((JSON.parse(vrfKeyFile).cborHex,"hex")));

not tested!


text:
Query assets with cardano-cli
So as the title says, I really need some help to query all the assets from a wallet address with the help of the cardano-cli.
So far I've got the cardano-node running with docker.

You can use cardano-cli query utxo --address <ADDRESS> --mainnet to check all UTXO's sitting at ADDRESS. ADA balances and policy/asset IDs will be output to STDOUT in the command line.

cardano-cli: Network.Socket.connect: <socket: 11>: does not exist (Connection refused)%  This is what it says when I do it in a terminal on a fresh start.
If I start cardano-node in another terminal it outputs : Command failed: query utxo  Error: This query cannot be used for the Byron era
I'm using this address: addr1q9klhtnsdqfmpfcdwxt426s2m489alzj8p55z8lq5p9a8e6uqudkzzl0x4pq0q79tx9ghxgcfkjtkugcx7qs0j445fpseuuu33
I run cardano-node with the following command:
sudo docker run -e NETWORK=mainnet -v cardano-node-ipc:/ipc -v cardano-node-data:/data inputoutput/cardano-node

Run cardano-cli query tip --mainnet and please comment whatever the terminal outputs. If you get an error, comment the error.

{     "era": "Byron",     "syncProgress": "32.67",     "hash": "7149c856efa86edf5c8059fdf27fb81e2c77d53e62b2ad3357e3678566615a8f",     "epoch": 110,     "slot": 2386495,     "block": 2384996 }
Thanks for your help by the way! Appreciate it

Your node is still syncing, and it is in the Byron era. In Byron there were no shelley-format addresses (ones that begin with addr1), so you can't query them because they don't yet exist in your local copy of the chain. Wait till the node is fully synced and then try the query utxo command again.

Thanks that worked! Now I'm getting this: `query utxo --address addr1q9klhtnsdqfmpfcdwxt426s2m489alzj8p55z8lq5p9a8e6uqudkzzl0x4pq0q79tx9ghxgcfkjtkugcx7qs0j445fpseuuu33 --mainnet
TxHash                                 TxIx        Amount
`
Am I doing something wrong? I know the address has something, I've checked on pool.pm

I'd recommend understanding how Hierarchical Deterministic (HD) wallets work in Cardano. Originally introduced in BIP-32, HD wallets allow for a virtually infinite number of addresses to be created from a single wallet/account. Cardano wallet software like Daedalus/Yoroi automatically link these addresses with a single stake key, which is what pool.pm queries. Check the UTXO distribution of your wallet here: https://cardanoscan.io/address/016dfbae706813b0a70d7197556a0add4e5efc523869411fe0a04bd3e75c071b610bef35420783c5598a8b99184da4bb7118378107cab5a243

So how do I do to link these addresses? I'm very confused.
With a single stake key I should be able to query one's wallets?
Why would that specific wallet be empty?

The address you are querying in your example is one of the addresses in your wallet that was used at some point in the past. Now, that address is empty (no UTXOs in that address), but other addresses in your wallet (all linked to the same stake key) or not empty. When you use wallet software like cardabno-wallet or Daedalus to send assets, it automatically selects non-empty addresses for you, but when you query them manually with cardano-cli, you must do so for each individual address.

How can I get all the adresses from a stake key then?

Also, can assets with the same policy id be spread into different wallet addresses within the same stake key?

I'd recommend refining your understanding of how addresses and wallets work in Cardano using this resource: https://input-output-hk.github.io/cardano-wallet/concepts
Start with "Key Concepts", and use other sections as needed. After working through these docs you should have a better understanding of how things work and what/how can be done. Lmk if you have questions

I have read Key Concepts, and some article about Stake key and Stakes/Stake holders. I'm still very confused with the Stake concept.
For context, what I wanna do is to be able to query something that a user give me, to get all the asset of one policy id from that.
So what should the user give me to query, and how should I query that? Should he give me a Stake key of some kind?


text:
Contract is not stopping execution if validation script fails (happened after 2022-04-06 PAB Release)
Before the 2022-04-06 PAB Release Contracts used to stop execution after validation script failed the transaction sent by submitTxConstraintsWith, but after this release Contract is not stopping its execution anymore and it's just proceeding to the end.
The suspected change which caused this changed behavior is this one https://github.com/input-output-hk/plutus-apps/pull/360/files
I need to update our code base to accommodate this recent change in behavior in Contract monad.
ledgerTx <- submitTxConstraintsWith @Void lookups tx
logInfo @String $ "In case if validation fails, this line was not reachable before 2022-04-06 release, but now it is"

There is some logic follows after submitTxConstraintsWith called, that logic should not be executed in case if validation script fails.
What would be the best way to check if validator script failed the transaction to throw an error and make the Contract return?

Found the way to address this problem
    statusChange <- awaitTxStatusChange . getCardanoTxId $ ledgerTx
case statusChange of
    Committed TxInvalid () -> logError @String "Transaction failed"
    Committed TxValid -> logInfo @String "Transaction successful"
    _ -> logInfo @String "something else"


text:
Cardano Node Causing Browser Errors
I am not a developer, just a hobbyist.
I installed the Cardano Node (1.33.0-win64) so that I could point my Nami Wallet Browser Extension to it, rather than the web server node Nami points to by default. Ever since installing the node, I get browser errors that reference the Cardano Node and  "WebAssembly.instantiateStreaming" (full console error from dev tools below). Just visiting websites is all it takes to get the errors.
Can someone help me learn more about this, and perhaps point me in the direction to a solution? I could just uninstall the node, but I want to solve the issue.
Thank you!
cardano_serialization_lib.js:13074          GET https://www.google.com/wasm/csl-v10.0.4.wasm 404
cardano_serialization_lib_init @ cardano_serialization_lib.js:13074
(anonymous) @ CardanoSerializationLib.ts:11
(anonymous) @ CardanoSerializationLib.ts:15
(anonymous) @ dom-script.js:27
(anonymous) @ dom-script.js:27
cardano_serialization_lib.js:12883 WebAssembly.instantiateStreaming failed because your server does not serve wasm with application/wasm MIME type. Falling back to WebAssembly.instantiate which is slower. Original error:
TypeError: Failed to execute 'compile' on 'WebAssembly': HTTP status code is not ok
load @ cardano_serialization_lib.js:12883
await in load (async)
cardano_serialization_lib_init @ cardano_serialization_lib.js:13079
await in cardano_serialization_lib_init (async)
(anonymous) @ CardanoSerializationLib.ts:11
(anonymous) @ CardanoSerializationLib.ts:15
(anonymous) @ dom-script.js:27
(anonymous) @ dom-script.js:27

Your browser or extension is trying to get the wasm code.
Your error shows GET https://www.google.com/wasm/csl-v10.0.4.wasm 404
The 404 result means 'not found'.
I found this reference: https://github.com/Emurgo/cardano-serialization-lib/issues/398
Do you have Eternl wallet extension installed in your browser? Seems that it is using the wasm URL above and failing, so best to disable Eternl wallet extension and try again.
Keep in mind that browser extensions inject their code into every page that you visit, so if one extension is not working correctly the impact will be felt on every page that you visit.

I think this issue is being tracked on https://github.com/ccwalletio/tracker/issues/119. It is a pretty major bug introduced by this Wallet Browser Extension.

I disabled Eternl and that totally eliminated the error message! I thought it was the node this whole time. Thank you so much.


text:
How to define decimel points while minting tokens?
I am minting some tokens on the testnet by following the instructions in at this document. https://docs.google.com/document/d/1gyIOEjxhGhlXsgPtM35DsY3QX02jxLwZSpek7zO4q7M/edit
Everything is working fine and i am able to do the transaction to my daedalus wallet which is running in my local system.
I have minted a token count of 1000 I am able to sent the token of

1.12(Two decimeal places)

What i want to do is this I want to sent a token count of

1.123456 (Six decimal places after the dot)

I am not sure how can i achive this. Any idea?

Not quite finalised, but CIP 38 is probably what you're looking for. You define the "decimals" value on-chain in your minting tx metadata.
See: https://github.com/cardano-foundation/CIPs/pull/137
The way its achieve before this is off-chain by registering your token with that information here in the token registry:
https://github.com/cardano-foundation/cardano-token-registry
In general there is technically no difference between tokens with and without decimals (except for the amount in existance), it's only a matter of interpretation - so its really just about educating the consumer of the tokens about how many digits to interpret as decimals.

I need to test this before working on mainnet do the above mentioned stuffs will work for test net as well?

Yes, here's the off-chain registry for testnet: https://github.com/input-output-hk/metadata-registry-testnet

if i specify decimal places here will i be able to sent 1.123456(Six decimal) Tokens from wallet?

Yes. Technically you'd be sending 1123456 tokens - just like 1 Ada is sent as "1000000 Lovelace". It's up to the wallet to implement your token decimals in the user interface, but most wallets will respect this no problem. Nami for example will.


text:
Cardano CLI - Cardano Transaction Build for NFT from Guide Docs
As per title, want to ask about cardano-cli transaction build for NFT, that I read on this guide or maybe this one
On near the last step, where it says about Minimum required UTxO - I wonder, if we can automatically handle it, so we don't need to change the variable of that minimum UTxO (yes, minimum UTxO, NOT Minimum Fee).
Is that possible? If yes, what command / option needed on that particular case?
Reason is, if we want to build, like a single command (or automation), to mint an NFT, we couldn't, since we don't know for sure if the Minimum required UTxO is enough (which, 1.4 ADA) or not.
Example, what if, suddenly, it's more than 1.4 ADA? We do need to change it manually, then hit it again. Which I think, it's a hassle.
Thanks!

The minimum Ada value is defined in the protocol parameter here: minUTxOValue
So, you can query the network via cardano-cli to dynamically get the minUTxOValue.
cardano-cli query protocol-parameters --mainnet
From the docs:
https://docs.cardano.org/native-tokens/minimum-ada-value-requirement
Case 1: Token bundle B in the UTXO u contains only ada (no other tokens) minAda (u) = minUTxOValue
Case 2: Token bundle B in the UTXO u contains ada as well as other tokens minAda (u) = max (minUTxOValue, (quot (minUTxOValue, adaOnlyUTxOSize)) * (utxoEntrySizeWithoutVal + (size B)))
Related links here:
Calculation of transaction fees
https://adapools.org/protocol-parameters

Hi! thanks for the hint! I'm super confuse, as they had 2 (or maybe more) official docs. *back to the topics. I wonder, if there's a more simpler terms for this kind. Since, when I try to look on the parameter. For example, when I do cardano-cli query protocol-parameters --testnet-magic 1097911063 --out-file protocol-parameters.json, and look for a variable named adaOnlyUTxOSize - I couldn't found it. So, I think, I kinda lost in their terms etc.

*To add, a little, in my case, where I just want to mint test NFT, based on docs is it Case 2 calculation?

The addOnlyUtxOSize is just a variable in the case above, so you wont find it in the network protocol parameters.   Here are 2 examples of where minAda is calculated.  I haven't tried these, so only providing them as reference.

https://github.com/gitmachtl/scripts/blob/69a584fc2b0b285c6e03fedfb4109daad8085502/cardano/testnet/00_common.sh  - line 483

https://github.com/dendorferpatrick/nami-wallet-examples/blob/master/src/nami-js/coinSelection.js

Hi! Thanks for the reference! The first one seems is the closest one that I'm looking for. It's kinda complicated for new devs like me to get an insight, but I think it's the answer that related to my question (although it's complicated). Thanks again! :)


text:
Using Endpoints in a PAB Schema
I am trying to find a way to integrate endpoints from a native token staking contract and implement them into the PAB. I am assuming I will heavily be using the getSchema instance. Like so:
instance HasDefinitions StakingContracts where

    getDefinitions        = [Monitor exampleAddr]

    getContract (Monitor addr) = SomeBuiltin $ Monitor.monitor addr

    getSchema = const $ endpointsToSchemas @Empty

My endpoints schema look as follows:
type StakingSchema = Endpoint "feed"       MainToken
                 .\/ Endpoint "register"   ()
                 .\/ Endpoint "unregister" ()
                 .\/ Endpoint "deposit"    MainToken
                 .\/ Endpoint "withdraw"   MainToken
                 .\/ Endpoint "claim"      ()
                 .\/ Endpoint "compound"   ()

What I do not understand is how to tell the PAB's getSchema to use these endpoints I have tried:

    getSchema = const $ endpointsToSchemas @feed

    getSchema = const $ endpointsToSchemas @StakingSchema

But none have worked. I feel like there is an easy solution here, but I am just not seeing it. Furthermore, documentation on PAB is scarce and so I cannot find anything online to help. Any help here would be greatly appreciated!

Here is my code I used to setup the PAB contract instances which works for the PAB simluator.
    getDefinitions = [ InitLottoContract, UseLottoContract ]
    getSchema =  \case
        InitLottoContract    -> Builtin.endpointsToSchemas @LottoInitSchema
        UseLottoContract     -> Builtin.endpointsToSchemas @LottoUseSchema

    getContract = \case
        InitLottoContract    -> Builtin.SomeBuiltin initEndpoint
        UseLottoContract     -> Builtin.SomeBuiltin useEndpoint

A word of caution though, the PAB is great for development and the simulator, but will run into challenges getting it to work on the testnet and it doesn't work on mainnet.
https://github.com/lley154/cardano-lottery/blob/main/app/LottoContract.hs

Thank you so much for your comment. Your code is interesting and I am trying to understand. Where do your endpoints come from? As in, what contract defines them? When I tried "getSchema = const $ endpointsToSchemas @StakingSchema" it didn't work and I am wondering why yours is different. Also, week06 of PPP connected PAB to testnet. Is it that much more difficult to do that again? I am unsure how to make a production level Dapp with endpoints without using the PAB.

The initEndpoint and useEndpoints are defined in the Offchain.hs file here: https://github.com/lley154/cardano-lottery/blob/main/src/OffChain.hs  (look at the bottom of the file)

In my source code I also give examples of how to interact with plutus scripts using shell scripts for devnet, testnet and mainnet.   It is one approach, there are other ways as well (eg cardano-serialization lib).

The issues I faced using the the plutus PAB on the testnet was that it take 3+ days to sync the chain index, which took a tones of memory.  The plutus PAB also uses the same wallet password for all wallets which you can make work by having all password the same, but this is odd.

and when I was ready to actually run in on the testnet, I needed to pivot and do it the way it will actually work on mainnet, so a lot of wasted effort there.

Also, check out the following as well for some other Dapp connector approaches.  https://plutus-community.readthedocs.io/en/latest/#Related/Utility/Dapp_Connector/

@lley154 What issue did you face on mainnet compared to testnet?

currently, the PAB when connecting to the cardano wallet needs to use the same password for different wallets. I discovered this during my testnet testing and would also apply to mainnet, so there is no way this will work for mainnet.   You can also see that in the latest plutus videos (https://www.youtube.com/watch?v=zUerLu_GOQs) the production deployment scenario is about creating and then deploying plutus scripts - no mention of using the plutus PAB.   This may change in the future, but was my practical experience working with plutus in the last few months.


text:
cardanocli-js and cardano-wallet-js vs cardano-wallet rest api and cardano-graphql how do they differ?
I've been going through the cardano docs at https://developers.cardano.org/docs/get-started/ and have come across discussions around the cardano-wallet rest api and cardano-graphql implementation.  I also saw that there are implement js implementations for cardanocli and cardano-wallet.
I'm currently playing with the platform but eventually I'm planning on building a service in React.  What's the difference between the different interfaces and which is best to use?
For context I'm playing with a few ideas around minting ntf's and creating a new coin.

I would recommend you to checkout https://github.com/StricaHQ/typhonjs, which is a pure js Cardano wallet library, which will be sufficient to creating mint transactions and much more

cardano-rest-api & cardano-graphql are backend components that you can use to run your own infrastructure to read data from the blockchain or submit transaction to via the rest api. Graphql, I believe is required to run in combination with cardano-db-sync.
cardanocli-js and cardano-wallet-js are JS libraries that correspond to cardano-cli and cardano-wallet.
The cli can be used to create transactions manually, make queries against a cardano node instance for retrieving infos of addresses or also to generate verification and signing keys for payment or staking.
The wallet is primarily concerned about allowing to create/ restore HDR wallets based on mnemonic phrases.
I recommend reading the docs for each for more info.


text:
How Do I Deploy a Wallet Connector to the Website in a Safe Way
If I want to start making a program that connects to the user's web wallet, such as nami in the google chrome browser, how do I ensure the security of the connection?
Using Nami and Google Chrome are just examples and can be replaced with an arbitrary wallet and browser, the real question here is what are the best practices I should stick to in order to make sure the connection is not taken advantage of easily by bad actors (black hat actors).
Do I install special plugins/extensions into the website?

Here is an example using Nami and blockfrost for you to review:
https://github.com/dendorferpatrick/nami-wallet-examples
Another smaller example:
https://www.npmjs.com/package/nami-wallet-api/v/1.1.9
In general, all wallet content will be viewable once the user allows for a website to 'connect'. Sending assets will obviously require the user to enter the wallet spending password which is used to ultimately sign the transaction.
('wallet content' above isn't quite right as really it's assets and transactions from the actual blockchain for this wallet address).
My understanding is that wallet interaction is all on the client side. The wallet code gets injected into the page during/after loading.
So nothing sensitive needs to be sent back to your web server and you do not need to handle the spending password. You could choose to send back to your web server whatever information that you want from the wallet but this is already publicly available information for that particular wallet address.
So if a wallet has allowed a website to connect and that website is controlled by a bad actor they could try to initiate a sending out of assets and the wallet will automatically prompt the user for their spending password (this is built into the wallet and out of control of you or the bad actor).
If the user is not paying much attention they might just enter their password without thinking about it - hard to know what percentage of people would do this.
Is their a particular scenario that you have in mind?


text:
Getting errors when using cardano-wallet-js --> Can't resolve 'fs'
I've been going through the cardano docs at https://developers.cardano.org/docs/get-started/cardano-wallet-js to test the interface.  I installed the package using npm without issue and am starting with including the package in my project using:

const { WalletServer } = require('cardano-wallet-js');

When I save i get the following error:
Compiled with problems:X

ERROR in ./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js 16189:14-40
Module not found: Error: Can't resolve 'fs' in 'C:\Users\Greg\Documents\crypto-app-test\node_modules@emurgo\cardano-serialization-lib-nodejs'

I originally had a number of errors which were fixed by installing various packages.  I tried doing the same with the fs package but that did not resolve the issue.
I am on a windows 10 virtual machine using the following:
vs code v1.76.1
node js v16.14.2
react v18.1.0
cardano-wallet-js v1.4.0
cardano-serialization-lib-nodejs v10.0.4
i took a look at the fs package and it seems to be abandoned or deprecated and has the following info in the readme:

Security holding package
This package name is not currently in use, but was formerly occupied
by another package. To avoid malicious use, npm is hanging on to the
package name, but loosely, and we'll probably give it to you if you
want it.
You may adopt this package by contacting support@npmjs.com and
requesting the name.

I do have a running wallet server running on another machine but haven't gotten to the point of trying to connect to it through this js package.  Anyone know what's going on here?


text:
How to get NFT count of wallet address
I'm wanting to display the NFT count of a wallet on my website. I've gone through the blockfrost SDK and I don't see anything that relates to NFTs. Is there a method to return this value?
Here is my code which currently returns the ADA amount:

        const Http = new XMLHttpRequest();
        const url = 'https://cardano-mainnet.blockfrost.io/api/v0/accounts/stake1u9r0sh6hl6csxt90k5ueh5pl404r6qs995kjnzmp8u3mr2csgg2q8';
        Http.open("GET", url);
        Http.setRequestHeader('project_id', 'mainnetxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
        Http.send();
        Http.onreadystatechange = (e) => {
            if (e.currentTarget.readyState == 4 && e.currentTarget.status == 200 && e.currentTarget.responseText != '') {
                var stake = (parseFloat(JSON.parse(Http.responseText).controlled_amount) / 1000000);
                console.log(stake)
            }
        }

Thanks for any help!

I recommend not sharing your project id publicly since it serves as API key so anyone can make requests in the name of your account using this id.

You'll probably need two steps for this.
First, fetch all assets at the stake address using this endpoint:
https://cardano-mainnet.blockfrost.io/api/v0/accounts/{stake_address}/addresses/assets
(documented here: https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1{stake_address}~1addresses~1assets/get)
Then filter all but those with a quantity of "1" (technically all tokens are identical, but NFTs should only exist with a quantity of "1").
Just counting these could already be enough for a rough counter on a website.
But the next step would be to check that only one of each of those token is in existance and the metadata suggests it is actually an NFT.
So you can look up each of those assets using this endpoint:
https://cardano-mainnet.blockfrost.io/api/v0/assets/{asset}
(documented here: https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets~1{asset}/get)
If this lookup also shows a quantity of "1" exists and the "onchain_metadata" is populated (with fields from this NFT metadata standard https://cips.cardano.org/cips/cip25/) you could assume it's an NFT, and then just count them up.

Thanks Sean, I'll check out those links then. In order to parse that data and filter all but those with a quantity of "1", can you tell me what the data type is?

It's a string as in:
{
"unit": "b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e",
"quantity": "125"
}


text:
How can I set up my environment for the upcoming Marlowe Pioneer Program?
I'm interested in getting ready for the upcoming Marlowe Pioneer Program. I know that for programmers one interesting flavor around all Marlowe components is to use the cli. What do I need to get early access to this?

So exploring the repo for the marlowe DSL lang. It is better to get Nix rather than installing ghc, stack,cabal, etc... locally. Nix contains everything we need.
To install Nix you can follow this guide HERE (I tried the single-user on Ubuntu 20.04).
Then we clone the marlowe-cardano repo and just run a nix-shell
$ git clone https://github.com/input-output-hk/marlowe-cardano
$ cd marlowe-cardano
$ nix-shell

this takes several minutes and will get us every dependency for the Marlowe language and the cli.
[nix-shell:~/marlowe-cardano]$ nix-env --version
nix-env (Nix) 2.8.1
[nix-shell:~/marlowe-cardano]$ marlowe-cli --version
marlowe-cli 0.0.4.0

and we are good to go!

It's hard to know the intended environment at the moment as  no details have been provided, but you can't go wrong having an Ubuntu workstation to work with. This will let you install/setup any needed code and packages, and you can easily run CLI and HTTP interfaces if they are needed.
Marlowe previously (still?) had a website with a drag-drop 'blocky' interface along with a CLI interface on the website. The course might offer something similar to this rather than each user needing to set up a local environment, in order to keep things simple.

The following two videos made by Plutus Pioneers gives us a good start.
https://youtu.be/mnfItts6VbU
https://youtu.be/g2F9raiGp_s
I didn't clone the Plutus repository as shown in the videos because I don't know if we will need that but I did jump around the videos and followed the directions for installing WSL, VSCode, Cabal, and Nix.
Haskell was installed at the linux terminal window with the following command
sudo apt install ghc

Tomorrow I am going to try and install the Cardano-CLI and the Marlow_CLI which I understand from this document will be necessary.


text:
Is the stake pool fixed fee cost once per epoch or per every block won?
Is the stake pool fixed fee cost, or min fee currently 340 ada, once per epoch, or once per block won?

The fixed fee and percentage fee are calculated once per epoch if the pool mints at least one block.
These fees are taken out of the total rewards amount that the pool earned that epoch, and the remainder is distributed to all delegates at amounts proportional to their stake within that pool.

Almost, the remainder is still deducted by the dynamic/ margin fees if those are set to a percent greater than 0 before the delegates receive their proportional rewards.


text:
Can chain index be configured to sync from a particular slot?
The chain-index syncs from genesis all over again, everytime there is a version change or sometimes even for other reasons. Can it be set to sync only from a particular slot to save on the time spent for syncing?

Unfortunately it currently cannot. Maybe some time in the future.


text:
Is the Transaction Hash from block frost the same as the transaction id?
When making an API (HTTP) Get  request to the blockfrost API service, you can specify an address and get the transactions at the address  (https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1txs/get).
Is the Hash it gives you the same as the ID of the transaction?

Yes, the tx hash and tx id are the same. The terminology is getting used interchangably.

Thanks for the quick answer


text:
How can I Convert BlockFrost API Code to Dandelion API?
I have somehow managed to get a lot of code for BlockFrost API, however, I want to build some free applications for people to monitor blockchain data from a website dashboard.
To take advantage of the better fee structure I want to convert the code to the Dandelion API, The original code is just a series of function calls calling different endpoints and returning different results. Is there a way to programmatically convert the old APIs into Dandelion compatible APIs?

Can you provide an example of what you are trying to change to/from. Sounds to me like you need to do a swap out of API/URL calls (easy enough to do manually, or search/replace) but you will also need to handle any potential difference in data structure that you get back from the new APIs. Or I might be misunderstanding this request.

Thanks it's sorted. Dandelion makes a bunch of different APIs the rest ones are to convert to blockfrost and vice versa, but there's a few small tricks to converting the rest. I basically made some factory function around the blockfrost API sdk

Ok great. It might be helpful to create your own answer and accept it as the best answer, in order help anyone else that has a similar question.

Dandelion is now running an Blockfrost endpoint too.


text:
How to specify differerent inputs coming from a smart contract on Cardano Cli
I am currently testing a plutus script on cardano-cli, I need to use 2 inputs from a SC address that have different datum, how can I specify both  --tx-in-datum-file for the transaction?
Thanks

You can just define multiple by reusing the same flag multiple times like so:
cardano-cli transaction build \
  --tx-in 123#0
  --tx-in-script-file SCRIPT_FILE1
  --tx-in-datum-file JSON_DATUM_FILE1
  --tx-in 456#0
  --tx-in-script-file SCRIPT_FILE2
  --tx-in-datum-file JSON_DATUM_FILE2
  {...}

You can see from the cardano-cli documentation notation that you can declare multiple tx-ins, datums and redeemers:
(--tx-in TX-IN
   [--tx-in-script-file FILE
      [
        ( --tx-in-datum-cbor-file CBOR FILE
           | --tx-in-datum-file JSON FILE
           | --tx-in-datum-value JSON VALUE
        )
        ( --tx-in-redeemer-cbor-file CBOR FILE
           | --tx-in-redeemer-file JSON FILE
           | --tx-in-redeemer-value JSON VALUE
        )
      ]
   ]
)

Inside your validator (onchain) code you can use findDatum to retrieve the respective datum by its hash or pattern matching.


text:
What's a Good example of Practle Serialation lib Usage
Okay so I have used an older version of the library by emerugo. And want some examples of the use of the newer version just to make sure I'm not missing anything important.
Can someone point me the most upto date docs?

I find this react example very useful as it pretty much shows all cases you may want to use the serialization lib.
https://github.com/dynamicstrategies/cardano-wallet-connector.git

have you got somthing with some more documentation?

Perhaps cardano's developer docs?
https://developers.cardano.org/docs/get-started/cardano-serialization-lib/overview

I'd appreciate if you mark my response as answer if it is satisfying your question :)

Actually, it's not really a satisfying answer so I'm planning on trying this out myself and posting the findings as a new answer.  I gave you the only upvote so far just because I appreciate you trying to help, if your answer were satisfying I would have given you the tick at the same time.  So apologies but I'm afread I cant do that right now.

Please specify your question then, bc the first link I provided shows plenty of examples how to use the serialization lib and the second provides a walk through for common examples with a demo available.
I am not sure what else you're looking for?

Another resource that might be interesting is: https://github.com/Berry-Pool/lucid
It's an abstraction layer on top of the serialization lib


text:
Extract keypair from hd wallet address and use for signing/verifying via libsodium
I like to use priv/pub keypair of an hd wallet address to sign/verfify data (outside a transaction signment). Based on this question i know how to derive the private key out of an address and i assume to get the public key via:
./cardano-address key inspect <<< $(cat public.key)

and then use the 'extended_key' value.
I try to verify the extracted keypair via libsodium:
sign:     libsodium.crypto_sign(message, sender_secret_ed25519)
verify:   libsodium.crypto_sign_open(signed_message, sender_pubkey_ed25519)

and fail to verify a signed message.
I think i may use the wrong public and/or private key or i need to convert the keys somehow.
does anyone have a recommendation to get this working?


text:
Why are some Plutus types defined multiple times in different packages?
I would like to know why certain types are defined multiple times in different packages and whether that's suppose to dictate which types to use for on-chain code and which for off-chain code?
Example: Address type exists in the following packages:
Plutus.V1.Ledger.Address
Ledger.Address

The second is just re-exporting.
Using the imports of the form Ledger.Address will mean bumping versions wont require lots of edits of V1 to V2 .
This may or may not be desirable. Depends on your context.


text:
utxo fail problem(utxo fee too small
we faced the utxo failure issue
the error message is like
message: '"transaction submit error ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 272465) (Coin 269165))))])"',
What is the problem?
We tested many times successfully but the error only occurred when it went to mainnet
Here is our policy id if anyone could help look into the transaction and find out what the problem is?
https://cardanoscan.io/tokenPolicy/2fd5b51792a29d9c0f77297a29bbc262de093b1072f2fc17ee048a81
There are just part of the transactions failed, we want to know why

The attached fee is too small. How are you creating your transactions? If you're using the cardano serialization lib (from here https://github.com/Emurgo/cardano-serialization-lib) and you're using the add_change_if_needed function, call it right before building the tx to make sure it adds the right fee.
Often times while testing you can have single pure Ada UTXOs as inputs and outputs and when you go live you can get fragmented multiple UTXOs to cover the required sum with various assets attached etc., which can cause the fee to vary depending on the total tx size. Depending on the coin selection strategy the mechanism for choosing UTXOs can be random, which is why it only sometimes occurs.

Yes I used cardano serialization lib, and my add_change_if_needed is just right before building the tx

txBuilder.add_change_if_needed(this.S.Address.from_bech32(PaymentAddress));
const transaction = this.S.Transaction.new(
txBuilder.build(),
this.S.TransactionWitnessSet.new(),
AUXILIARY_DATA
);

We calculate the fee and build the transaction in the frontend, then the backend sign and submit the tx, would that be the problem for the wrong tx fee?

That should not be a problem. Creating a tx on the frontend and signing on the backend generally should be fine, but there seems to be a change in tx size happening somewhere, it could be somewhere in the cbor encoding / decoding processes. Maybe this helps: https://developers.cardano.org/docs/get-started/cardano-serialization-lib/generating-transactions/#a-note-on-fees

Just set your fee to 272465 and resubmit the tx, then you should be fine

There are different utxo fee, if I just simply set to 272465, the tx exceeding 272465 will fail, unless I set it to 500000

How are you building your transactions? Because if you're using the cardano cli you can let the cli calculate the fee instead of manually inputting it.
Same can be done using the cardano-serialization library


text:
Creating wallets using apis
I am wondering whether the cardano block chain has the apis which i can integrate with a third arty cms. For example if i call an api the wallet has to be created and i can sent funds using the same wallet thinks like that?

REST Api there is https://blockfrost.io/
Otherwise it´s the cardano-cli

You create a wallet (keys and addresses) with just a few lines of code, eg like this: https://github.com/Emurgo/cardano-serialization-lib/blob/master/doc/getting-started/generating-keys.md. No need for remote services or interfacing w. the blockchain for this. Once you generate an address it's ready for you to use. Just create transactions using that address and submit those to the network (eg using blockfrost). Whatever you send to an address will just be sitting there until the key-holder decides to spend it.

I need a remote service becose i am using a cms in which i have to give a wallet whenever a user is signing up.

ah okay sorry can't recommend any such service unfortunately. Must be one that you'd potentially trust access to all your funds to, though, if I understand correctly.

Hello you can definitely use cardano-wallet but you will need local cardano-node's socket connection.
Once you are running it, it exposes REST APIs web services you can interact to


text:
What specifications should be used when creating a native token logo?
What specifications should be used when creating a native token logo (e.g. dpi, pixel dimensions, size, etc.)

There is no standard or specification you need to follow for creating a native token logo. You should use the same width and height if you want your token logo to be correctly displayed in wallets, though.
You can find an example of dimensions that will work properly here: https://cardano.org/brand-assets


text:
Haskell + Blockfrost toolchain?
I am looking for a Haskell alternative to the cardano-serialization-lib, which can work in conjunction with blockfrost-haskell. So ideally, it should be able to easily create wallet keys, transactions, etc., without having to use Javascript (and also not running cardano-node). What's the best way to go about this?

I think you want the cardano-api, part of the cardano-node repo. Most things that can be done, it can do. At the very least its the place to start.
The cardano-cli provides a set of examples of how to use the api to, say, make keys or build txs.

Thanks for the answer! So I could build just the api directory and add it as a dependency to my cabal.project file right? Also, I was unable to find the examples for the api in the cli directory, could you link them? Thanks again!

I tried this and it works for creating addresses! But it throws an error when I try to build transactions because it requires CARDANO_NODE_SOCKET_PATH

Ah. You'll have to dig in to the code (its intimidating but doable) to see what its using the node for. It might just need the env variable set (some initial catch-all condition to prevent the user getting down stream errors that make no sense, but this particular call doesn't actually use the node service) or it might need to protocol params... at which point this won't be an off-the-shelf solution. Still you could extract the function can provide the params yourself.

Oh okay, will try to do this! Thanks again

Yeah, I think that this requires a running node, which is why CARDANO_NODE_SOCKET_PATH is required.

I have been looking into this as well, please hit me up if you have come up with something easier/more convenient.


text:
Installing GHC on WSL
I just installed Ubuntu on WSL for Windows 10 in order to get ready for the Marlowe Pioneers Program. I figure I will need to install GHC and Cabal next in order to install the Cardano-CLI and Marlowe-CLI.
Can someone please tell me the best way to install GHC and Cabal on WSL/Ubuntu?
Much Thanks

The recommended way to install Haskell on Linux is by using GHCUP. Using apt may install an old version of GHC.
Simply enter the following command on your WSL terminal:
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

It depends on your use case. If you would like to develop using Haskell, I would recommend installing Stack too. Note that you should not install the Haskell Language Server if you plan on using VS Code. VS Code will download it for you, depending on your GHC version.

You will likely want to use wsl2 on windows, if you aren't already, as you will have build issues.
https://winaero.com/set-linux-distro-version-to-wsl-1-or-wsl-2-in-windows-10/

Found two great resources from the Plutus Pioneers Program
youtu.be/mnfItts6VbU and
youtu.be/g2F9raiGp_s
I had to jump around a bit because these videos are for Plutus not Marlowe but there was good information on installing WSL-Ubuntu, Cabal, Nix, and VSCode
Haskell was installed at the linux terminal window with the following command
sudo apt install ghc


text:
Plutus Script Validation Metadata
I have a question but I cannot find a concrete answer for that. I have a smart contract developed in Plutus for managing locking and withdraw of Tokens/NFTs. I'm wondering if I can validate some metadata of my NFT onchain, in my validator script.
For example, imagining this NFT: https://pool.pm/asset16tkxq9yrk6lmkwld6vnz5m8f6j54gj376jy2xx
The metadata contains: Artist, Artist Website, Id, Rarity and so on; Can I get the information about the metadata onchain on my validation script? so I can verify an specific word contained on this attributes?
Thank you so much.

There is a solution proposed in this question https://cardano.stackexchange.com/q/4609/5589 . As proposed, you can send another token to the validator script and set its datum to metadata.
Another option is proposed https://cardano.stackexchange.com/questions/4609/how-to-retrieve-the-datum-added-with-the-option-tx-out-datum-embed-file-from-th#comment4987_4609

If the NFT was minted using a transaction with metadata (cardano-cli), then the Plutus script won't be able to access this information. This is because you can only feed UTxOs to Plutus validator scripts. UTxOs don't contain the data stored on the ledger.
If you are in this situation, I would solve your problem by getting the metadata of the NFT from the ledger (using a service like Blockfrost) and validating it BEFORE feeding the UTxO to the validator script. This way, if metadata doesn't match, then there's no point in continuing with the execution of the Plutus script.
On the contrary, if the NFT was minted using a Plutus minting policy, as per this tweet, you have the ability to store this information in the UTxOs, using TxWitness field, as part of the datum hash.

If by "BEFORE" you mean in off chain code, than I don't think this is a right approach as advarsery can easily bypass that and send invalid/different metadata to an chain code.
Second proposal will work, if you store datum or datum hash in validator script utxos. If the number of NFTs is big (lets say 10_000), than this will require creation of 10_000 utxos which is costly. Currently every utxo has to have at least 1 ada so in this case that would cost 10_000ada just to be able to verify the metadata on chain.


text:
Building a transaction on cardano-cli/api without running node?
Is there a way to build and sign transactions with the cardano-cli/api without running a node? I am trying to construct a transaction using the cli or api and submit it using blockfrost. It throws an error about the CARDANO_NODE_SOCKET_PATH since I am not running a node locally. Any help would be appreciated. I would prefer to avoid using the cardano-serialization-lib since I want all my offchain code to be in Haskell too.

You could try building on/with parts of the plutus-apps repo.
It doesn't need a node.
However this is not its intended use case so it won't be without problems.
You'll probably have to write your own minAda function, your own balancer, and your own fee calculator. These are deemed the responsibility of the wallet - at present only the cardano-wallet is feature complete and integrated into plutus in that sense.
The cardano-wallet will not be happy if you don't point it at a node socket.

plutus-apps is pretty much abandoned https://github.com/input-output-hk/plutus-apps/commit/f4790acbf901cfd546ff57b7052b20f1addbd57b

You dont need a node at all to build or sign CLI transactions (i.e. assuming you're using cardano-cli transaction build-raw. The only point you might need to look up something from a live node is getting UTxOs to your address (and checking TTL), but atleast for latter you can also calculate current slot remotely (or use tip from your API provider).
As regards input UTxO , blockfrost as well as Koios both offer checking address utxos.

I believe that error only comes up when you try to push a transaction
sounds like you've already constructed your transaction with cardano-cli - if not this is available via github, just grab the latest binary release from the cardano node repo, it'll include cardano-cli
at any rate, once you have your transaction built and signed it's just a matter of submitted it to the blockchain.
a couple of options, us a wallet like eternl, you can import your own transactions and use their nodes to push it, this is available under Send > Options > Import
alternatively you can use any of the publicly available cardano node apis


text:
Will stakepool rewards statistically even out over time if I run a pool with a small stake?
If I start a pool with a large pledge of around 170k ADA but I struggle to get people to stake to my pool and I just end up having only the 170k pledge of ADA staked to the pool the entire time the pool is run will the rewards I earn eventually make running a pool worthwhile?
I'm thinking long term, like 5-10 years, and not considering the costs of running the pool such as electricity, equipment, and an internet bill. I'm just comparing running a stakepool with a large stake to just staking it in an already well performing pool.
I think I'd like to take the chance of running a pool but I don't want to sink my bag into a pool that makes me nothing if I could have it in a larger pool and earn rewards.
Also, I realize that cardano.org has a calculator for calculating stake pool rewards but it doesn’t give much indication on what rewards would be for smaller stakes.

The rewards of staking on Cardano are, on average, 5% APY.
At the moment, a pool with 170K ADA of stake has a 12.89% chance of producing a block per epoch (you can check the "Rewards" tab of this pool for reference, as it has that same amount of stake: https://adapools.org/pool/34736425217f45cc1f6e59a88bd253e50b90f47ea206ec7f26afdfc5). This means that, to produce a block every epoch, you need to have a stake of 1.4M ADA at least.
In your case, and probabillistically, you'll be signing a block every 7.75 epochs (1 epoch has 5 days in Cardano's blockchain). One year has 73 epochs, so you will be signing a block in 9.41 of those epochs. Every epoch you mint a block, as an operator, you'll get 340 ADA on top of your rewards (this is the most usual fixed fee for SPOs).
I run a stake pool and I can assure you that, if you won't be promoting it or at least trying to get more delegators to join your pool, then I reckon that with that amount of stake it's better for you to join a pool. I would consider running my own pool without caring about delegators at least with a chance of 50% of minting a block each epoch. But this is just my opinion.

Would the rewards and pool fees I would receive every 7.75 epochs equal or exceed the rewards of just staking?

That's not something I can answer straight away as there are so many variables in play and the performance of your pool is one of those. As per this website (https://cardanode.com.au/cardano-staking-calculator-rewards-ada/) you'll be getting 8,713.0276 ADA each year staking on a 5% APY pool. The rewards you will receive if you mint a block in an epoch will exceed the rewards of just staking BUT you need to consider the costs of running the pool (servers) and the time you'll have to dedicate to maintain it. In my experience as an SPO, it's not profitable to run a stake pool with only 170K ADA.


text:
systemd auto run stake poll issue (code=exited, status=127)
I have been trying to run the Cardano node by systemd for about 3 days but not getting any luck
I can run startBlockProducingNode.sh manually without error, Cardano node run successfully
The systemd failed with (code=exited, status=127) but did not say any error
Below is the systemd status
May 20 15:40:56 systemd[1]: Started Cardano node service.
May 20 15:40:56 systemd[1]: cardano-node.service: main process exited, code=exited, status=127/n/a
May 20 15:40:56 systemd[1]: Unit cardano-node.service entered failed state.
May 20 15:40:56 systemd[1]: cardano-node.service failed.
May 20 15:41:01 systemd[1]: cardano-node.service holdoff time over, scheduling restart.
May 20 15:41:01 systemd[1]: Stopped Cardano node service.

By the way, I'm using ec2 from aws

Can you post your systemd settings into your question for us to review. There is a good chance that more environment settings need to be set, when compared to your user that runs the script successfully. Also check your system logs for any extra details eg permissions issues

I have solved the issue by myself, here is the solution:
The solution for those who followed the Cardano developer portal to build the stake pool but failed to use systemd to start

move the file

$ which cardano-node

~/.local/bin/cardano-node

$ cd ~/.local/bin/

$ sudo cp cardano-cli /usr/local/bin/

$ sudo cp cardano-node /usr/local/bin/

Set the enviroment in systemd file

Environment="LD_LIBRARY_PATH=/usr/local/lib"
Environment="PKG_CONFIG_PATH=/usr/local/lib/pkgconfig"
Environment="CARDANO_NODE_SOCKET_PATH="$HOME/cardano-src/db/node.socket"

it might be a permission-related issue. Make sure you are running the systemd service with the user you manually run ./startBlockProducingNode.sh


text:
Failed Install Marlowe-CLI
I cloned marlowe-cli from https://github.com/input-output-hk/marlowe-cardano/tree/cli-blog-april2022/marlowe-cli into WSL at /home/{user}
and attempted to install with the command:
cabal install exe:marlowe-cli
The install failed with the following message:
Failed to build lzma-0.0.0.3. The failure occurred during the configure step.
Build log (
/home/johnshearing/.cabal/logs/ghc-8.10.7/lzma-0.0.0.3-b8e5e5271afb9de54972ab2bbbbfe6e55609cefdde55c24b9e9d56d7e4cf3ba8.log
):
Configuring library for lzma-0.0.0.3..
cabal-3.6.2.0: Missing dependency on a foreign library:

Missing (or bad) header file: lzma.h
Missing (or bad) C library: lzma
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

cabal: Failed to build lzma-0.0.0.3 (which is required by exe:marlowe-cli from
marlowe-cli-0.0.4.0). See the build log above for details.
Can someone please tell me what to do?
Thanks

what OS are you on?
on debian-based distros try installing
sudo apt install liblzma-dev

lzma.h is included in liblzma-dev, so this should solve the missing dependency.
as per
this package search

Thanks @Dark345. I am using WSL/Ubuntu I see by your package search link that Ubuntu is Debian Based. I will try your solution. and report back.

yep, let me know, thanks

Yes @Dark354, I ran the install for liblzma-dev and then cabal install for marlowe-cli and it went through without any errors. Much thanks

okay, perfect, you can mark as answered if you have time. Thanks


text:
Using chain-index endpoints
Hitting the chain index endpoint to query utxo just gives Bad Request as response.
Tried this on testnet where txOutRefId is the tx hash of a testnet transaction. Screenshot is attached.
curl -X 'POST' \
  'http://localhost:9083/unspent-tx-out' \
  -H 'accept: application/json;charset=utf-8' \
  -H 'Content-Type: application/json;charset=utf-8' \
  -d '{
  "txOutRefId": "32178b5f5af6c2ac963adef07284f35cb7a86ff1cdd18e119007631607a28b84",
  "txOutRefIdx": 0
}'

Unable to figure out what I am doing wrong here. Has anyone been able to use this endpoint?
Note: Chain index is synced and /tip endpoint works.
Update:
This seems to be required format for the endpoint
curl -X 'POST' \
  'http://localhost:9083/unspent-tx-out' \
  -H 'accept: application/json;charset=utf-8' \
  -H 'Content-Type: application/json;charset=utf-8' \
  -d '{
  "txOutRefId": {"getTxId":"3961a841f5af32d3878cd816a23c9da7b3c3bb586e3b3db5fba1579bd1408a20"},
  "txOutRefIdx": 0
}'

Howeve my chain-index responded with this
Delete your chain index database and resync.
CallStack (from HasCallStack):
  error, called at src/Plutus/ChainIndex/DbSchema.hs:232:22 in plutus-chain-index-core-0.1.0.0-inplace:Plutus.ChainIndex.DbSchema

Beats me why it asks for a resync. Resyncing chain index will take days, so I have not gone ahead to try that :)

What error does curl return when run in the terminal?

@waalge: Thanks for that comment. Terminal gives.
Error in $.txOutRefId: parsing Plutus.V1.Ledger.TxId.TxId(TxId) failed, expected Object, but encountered String
Seems it expects the TxId object defined in Plutus as TxId { getTxId :: PlutusTx.BuiltinByteString }.
Will try it out

how to query the chain index tx endpoint?
I think you are probably still seeing this.
This happens on a number of the apis.
Shame swagger doesn't return the actual error. It would save some time.

I changed the object in the payload and got a response, not the one I expected though. I have added the info as updates to the question.

the chain-index is such a headache that I gave up. Bon courage.


text:
gLiveView not working and cnode.service could not be found setting up node for first time
My node is syncing right now for the first time but i can't check the progress or node status.
GLiveView failed to load and cnode.service could not be found

Did you set the port on gLiveView's env file?
Also gLiveView will not work until epoch 208 is synced as said here:

A node must synchronize to epoch 208 (Shelley launch) before
gLiveView.sh can start tracking the synchronization process.

For the problem with systemctl, are you sure that you've created the service?
Which guide did you follow?

check
ls -lrt /etc/systemd/system/

for existing services, looks like cnode.service is missing from that folder.
Anyway you don't need the full cnode.service running to use gliveview, just set these two variables for proper gliveview functioning:
CONFIG="${NODE_HOME}/mainnet-config.json"
SOCKET="${NODE_HOME}/db/socket"


text:
MacOS nix-shell (fail) after cd marlowe-cardano
I followed the instructions for MacOS setup from here:
How can I set up my environment for the upcoming Marlowe Pioneer Program?
... which worked well up until
cd marlowe-cardano
$ nix-shell
MacOS version: 12.3.1 Monterey.
... nix-shell worked for a while, installing until it failed:
Preprocessing library for plutus-ledger-constraints-0.1.0.0..
Building library for plutus-ledger-constraints-0.1.0.0..
[1 of 4] Compiling Ledger.Constraints.TxConstraints ( src/Ledger/Constraints/TxConstraints.hs, dist/build/Ledger/Constraints/TxConstraints.o, dist/build/Ledger/Constraints/TxConstraints.dyn_o )
[2 of 4] Compiling Ledger.Constraints.OnChain ( src/Ledger/Constraints/OnChain.hs, dist/build/Ledger/Constraints/OnChain.o, dist/build/Ledger/Constraints/OnChain.dyn_o )
[3 of 4] Compiling Ledger.Constraints.OffChain ( src/Ledger/Constraints/OffChain.hs, dist/build/Ledger/Constraints/OffChain.o, dist/build/Ledger/Constraints/OffChain.dyn_o )
: error:
: dlopen(/nix/store/7zv7cy150qlqrhn8jx4hwchmnj16c9fa-cardano-wallet-core-lib-cardano-wallet-core-2022.1.18-config/lib/links/libHSappar-0.1.8-KYad8eEAlRI90NAZOjuGzF-ghc8.10.4.20210212.dylib, 0x0005): cannot dlopen until fork() handlers have completed
[107 of 114] Compiling UnliftIO.Compat  ( src/UnliftIO/Compat.hs, dist/build/UnliftIO/Compat.o, dist/build/UnliftIO/Compat.dyn_o )
[108 of 114] Compiling Cardano.DB.Sqlite ( src/Cardano/DB/Sqlite.hs, dist/build/Cardano/DB/Sqlite.o, dist/build/Cardano/DB/Sqlite.dyn_o )
error: builder for '/nix/store/f4ybcf3n7hk2yfn375ikgz9r4l37nfa3-cardano-wallet-core-lib-cardano-wallet-core-2022.1.18.drv' failed with exit code 1;
last 10 log lines:
> [ 99 of 114] Compiling Data.Vector.Shuffle ( src/Data/Vector/Shuffle.hs, dist/build/Data/Vector/Shuffle.o, dist/build/Data/Vector/Shuffle.dyn_o )
> [101 of 114] Compiling Network.Wai.Middleware.Logging ( src/Network/Wai/Middleware/Logging.hs, dist/build/Network/Wai/Middleware/Logging.o, dist/build/Network/Wai/Middleware/Logging.dyn_o )
> [102 of 114] Compiling Network.Wai.Middleware.ServerError ( src/Network/Wai/Middleware/ServerError.hs, dist/build/Network/Wai/Middleware/ServerError.o, dist/build/Network/Wai/Middleware/ServerError.dyn_o )
> [105 of 114] Compiling Paths_cardano_wallet_core ( dist/build/autogen/Paths_cardano_wallet_core.hs, dist/build/Paths_cardano_wallet_core.o, dist/build/Paths_cardano_wallet_core.dyn_o )
> [106 of 114] Compiling Cardano.Wallet.Version ( src/Cardano/Wallet/Version.hs, dist/build/Cardano/Wallet/Version.o, dist/build/Cardano/Wallet/Version.dyn_o )
>
> : error:
>     : dlopen(/nix/store/7zv7cy150qlqrhn8jx4hwchmnj16c9fa-cardano-wallet-core-lib-cardano-wallet-core-2022.1.18-config/lib/links/libHSappar-0.1.8-KYad8eEAlRI90NAZOjuGzF-ghc8.10.4.20210212.dylib, 0x0005): cannot dlopen until fork() handlers have completed
> [107 of 114] Compiling UnliftIO.Compat  ( src/UnliftIO/Compat.hs, dist/build/UnliftIO/Compat.o, dist/build/UnliftIO/Compat.dyn_o )
> [108 of 114] Compiling Cardano.DB.Sqlite ( src/Cardano/DB/Sqlite.hs, dist/build/Cardano/DB/Sqlite.o, dist/build/Cardano/DB/Sqlite.dyn_o )
For full logs, run 'nix log /nix/store/f4ybcf3n7hk2yfn375ikgz9r4l37nfa3-cardano-wallet-core-lib-cardano-wallet-core-2022.1.18.drv'.
error: 1 dependencies of derivation '/nix/store/dvcxsznm7y2vlylprmgmxaxkrz127ng3-cardano-wallet-exe-cardano-wallet-2022.1.18.drv' failed to build
error: build of '/nix/store/0qc5jy1gq7wvfrh8cgk8simha4kcy1yw-marlowe-play-spago.drv', '/nix/store/1n6k5x1w9anmdyy8sk91jy3ccgm05vf1-haskell-language-server-wrapper.drv', '/nix/store/2nh1qzgav72nhqx3z1z9vpslykc91ql4-marlowe-run-server.drv', '/nix/store/2vwdv3q4y9x9hizcc6nrzzaxbkv9f8pc-fix-dhall.drv', '/nix/store/2xwv0nk72cjxy6hvknnvkml99il3av0p-fix-stylish-haskell.drv', '/nix/store/3713lqy701bvfk5ajxypq64jsygfzmsb-start-dashboard-server.drv', '/nix/store/3cn5w7pfgxg6l22aqvd95246v3yhhjr7-marlowe-run-generate-purs.drv', '/nix/store/5cxhfxjy2sil7nax62mckchg1xc5idk9-fix-purs-tidy.drv', '/nix/store/5zszwp9j729xijzvwcnphy26gnjifl44-updateMaterialized.drv', '/nix/store/65l907v2srfpqh1vi208mxac13l9d4x0-marlowe-run-test.drv', '/nix/store/693hfzb5rlpfkf23zgxcg57fhyz9k89a-start-chain-index.drv', '/nix/store/8lvv31qg971507d244ipfci9sjncm2q3-start-cardano-node.drv', '/nix/store/9kxgfphjxpflks2as3rv4vw4n2vsqy49-start-marlowe-run.drv', '/nix/store/dvcxsznm7y2vlylprmgmxaxkrz127ng3-cardano-wallet-exe-cardano-wallet-2022.1.18.drv', '/nix/store/gf3wry42mkylrln6j630x5cz95ckfgpi-marlowe-playground-generate-purs.drv', '/nix/store/hbrm722bkf986l20cmlsh2jdqwnalw37-marlowe-run-spago.drv', '/nix/store/hmww1licvw5ymk8vvf69a5376ly1s205-haskell-language-server-exe-haskell-language-server-1.3.0.0.drv', '/nix/store/hqma6a8a48g0lwy811b89xh93jz9dcnn-ghc-shell-for-packages-ghc-8.10.4.20210212-env.drv', '/nix/store/hvz6yfsj3azapdl4r3p92nj24rz0wrnx-pre-commit-config.json.drv', '/nix/store/i45s1bvam4xpg1ssz1kprizkzzhm7kzi-marlowe-playground-server.drv', '/nix/store/ill6y3fxqg8j75qhq4qyrbwa2p1j65a2-generate-purescript.drv', '/nix/store/kiq89kgza8shhc3qx7mxdl5lhkj7qk1y-fix-prettier.drv', '/nix/store/kw40pqdaq4vibc81c8gylkx3ikwwlmk3-blockfrost-client-lib-blockfrost-client-0.3.1.0.drv', '/nix/store/lwapgnmc48inbjdsximapbm9k9mfbc4n-marlowe-cli-exe-marlowe-cli-0.0.4.0.drv', '/nix/store/vbv7f25mjlprckimfvmf2v881l0afcrh-start-marlowe-pab.drv', '/nix/store/x006fz3vjkykqf1m96jzh54nj22zghf4-start-cardano-wallet.drv', '/nix/store/y1n8l4jznbm0q4xrlgbhly6lnd9im60s-update-client-deps.drv', '/nix/store/z6xqdvz6grjpxdkkp3k2g47zyd2hw8hq-python3-3.9.6-env.drv', '/nix/store/z9bsag150pgrskwj3pza4kbfcd53djk1-marlowe-exe-marlowe-pab-0.1.0.0.drv', '/nix/store/zbdiqa6snqkrjmdz270dggac1sd5427l-plutus-chain-index-exe-plutus-chain-index-0.1.0.0.drv' failed
... so it looks like it got hung up when trying to do:
Preprocessing library for plutus-ledger-constraints-0.1.0.0
Note i tried entering nix shell after marlowe install... and there's an "segmentation fault" error:
nix-shell marlowe-cardano/shell.nix
trace: To materialize project.plan-nix for cabal-install entirely, pass a writable path as the materialized argument and run the 'updateMaterialized' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the materialized argument and run the 'updateMaterialized' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the materialized argument and run the 'updateMaterialized' script in 'passthru'.
zsh: segmentation fault  nix-shell marlowe-cardano/shell.nix

Closing the loop on this. I was able to install Daedalus locally, and open a Marlowe terminal from the menu. This is much simpler, and it seems to work just fine. :) Advise using the CLI from Daedalus as the preferred method of local development, at least on a Mac.

Hi Aaron, you can mark this one or any other answer as correct to let everybody know your question has been answered. Cheers.

Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Mac users have to configure their nix setup a little differently than other environments. You might need to update your nix.conf file located in /etc/nix/nix.conf.
You can find the specific instructions for Mac users here: https://plutus-community.readthedocs.io/en/latest/#Environment/Build/MacOS/
And Mac M1 users here: https://plutus-community.readthedocs.io/en/latest/#Environment/Build/Mac_M1/
After updating your nix config, make sure to restart your machine and try again.

Thanks... I followed the Mac instructions precisely, and a lot worked. However, it looked like it all messed up here: Preprocessing library for plutus-ledger-constraints-0.1.0.0..
Building library for plutus-ledger-constraints-0.1.0.0.. this part failed. Hence, it doesn't appear all the tools installed/built.

Going to try Nix install directions... https://nixos.org/download.html#nix-install-macos

Closing the loop on this. I was able to install Daedalus locally, and open a Marlowe terminal from the menu. This is much simpler, and it seems to work just fine. :)


text:
Is there a precedent or example for using a cardano NFT for permission verification?
I would like to use ownership of a Cardano NFT as a requirement for editing an online document. i.e. if you own the nft then you will be capable of writing to the document,but if you do not own the required NFT then you will only be able to read.  Are there any examples of NFT ownership being used as a password of sorts like this?  any recommendations of where to start looking for a way to do this?

What you say is possible.
In this repo you can find an example on how to mint an NFT and then use it to login to a web app.
I reckon you can use a similar approach for your use case.

Are you sure that you posted the link you intended?  I searched the repo and do not even see the word NFT appear

Yes, I'm sure. Here you can find how to mint the NFTs: https://github.com/CardanoSevilla/cardano-summit-2021/tree/main/src/NFTs. The project uses GameChanger wallet to mint (https://gamechanger.finance). You can import those JSON in the Playground and mint your NFTs from there.

Here is another example: SpaceBudz Contract
He created individual SpaceBudBid NFTs that basically mark the highest bid on-chain for a specific SpaceBud. That way he doesn't need to scan a lot of UTxOs and instead always keeps track of the highest bidder.
You can do the same thing by generating an NFT series for each document. The policy could be unlocked so that the owner of the document can grant an arbitrary number of people different rights (reading, writing, commenting etc.) which correlates to some action that mints a respective NFT for that user.


text:
How to loop through multiple pages of blockfrost api in Javascript
I'm trying to count the assets at a blockfrost api endpoint. It only shows 100 items on a page though. How do you loop through all the pages and extract the asset count? Thanks for any help.
const Http = new XMLHttpRequest(),
        method = "GET",
        url = 'https://cardano-mainnet.blockfrost.io/api/v0/accounts/stake1';

    const PAGE_SIZE = 100 /* 100 is the max Blockfrost page size */
    const stake_address = 'stake1';

    Http.open(method, url, true);
    Http.setRequestHeader('project_id', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    Http.send();
    Http.onreadystatechange = (e) => {
        if (e.currentTarget.readyState == 4 && e.currentTarget.status == 200 && e.currentTarget.responseText != '') {
async function count_assets() {
let total = 0;
try {
                let total = 0;
                let assets = [];

do {
    assets = Http.responseText;
    total += assets.length;
    page++;
    } while (assets.length == page);
} catch (err) {
    console.log('error', err);
}
return total;
}

count_assets(stake_address).then(assets => {
console.log(stake_address, 'assets:', assets);
});
            }}

You probably want to use the "Assets associated with the account addresses" endpoint. You can add query params to the request as per specification.
E.g. to get 100 items on page 3: /accounts/{stake_address}/addresses/assets?count=100&page=3
Now simply create a loop that increments the page query param until you don't get 100 items in the response.


text:
How to check if validator ran inside minting policy
I want to check within a minting policy whether a specific spending validator script is being run by checking if I can find an input that belongs to that spending validator's script address.
If there is an easier way please let me know but I am running in to the following problem:
I have a function that returns a Maybe of the transaction input matching my spending validator.
scriptInput :: Maybe TxInInfo
scriptInput =
    let isScriptInput i = (isScriptAddress . txOutAddress . txInInfoResolved) i
        xs = [i | i <- txInfoInputs info, isScriptInput i]
    in
        case xs of
            [i] -> Just i
            _   -> Nothing

isScriptAddress :: Address -> Bool
isScriptAddress
    Address { addressCredential=ScriptCredential vh
            , addressStakingCredential=Nothing
            } = vh == scriptValidatorHash -- comes from validator definition in same file
isScriptAddress _ = False

When I replace the vh == scriptValidatorHash with True I get no interpreter error, but if I leave it as described above I get the following error:
GHC Core to PLC plugin: E042:Error: Unsupported feature: Type constructor: GHC.Prim.ByteArray# Context: Compiling type: GHC.Prim.ByteArray# Context: Compiling data constructor type: GHC.Natural.NatJ# Context: Compiling type: GHC.Natural.Natural Context: Compiling data constructor type: PlutusCore.Core.Type.Version Context: Compiling type: PlutusCore.Core.Type.Version ann Context: Compiling data constructor type: UntypedPlutusCore.Core.Type.Program Context: Compiling type: UntypedPlutusCore.Core.Type.Program PlutusCore.DeBruijn.Internal.DeBruijn PlutusCore.Default.Universe.DefaultUni PlutusCore.Default.Builtins.DefaultFun () Context: Compiling type: Plutus.V1.Ledger.Scripts.Script Context: Compiling type: Plutus.V1.Ledger.Scripts.Validator Context: Compiling data constructor type: Ledger.Typed.Scripts.Validators.TypedValidator Context: Compiling type: Ledger.Typed.Scripts.Validators.TypedValidator a Context: Compiling type: Ledger.Typed.Scripts.Validators.TypedValidator a -> ...

It turns out directly referencing the spending validator hash computes the hash of the spending validator which runs the PLC plugin again. That leads to problems of some kind. Therefore the best solution for referencing script hashes inside scripts is by lifting them with the help of PlutusTx.liftCode and PlutusTx.applyCode.
So I made the following changes to my minting policy to get it to work:
I am passing along an address parameter which allows me to check  for equality - essentially, making my minting policy a parameterized policy.
{-# INLINABLE mkMintPolicy #-}
mkMintPolicy :: Address -> ScriptAction -> ScriptContext -> Bool
mkMintPolicy addr sa ctx =
    ...
    isScriptAddress :: Address -> Bool
    isScriptAddress a = a == addr
    ...

policy :: Scripts.MintingPolicy
policy = mkMintingPolicyScript $
    $$(PlutusTx.compile [|| wrap ||])
    `PlutusTx.applyCode` PlutusTx.liftCode mySpendingValidatorAddress
    where
        wrap addr = Scripts.wrapMintingPolicy $ policy addr


text:
importing nami-wallet package in nodejs
I successfully imported and used cardano-wallet-interface by harmonic pool. However, I wonder if I can directly install and import Nami wallet. I installed the package using "npm install git+{url}.git" and tried to "import * as NamiWallet from 'nami-wallet'" but I get error of index.js not found.
Main reason is that I want to check Nami further, I am getting wrong utxos when I use getUtxos() method from cardano-wallet-interface when Nami is the active wallet, however, same exact code works find when Eternl wallet is used.

The import of Nami you are doing is not quite right. That's why you are getting that error.
I suggest you import lucid-cardano instead:
npm install lucid-cardano
Lucid is a library which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js. It has been done by the creator of Nami Wallet so, if you want to check how it works, this will be helpful.


text:
How to setup environment for Marlowe Pioneer Program? Error: creating directory '/tmp/nix-shell-1271-0': No space left on device
Im participating in the Marlowe Pioneers program, I setup Nixos with IOHK Binary, then added to Marlowe repository, did cd marlowe-cardano. But when I ran Nix-shell I got an error that I had no space left on device. How much space do I need to run these? Setup is 8GB RAM, 16GB Memory. Are there ways i get better optimise to let Nix-shell work? Thanks for your help.

All Cardano development environments/tools are extremely space hungry and nix too. Don't bother setting up anything below 100 GB of free space, otherwise you will regret it later, even if it works in the beginning.

The error you are getting has nothing to do with the RAM of your environment but with the disk space.
Unfortunately, there is no other way to make Nix work rather than setting up a partition with, at least, 40 GB of free space (to be safe).
This is a screenshot of my /nix/store directory, where Nix keeps all its necessary modules:

You can see it has over 1M files, totalling 33.3 GB.