text:
Connection between functions, modules, and packages
I have determined (by analyzing all the .hs files) that for weeks 1-8, the following modules are variously imported:
import qualified Prelude
import qualified Prelude                       as P
import           Prelude                       (IO)
import           Prelude                       (IO, Show (..))
import           Prelude                       (IO, Show (..), String)
import           Prelude                       (IO, Semigroup (..), String)
import           Prelude                       (IO, Semigroup (..), String, undefined)
import           Prelude                       (IO, Semigroup (..), Show (..), String)
import           Prelude                       (IO, Semigroup (..), Show (..), String, undefined)
import           Prelude                       (Semigroup (..), Show (..), String)
import           Prelude                       (Semigroup (..), Show (..), uncurry)

import           Cardano.Api
import           Cardano.Api                   as API
import           Cardano.Api.Shelley           (PlutusScript (..))
import           Cardano.Api.Shelley           (Address (..), PlutusScript (..))
import           Cardano.Crypto.Hash.Class     (hashToBytes)
import           Cardano.Ledger.Credential     as Ledger
import           Cardano.Ledger.Crypto         (StandardCrypto)
import           Cardano.Ledger.Hashes         (ScriptHash (..))
import           Cardano.Ledger.Keys           (KeyHash (..))

import           Codec.Serialise               (serialise)

import           Control.Lens
import           Control.Monad
import           Control.Monad                 hiding (fmap)
import           Control.Monad.Freer.Extras    as Extras

import           Data.Aeson                    (ToJSON, FromJSON)
import           Data.Aeson                    (encode)
import qualified Data.ByteString.Char8         as BS8
import qualified Data.ByteString.Lazy          as LBS
import qualified Data.ByteString.Short         as SBS
import           Data.Default                  (Default (..))
import           Data.Functor                  (void)
import           Data.List.NonEmpty            (NonEmpty (..))
import           Data.Map                      as Map
import qualified Data.Map                      as Map
import           Data.Maybe                    (fromJust, fromMaybe)
import           Data.Monoid                   (Last (..))
import           Data.OpenApi.Schema           (ToSchema)
import           Data.String                   (IsString (..))
import           Data.Text                     (Text)
import           Data.Text                     (pack, Text)
import           Data.Text                     (Text, unpack)
import           Data.Void                     (Void)

import           GHC.Generics                  (Generic)

import           Ledger
import qualified Ledger
import qualified Ledger                        as Plutus
import           Ledger                        hiding (singleton)
import           Ledger                        hiding (mint, singleton)
import           Ledger                        (Address)
import           Ledger.Ada                    as Ada
import           Ledger.Constraints            as Constraints
import qualified Ledger.Constraints            as Constraints
import           Ledger.Constraints            (TxConstraints)
import qualified Ledger.Scripts                as Scripts
import qualified Ledger.Scripts                as Scripts hiding (validatorHash)
import           Ledger.TimeSlot
import qualified Ledger.Typed.Scripts          as Scripts
import           Ledger.Typed.Tx
import           Ledger.Value
import           Ledger.Value                  as Value

import           Playground.Contract         (IO, ensureKnownCurrencies, printSchemas, stage, printJson)
import           Playground.Contract         (printJson, printSchemas, ensureKnownCurrencies, stage)
import           Playground.Contract         (printJson, printSchemas, ensureKnownCurrencies, stage, ToSchema)
import           Playground.Contract         (ToSchema)
import           Playground.TH               (mkKnownCurrencies, mkSchemaDefinitions)
import           Playground.Types            (KnownCurrency (..))

import           Plutus.Contract
import           Plutus.Contract               as Contract
import           Plutus.Contract.StateMachine
import           Plutus.PAB.Effects.Contract.Builtin (Empty, HasDefinitions (..), SomeBuiltin (..), endpointsToSchemas)
import           Plutus.PAB.Webserver.Types   (ContractActivationArgs (..))
import           Plutus.Trace
import           Plutus.Trace.Emulator         as Emulator
import           Plutus.V1.Ledger.Credential   as Plutus
import           Plutus.V1.Ledger.Crypto       as Plutus
import           Plutus.V1.Ledger.Value        (TokenName (..))

import qualified PlutusTx
import           PlutusTx                      (Data (..))
import           PlutusTx.Prelude
import           PlutusTx.Prelude              hiding (unless)
import           PlutusTx.Prelude              hiding (Semigroup(..), unless)
import           PlutusTx.Prelude              hiding (Semigroup(..), check, unless)
import qualified PlutusTx.Builtins             as Builtins
import           PlutusTx.Builtins             (toBuiltin)
import           PlutusTx.Builtins.Internal    (BuiltinByteString (..))
import           PlutusTx.Code                 (getCovIdx)
import           PlutusTx.Coverage             (CoverageIndex)

import           Prettyprinter                 (Pretty (..), viaShow)

import           Schema                        (ToSchema)

import           Text.Printf                   (printf)
import           Text.Read (readMaybe)

import           Wallet.Emulator.Wallet
import           Wallet.Emulator.Wallet        (knownWallet, mockWalletAddress)
import           Wallet.Emulator.Wallet        (WalletId (..), Wallet (..))
import           Wallet.Types                  (ContractInstanceId (..))

import           Week03.Parameterized
import           Week04.Vesting
import           Week04.Monad
import qualified Week06.Monitor                as Monitor
import           Week06.Token.OffChain
import qualified Week06.Token.OffChain         as Token
import           Week07.EvenOdd
import           Week07.RockPaperScissors
import           Week07.StateMachine

I have also determined (by analyzing all the plutus-pioneer-program-week0x.cabal files) that the following packages are variously included in the various projects:
 build-depends:       aeson
                     , ansi-terminal
                     , base ^>=4.14.1.0
                     , req ^>= 3.9.0
                     , bytestring
                     , cardano-api
                     , cardano-crypto-class
                     , cardano-ledger-core
                     , cardano-ledger-shelley
                     , cardano-wallet-core
                     , containers
                     , data-default
                     , freer-extras
                     , freer-simple
                     , html-entities
                     , lens
                     , openapi3
                     , playground-common
                     , plutus-contract
                     , plutus-ledger
                     , plutus-ledger-api
                     , plutus-ledger-constraints
                     , plutus-pab
                     , plutus-tx
                     , plutus-tx-plugin
                     , plutus-use-cases
                     , prettyprinter
                     , QuickCheck
                     , serialise
                     , tasty
                     , tasty-hunit
                     , tasty-quickcheck

                     , plutus-pioneer-program-week06
                     , plutus-pioneer-program-week08

  if !(impl(ghcjs) || os(ghcjs))
    build-depends: plutus-tx-plugin -any

Is there any comprehensive source that lists what modules are in what packages? The haddock does not appear to be structured in this way.
Even better...

Is there a source that explains and demonstrates how to use each of those modules, including each and every function/type/etc. within each module? I find the haddock and related docs are more of a dense inventory than a teaching tool. Of course, maybe this is exactly what pioneers are meant to build (I'm trying)!

Where do all those packages come from? I assume they are hiding in that massive 67GB nix store I downloaded as part of the setup process, but is there any order to it all?

Considering that each module may have dozens of internally defined types/functions/etc., the dizzying array of unfamiliar terms is causing what I shall dub "magic word syndrome". No question here, just a plea for symptom relief.

I have numerous other questions about how all of this is structured/connected but this is enough for one "question". Thank you one and all.

Is there any comprehensive source that lists what modules are in what packages?

Not really, but Hackage has all the packages available from Hackage as well as providing their documentation.

Is there a source that explains and demonstrates how to use each of those modules,

No, but Hackage (above) does give some of this.

Where do all those packages come from?

Hackage.

I don't think so. I think many (all?) of the plutus packages are not yet on hackage because they are still being developed. Being new to Haskell and Plutus, the boundary between what is hackage and what is plutus is still blurry. But I'll spend some time on hackage working to get at least halfway where I need to be.

Plutus and Cardano ones are not, but the vast majority of the others in the cabal file fragment you posted are.


text:
Easy way to list IPFS directory contents
I have an image directory that I've posted to IPFS with a large number of images in it. When I try to query the directory using an IPFS HTTP gateway, I get a gateway timeout error as I assume the quantity of files is so high. I am using:
https://gateway.ipfs.io/ipfs/bafybeiakb6sdfohwdw7dtdbe..../directory

Is there a simple way to CURL this directory easily into a json file, or some other method where I can get the file list? I also have IPFS downloaded and installed on my Ubuntu server, but can't figure out how to list the files within this directory through there either...

Might be worth checking if the cloudflare IPFS gateway works for you to get access to the directory.
Check out this link here.

source: Stack Exchange

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

sort: votes


text:
could not build or repl plutus-pioneer-program
I'm trying to build the plutus-pioneer program, and I assume that having the environment working is important also in order to build real smart-contracts;
I've set up nix and cache and I'm also sure to be working with the correct commit; I'm trying to build from inside the nix-shell launcehd from the plutus directory (which is assumed to resolve dependecies) but still I get the following error:
cabal build --minimize-conflict-set

Warning: Requested index-state 2021-10-20T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2021-10-19T23:39:06Z).
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: lobemo-scribe-systemd-0.1.0.0 (user goal)
[__1] next goal: libsystemd-journal (dependency of lobemo-scribe-systemd)
[__1] rejecting: libsystemd-journal-1.4.5, libsystemd-journal-1.4.4,
libsystemd-journal-1.4.3, libsystemd-journal-1.4.2, libsystemd-journal-1.4.1,
libsystemd-journal-1.4.0, libsystemd-journal-1.3.4, libsystemd-journal-1.3.3,
libsystemd-journal-1.3.1, libsystemd-journal-1.3.0 (conflict: pkg-config
package libsystemd>=209, not found in the pkg-config database)
[__1] trying: libsystemd-journal-1.2.0
[__2] next goal: base (dependency of lobemo-scribe-systemd)
[__2] rejecting: base-4.14.1.0/installed-4.14.1.0 (conflict:
libsystemd-journal => base>=4.6 && <4.8)
[__2] skipping: base-4.15.0.0, base-4.14.3.0, base-4.14.2.0, base-4.14.1.0,
base-4.14.0.0, base-4.13.0.0, base-4.12.0.0, base-4.11.1.0, base-4.11.0.0,
base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0 (has the same characteristics that caused the
previous version to fail: excluded by constraint '>=4.6 && <4.8' from
'libsystemd-journal')
[__2] rejecting: base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1,
base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0,
base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0,
base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from
non-upgradeable package requires installed instance)
[__2] fail (backjumping, conflict set: base, libsystemd-journal,
lobemo-scribe-systemd)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, libsystemd-journal,
lobemo-scribe-systemd

could anyone please explain to me what am I doing wrong?
additional infos
evrything executed in nix-shell environment
ghc version
ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.4.20210212

cabal varsion
cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library

Did you do "cabal update" before "cabal build" ?

I could only build inside a nix shell. Install nix and then instead of your command type nix-shell. It should build the thing and open the shell. From within that, you can then execute your cabal-commands.

@kindofdev yes I did cabal update, I retryied justy in case and the error persists;

@Jey I'm already in a nix-shell environment

Ok. Did you execute "nix-shell" from within the folder of plutus-apps ?

Did you do cabal build on ppp/code/week0x folder ?

@Jey no I launched nix-shell form the plutus repository, I'm trying from plutus-apps now

@kindofdev yes I tryied cabal build on plutus, plutus-apps and the week0x folders (with aprropriate tags setted before launching the nix-shell from the plutus repo

You need to launch nix-shell from plutus-apps, not plutus

@Jey @kindofdev launching nix-shell from plutus-apps solved the issue; if any of you want to answer the question I'll mark it as soilved, thank you

Try to run nix-shell from within the plutus-apps folder and then (inside this nix shell) navigate to the plutus-pioneer folder to run the cabal command.

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


text:
how to import cardano-cli project into dependecies under cabal?
I've got the following nix-shell:
let
   src = builtins.fetchGit {
      url = "git@github.com:input-output-hk/plutus-apps.git";
      # url = "https://github.com/input-output-hk/plutus-apps.git";
      ref = "main";
      # rev = "4ecc1d9350e9897557d2a15699a9ace7df665a01";
    };
    in
let
  packages = import "${src}/default.nix" {};
in
with packages;
with pkgs;

mkShell {
  src = builtins.toString ./.;

  buildInputs = [
    wget gnupg coreutils
    which less curl ripgrep tree
    gitMinimal openssh man-db
  ] ++ (with plutus-apps; [
    haskell-language-server
    cabal-install
    hlint
    (haskell.project.ghcWithPackages (ps: with ps; [
      playground-common
      plutus-contract
      plutus-ledger
      plutus-ledger-api
      plutus-pab
      plutus-tx
      plutus-tx-plugin
      plutus-doc
      plutus-use-cases
      # cardano-node.cardano-cli
      freer-extras]))]);
  GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
  LANG = "C.UTF-8";
  LC_ALL = "C.UTF-8";
  PAGER="less -R";
  shellHook = ''
    ulimit -Sv 8388608
    ulimit -v 10485760
  ''; }

Under cabal project it always fails with error if I just add cardano-cli in build-depends
Can someone help ?

Just modify the following lines:
let packages = import "${src}/default.nix" {};
cardano_pkgs = import "${cardano-node}/shell.nix" {};
in
  with packages;
  with pkgs; with cardano_pkgs;

and add cardano-cli to packages search
 ...
 plutus-doc
 plutus-use-cases
 cardano-cli
 freer-extras]))]);
 ...


text:
How to apply show to TxOutAnyEra datatype from cardano-cli sources?
Example:
testTxOut :: IO ()
testTxOut = do
  let
    testInput = "addr_test1vqwvs32x3wg5ea2l5tr7t93hpta8arwxllr4ey96dhl5d7sytaf9n + 1000000 lovelace"
  case (OutBuilder.getTxOutFrom testInput) of
     Left err -> putStrLn $ show err
     Right tx -> putStrLn $ "passed" -- HOW TO SHOW IT HERE

almost from the Cardano.CLI.Shelley.Parsers because it does not export one
module BuildTxOut
  (getTxOutFrom)
where

import Cardano.Api
import Cardano.CLI.Types
import Cardano.CLI.Shelley.Parsers

import qualified Text.Parsec as Parsec

import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Token as Parsec

parseTxOutAnyEra2 :: Parsec.Parser (TxOutDatumAnyEra -> TxOutAnyEra)
parseTxOutAnyEra2 = do
    addr <- parseAddressAny
    Parsec.spaces
    -- Accept the old style of separating the address and value in a
    -- transaction output:
    Parsec.option () (Parsec.char '+' >> Parsec.spaces)
    val <- parseValue
    return (TxOutAnyEra addr val)

getTxOutFrom :: String -> Either Parsec.ParseError (TxOutDatumAnyEra -> TxOutAnyEra )
getTxOutFrom s = Parsec.parse parseTxOutAnyEra2 "Wrong" s

Here is simplified version got from cardano-cli Parsers that works.
module BuildTxOut
where

import Cardano.Api
import Cardano.CLI.Types
import Cardano.CLI.Shelley.Parsers

import qualified Text.Parsec as Parsec

import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Token as Parsec

parseTxOutAnyEra2 :: Parsec.Parser (TxOutDatumAnyEra -> TxOutAnyEra)
parseTxOutAnyEra2 = do
    addr <- parseAddressAny
    Parsec.spaces
    -- Accept the old style of separating the address and value in a
    -- transaction output:
    Parsec.option () (Parsec.char '+' >> Parsec.spaces)
    val <- parseValue
    return (TxOutAnyEra addr val)

pTxOut ::  Parsec.Parser TxOutAnyEra
pTxOut = parseTxOutAnyEra2 <*> pTxOutDatum

-- INFO: can be modified to accept all functionality
-- see original implementation

pTxOutDatum ::  Parsec.Parser TxOutDatumAnyEra
pTxOutDatum = pure TxOutDatumByNone

getTxOut :: String -> Either Parsec.ParseError TxOutAnyEra
getTxOut s = Parsec.parse pTxOut "Wrong" s


text:
What is the role of datum in spending a transaction
So i am going over the plutus-pionner-program right now and he keeps on iterating this point. Transaction that spends a script output need to provide the datum of that script. Transaction that send money to a script address just need to provide the hash of that script. What is the point of all this ? I thought datum was used to keep track of the state of the script.What role does datum play in using a output from a script address and what role does datum play in sending to a script address.

I thought datum was used to keep track of the state of the script.

It can be and often is. This is how its used in a StateMachine, for example.
The cardano chain is 'lean': only the necessary information to ensure the integrity of the chain is required and kept on the chain.
A script is required and run only if a transaction spends from the address, and that script requires the datum to be available.
Sending to a script address from  a payment address doesn't require the script to be run. In the minimalist spirit the chain needs only to record the hash of the datum to ensure that when the UTXO is spent this spending transaction has provided the right datum.
The design requires "off-chain" components of a DApp to take a much greater role for handling state than, say, ethereum. Whatever builds a transaction is responsible for ensuring that all datums and hashes are sensible ones.
Use of datum hashes has been flagged as a pain point:
https://github.com/cardano-foundation/CIPs/tree/master/CIP-0032


text:
Is there good examples for building a transaction using serialization-lib?
I am trying to find an example of building a simple Tx of ADA in, ADA out type of transaction using sterilization-lib to get cbor and pass it to Wallet.signTx(cbor). developer.cardano.org has a great cli documentation and walkthrough, if only the same could be available for web-based application.

This answer is a little sidetracked, But may be useful for you and others :)
If you are open to integrating your application with Typhon Wallet then its DApp connector is very simple and developer-friendly which does not require you to build a transaction in your application.
Below is a simple payment transaction using Typhon Dapp Connector,
const paymentTransactionResponse = await window.cardano.typhon.paymentTransaction({
  outputs: [
    {
      address:
        "addr_test1qz7jw975stagnvs00wsjny6y6gpazn86yvwcm2vy02j3up7mt68vuzvz4nzgs00x0shrgywvy674v6r2zcs8fxvvq27qfjq8np",
      amount: "6000000",
    },
  ],
});

that's all needed in your application to build a transaction, You can also add tokens, metadata, datum, and minting with this.
More examples, https://docs.typhonwallet.io/examples/paymentTransaction.html#sending-ada

NOTE: Typhon Dapp Connector does not follow CIP-30

Thank you so much for the answer. I will give it a look. But I am trying to use the more general CIP0030 convention in order to build wallet-agnostic dapps. Nami also has simple methods like the one above. These are great solutions for quick fix, however, being wallet-agnostic I guess is a great feature and also assure longevity of the dapp

I completely agree with your point on dapp needs to be wallet agnostic, but this is not a solution for a quick fix instead this approach is more developer-friendly. Dapp developers job is not to read cardano specs, do UTXO selection, fee calculation and what more, Instead developer should be more focused on building DApp application logic.

There are examples here:
https://developers.cardano.org/docs/get-started/cardano-serialization-lib/generating-transactions
https://developers.cardano.org/docs/get-started/cardano-serialization-lib/create-react-app
And I have created a repo with a working example of how to connect to web-wallets, build and submit transactions using the serialization lib:
https://github.com/dynamicstrategies/cardano-wallet-connector
All the best!


text:
Dapp connection with mobile browser
How do I connect my cardano website (dapp) with cardano mobile wallet. currently, I am using yoroi-frontend for desktop browsers.

You will be more likely to get answers if you follow the guidelines in [ask]

@gRebel Thanks a lot!

Look in the window object for window.cardano and then look for the property yoroi and then you can interact with the public API.
To enable the wallet use window.cardano.yoroi.enable(). This will return an object with the endpoints to interact with the wallet or will fail if the user does not allow to read the wallet.


text:
Connect Unity 3D game with cardano
I am creating a play to game in Unity 3D. What is the best way to authenticate wallet of the users and send cardano native tokens.

You can use cardano-unity SDK for this purpose.


text:
How to sign transaction externally?
I am using the cardano-serialization-lib to derive addresses and create a transaction unsigned. I am then passing that transaction hash in CBOR to an external program to handle the signing process. I am unsure how that works because with the library, we sign the transaction by creating a new Transaction Object, passing in the witnesses and body of the previous transaction. See below
const signed_transaction = await cardanolib.Transaction.new(
  newTx.body(),
  witnesses,
  undefined //metadata
);

I want to to this on my own, but I'm not sure exactly what gets signed. I have tried signing the transaction body with the curve25519 algorithm, but I am getting a different hash from that transaction made this way. I am not sure if I am understanding how the signing process works for the transaction. What exactly gets signed and how do I create that transaction?

Did you ever figure this out? Might have to go through the node source code :-/

@noone392 yes I found a solution. it works the same way as the signing works in an all hot implementation with CSL. Ill give you a hint, there exists some function to grab the hash and you have to go about making the witnesses object yourself. Going to require you to step through the source code a bit, but nothing crazy.


text:
Best approach to retrieving transaction by id
The Cardano ecosystem has a mountain of various tools for querying the chain. Here are a few I'm aware of

Ogmios
Cardano-Wallet
dbsync
Cardano-graphql
koios

We would like to retrieve all information related to a transaction (sender, receiver, amounts, insertion slot, etc). What is the best tool for doing that as of today?

Here is how you do it using cardano-graphql:
  {
    transactions(where: { hash: { _eq: "4c827fe1c193de7924b19696965d21a34df04fed99a35428b22d475dbc999cc3"} })   {
      block {
        epoch {
          number
        }
        epochNo
        fees
        forgedAt

        hash
      }
      blockIndex
      deposit
      fee
      hash
      inputs {
        address
          txHash
      }
      invalidBefore
      invalidHereafter
      scriptSize
      size
      totalOutput
      includedAt
      validContract
    }
  }

You can use Dandelion and paste this code in there to retrieve the information requested. You can even play with the different data types (check the "DOCS" tab for reference) and add/remove the ones you want.
If you want a real implementation of this, you can refer to the following TypeScript code:
import axios from "axios";

export async function getTransaction(txHash: string) {

  const url = `https://graphql-api.testnet.dandelion.link`;

  const headers = {
    "content-type": "application/json"
  };

  const query = `
  {
    transactions(where: { hash: { _eq: "${txHash}"} })  {
      block {
        epoch {
          number
        }
        epochNo
        fees
        forgedAt

        hash
      }
      blockIndex
      deposit
      fee
      hash
      inputs {
        address
          txHash
      }
      invalidBefore
      invalidHereafter
      scriptSize
      size
      totalOutput
      includedAt
      validContract
    }
  }
`;

  const graphqlQuery = {
      "query": query
  };

  const response = await axios({
    url,
    method: 'post',
    headers: headers,
    data: graphqlQuery
  });

  return response.data;

}

I'm using axios library to handle the request to Dandelion.

GraphQL is probably the easiest in my option and offers the most room for growth.
The public GraphQL API hosted by Dandelion (https://graphql-api.testnet.dandelion.link) is a great place to learn and get started with GraphQL.   I suggest hosting your own GraphQL Servers so you can query larger and more advanced data sets.
Blockfrost.io and Tangcrypto are honorable mentions, which will allow you get data from the Cardano Blockchain but have daily free limits. It is possible to get mostly all the data you need from one of the Blockfrost or Tangcrypto, but you will mosy likely need to execute multiple queries to get all the info you want.
There is another open-source API that is free and in the process of being created. I found it a few months ago but forgot the link, it was like the blockfront API but a little more in-depth and advanced, and it was all free with unlimited queries. If I find it ill again ill add it.
Short answer GraphQL is the best, and blockfrost is the most convenient.
@RdLrT also suggested https://api.koios.rest/

I assume you meant koios? It's already part of OP's list


text:
minted NFT is shown as solid color of picture in Nami wallet
I have some questions about NFT mint.
I minted NFT using Nami Wallet API, but sometimes error occurred.

I need to mint several NFTs at once. So I submit minting transactions in for loop.
But sometimes transactions make Utxo failure error. I think it's because the new transaction's Utxo input is not same as the old transacion's Utxo input. Help me to mint several NFTs at once.
And sometimes Minted NFT is shown as solid color picture in Nami wallet.
I checked that image in IPFS and it same as what I uploaded. But why Nami wallet can't include it?

Try to have the asset_name and name the same:
"asset_name": "TestNFT1",
"name": "TestNFT1",

For some reason, when they are different, Nami shows the solid color, in ccvault/Eternl works well with spaces.


text:
Select only one UTxO from script address
I need to get only one UTxO from the script address, where its datum hash matches the redeemer hash. For example I have locked two UTxO with 10 Ada  and the DatumHash "house" at the script and only want to unlock one of them.
I use the guessing game example of the Plutus Playground, but it unlocks both UTxO when the Redeemer has the same hash:
guess = endpoint @"guess" @GuessParams $ \(GuessParams theGuess) -> do
    -- Wait for script to have a UTxO of a least 1 lovelace
    utxos <- fundsAtAddressGeq gameAddress (Ada.lovelaceValueOf 1)

    let redeemer = clearString theGuess
        tx       = collectFromScript utxos redeemer

    let hashedSecretWord = findSecretWordValue utxos
        isCorrectSecretWord = fmap (`isGoodGuess` redeemer) hashedSecretWord == Just

    void (submitTxConstraintsSpending gameInstance utxos tx)

-- | Find the secret word in the Datum of the UTxOs
findSecretWordValue :: Map TxOutRef ChainIndexTxOut -> Maybe HashedString
findSecretWordValue =
  listToMaybe . catMaybes . Map.elems . Map.map secretWordValue

-- | Extract the secret word in the Datum of a given transaction output is possible
secretWordValue :: ChainIndexTxOut -> Maybe HashedString
secretWordValue o = do
  Datum d <- either (const Nothing) Just (_ciTxOutDatum o)
  PlutusTx.fromBuiltinData d

At which part do I have to change the code, so it only unlocks one UTxO (best case: a random choice of both)?

You may need to update this part:
utxos <- fundsAtAddressGeq gameAddress (Ada.lovelaceValueOf 1)
Try:
utxos <- Map.take 1 <$> fundsAtAddressGeq gameAddress (Ada.lovelaceValueOf 1)
You need to change the import on top to
import PlutusTx.Prelude hiding (pure) so as to use <$>.
I have tried it using 4 wallets (somehow the Playground does not allow one wallet to make multiple calls) and it worked.


text:
Cardano-cli error: "Invalid argument `"type":'"
I'm new and I'm following cardano developers tutorial to create NFT. I arrived at some modified code for what I wanted to do. But get this "Invalid argument `"type":'" error. When building the transaction for minting. The other part of the transaction that is not the minting parts seems to work because I can make ordinary transaction and I'm using the testnet, running a testnet node with zsh. Cardano-cli version 1.33. Macbook pro M1 pro, macOS 12.2.1.
Here is the code:
cardano-cli query protocol-parameters \
--testnet-magic 1097911063 \
--out-file $HOME/nft/protocol.json

tokenname="5465737469616e"
tokenamount=1
txhash="989b03feb8885db90c6ca44065fe950a2208ba60c6d1b1f17aef87dcfd13c03b"
txix=0
policyid=$(cat $HOME/nft/policy/policyID)
script=$(cat $HOME/nft/policy/policy.json)
addressOut=$(cat $HOME/cardanotestwallet/keys/payment1.addr)
addressIn=$(cat $HOME/receive-ada-sample/keys/payment.addr)

fee=$(cardano-cli transaction build-raw \
--alonzo-era \
--tx-in ${txhash}#${txix} \
--tx-out ${addressOut}+0+"${tokenamount} ${policyid}.${tokenname}" \
--tx-out ${addressIn}+0 \
--mint="${tokenamount} ${policyid}.${tokenname}" \
--minting-script-file ${script} \
--invalid-hereafter ${slotnumber} \
--fee 0 \
--metadata-json-file $HOME/nft/metadata.json \
--out-file $HOME/nft/matx.raw

cardano-cli transaction calculate-min-fee \
--tx-body-file $HOME/nft/matx.raw \
--tx-in-count 1 \
--tx-out-count 2 \
--witness-count 1 \
--testnet-magic 1097911063 \
--protocol-params-file $HOME/nft/protocol.json)

fee=${fee%" Lovelace"}

funds=99829967
output=1700000
slotnumber=53264773
change=$((${funds}-${output}-${fee}))

cardano-cli transaction build-raw \
--alonzo-era \
--tx-in ${txhash}#${txix} \
--tx-out ${addressOut}+${output}+"${tokenamount} ${policyid}.${tokenname}" \
--tx-out ${addressIn}+${change} \
--mint="${tokenamount} ${policyid}.${tokenname}" \
--minting-script-file ${script} \
--invalid-hereafter ${slotnumber} \
--fee ${fee} \
--metadata-json-file $HOME/nft/metadata.json \
--out-file $HOME/nft/matx.raw

...And here is the full error code:
Invalid argument `"type":'

Usage: cardano-cli transaction build-raw
            [ --byron-era
            | --shelley-era
            | --allegra-era
            | --mary-era
            | --alonzo-era
            ]
            [--script-valid | --script-invalid]
            (--tx-in TX-IN
              [--tx-in-script-file FILE
                [(--tx-in-datum-file FILE | --tx-in-datum-value JSON VALUE)
                  ( --tx-in-redeemer-file FILE
                  | --tx-in-redeemer-value JSON VALUE
                  )
                  --tx-in-execution-units (INT, INT)]])
            [--tx-in-collateral TX-IN]
            [--required-signer FILE | --required-signer-hash HASH]
            [--tx-out ADDRESS VALUE
              [ --tx-out-datum-hash HASH
              | --tx-out-datum-hash-file FILE
              | --tx-out-datum-hash-value JSON VALUE
              | --tx-out-datum-embed-file FILE
              | --tx-out-datum-embed-value JSON VALUE
              ]]
            [--mint VALUE
              (--mint-script-file FILE
                [(--mint-redeemer-file FILE | --mint-redeemer-value JSON VALUE)
                  --mint-execution-units (INT, INT)])]
            [--invalid-before SLOT]
            [--invalid-hereafter SLOT]
            [--fee LOVELACE]
            [--certificate-file CERTIFICATEFILE
              [--certificate-script-file FILE
                [
                  ( --certificate-redeemer-file FILE
                  | --certificate-redeemer-value JSON VALUE
                  )
                  --certificate-execution-units (INT, INT)]]]
            [--withdrawal WITHDRAWAL
              [--withdrawal-script-file FILE
                [
                  ( --withdrawal-redeemer-file FILE
                  | --withdrawal-redeemer-value JSON VALUE
                  )
                  --withdrawal-execution-units (INT, INT)]]]
            [--json-metadata-no-schema | --json-metadata-detailed-schema]
            [--auxiliary-script-file FILE]
            [--metadata-json-file FILE | --metadata-cbor-file FILE]
            [--genesis FILE | --protocol-params-file FILE]
            [--update-proposal-file FILE]
            --out-file FILE

  Build a transaction (low-level, inconvenient)

  Please note the order of some cmd options is crucial. If used incorrectly may produce undesired tx body. See nested [] notation above for details.
Command failed: transaction calculate-min-fee  Error: /Users/myyenongianggiang/nft/matx.raw: /Users/myyenongianggiang/nft/matx.raw: openBinaryFile: does not exist (No such file or directory)
createN.sh: line 38: 99829967-1700000-: syntax error: operand expected (error token is "-")

Am I missing something really easy? can't find out what the problem is, would be very happy for getting some help. Been stuck...
Thank you very much in advance.
//Koki

The error states a missing file: matx.raw
I sugguest separating the build-raw and calc fee commands.
Edit: $slotnumber was not set before use in the first 'build-raw' statement.
Edit: Try the steps below manually one by one to confirm that things are as we expect before carrying on. Set the slotnumber to the appropriate value.
Edit: --minting-script-file expects a file path not data
Edit: User recreated the policy ID and the policy script - now working ok.
#Step 0 - Remove $HOME/nft/matx.raw if it exists
rm $HOME/nft/matx.raw

#Step 1
cardano-cli query protocol-parameters \
--testnet-magic 1097911063 \
--out-file $HOME/nft/protocol.json

#Step 2
tokenname="5465737469616e"
tokenamount=1
txhash="989b03feb8885db90c6ca44065fe950a2208ba60c6d1b1f17aef87dcfd13c03b"
txix=0
policyid=$(cat $HOME/nft/policy/policyID)
#script=$(cat $HOME/nft/policy/policy.json)
script="$HOME/nft/policy/policy.json"
addressOut=$(cat $HOME/cardanotestwallet/keys/payment1.addr)
addressIn=$(cat $HOME/receive-ada-sample/keys/payment.addr)

slotnumber=53264773

#Step 3 - Check each is set correctly
echo "This is step 3"
echo "A $txhash "
echo "B $txix"
echo "C $addressOut"
echo "D $tokenamount"
echo "E $policyid"
echo "F $tokenname"
echo "G $addressIn"
echo "H $script"
echo "I $slotnumber"

echo "About to run the first build-raw command"

cardano-cli transaction build-raw \
--alonzo-era \
--tx-in ${txhash}#${txix} \
--tx-out ${addressOut}+0+"${tokenamount} ${policyid}.${tokenname}" \
--tx-out ${addressIn}+0 \
--mint="${tokenamount} ${policyid}.${tokenname}" \
--minting-script-file ${script} \
--invalid-hereafter ${slotnumber} \
--fee 0 \
--metadata-json-file $HOME/nft/metadata.json \
--out-file $HOME/nft/matx.raw

echo "After the first build-raw"

Also, keep in mind that each command should be on one line, or use the line continuation character \ if split over multiple lines.

Thank you for your quick response. I tried your suggestion as mentioned and got the exact same error. And yes everything is on same line or "" is used when multiple lines. The "" don't seems to show when posting here. However they are there .

Thanks for the update.
I just noticed that slotnumber does not appear to be set before the first 'build-raw' attempt.
--invalid-hereafter ${slotnumber}
Can you set it at the top before running 'cardano-cli transaction build-raw...' eg  slotnumber=53264773

Okey. Tried moving the slotnumber higher above the first build-raw attempt, but still exact same error code.

slotnumber needs to be set before you use it eg BEFORE the line beginning:
fee=$(cardano-cli transaction build-raw...... Set it at the TOP right after the line: addressIn=$(cat....

Builds-raw and calc fee commands are now separated as suggested and slot number is set before first build-raw command (right after/under addressIn). Same error code created.

Can you try these steps in my updated answer.

Can you link in the document guide that you are following.

About to run the first build-raw
Command failed: transaction build-raw  Error: {
"type": "all",
"scripts":
[
{
"type": "before",
"slot": 53612937
},
{
"type": "sig",
"keyHash": "13589c57f20c76a46b508cca1f4434d0a1e3f568c3f359c02d2a8327"
}
]
}: {
"type": "all",
"scripts":
[
{
"type": "before",
"slot": 53612937
},
{
"type": "sig",
"keyHash": "13589c57f20c76a46b508cca1f4434d0a1e3f568c3f359c02d2a8327"
}
]
}: openBinaryFile: does not exist (No such file or directory)
After the first build-raw

Seems something wrong with my policy script?
I follow these guides:

https://developers.cardano.org/docs/native-tokens/minting-nfts#crafting-the-transaction
https://developers.cardano.org/docs/native-tokens/minting
https://devslug.com/how-to-mint-an-nft-on-cardano-testnet-using-the-command-line

Error at step #3. See above comment.

Ok good, that's moving along. One thing I noticed is that '--minting-script-file' accepts a file path. In your case it should be: '--minting-script-file $HOME/nft/policy/policy.json'

When I change from variable to path as suggested, I get this error instead:
About to run the first build-raw command
Command failed: transaction build-raw  Error: The "--mint" flag specifies an asset with a policy Id, but no corresponding monetary policy script has been provided as a witness (via the "--minting-script-file" flag). The policy Id in question is: 3d700373099c2b932990d812c02909223bc6587f2ef25b587e8d03e7
After the first build-raw

Ok good, that has progressed to the next issue. It looks like the policy.json and/or policyID need checking. Back up a few steps and look closely at how these are created and if there is something missing or incorrect.

Yes you are right! I recreated the policy ID and the policy script and together with the filepath change earlier it now works. Thanks a lot man!

That's great, glad to help


text:
What is the derivation path in a Cardano address?
It comes from CCVault.  I saw it in the 'Receive' tab.
You can specify a part of the address, or a derivation path like "m/1852'/1815'/0'/1/32", "1815 0 1 32" or "0 1 32".

...and what do the various numbers mean?

Cardano follows the BIP32-ed25519 standard for HD key derivation. Read more about it here.
In a nutshell, a virtually infinite number of public/private addresses/keys pairs can be derived from a single master key-pair, which itself is derived from an entropic secret (usually in the form of a 24-word mnemonic). Staking (and all other types of) keypairs on Cardano can, in principle, be generated from the same set of root keys, though this is not recommended unless you know how to manage private keys yourself.
Keys used in Cardano transactions are 5 derivations away from the master seed. Your "wallet" is the middle number x in that whole mess there.
m / 1852' / 1815' / x' / 0, 1, or 2 / n
where:

m is the mnemonic
1852 is the coin (ADA) ID#
1815 is an extra, unused path
x is the account/wallet index #
0/1 are wallet x's payment/change keys-paths, and 2 is it's staking key-path
n is the key #

Also, the ' symbol means hardened derivation is used, meaning the child keypairs will be able to make keypaths of their own. if hardened derivation is not useed, the child keys will be "infertile".
Many unique wallets with unique staking keys can be derived from the same master seeds. Unfortunately, most wallet software like Daedalus and or Yoroi don't do this by default. The good news is this can all be done manually using CLI tools!

great answer, thank you

The link has been moved, here's the latest working link: https://input-output-hk.github.io/adrestia/cardano-wallet/concepts/hierarchical-deterministic-wallets


text:
Will Ouroboros Crypsinous be included in Ouroboros Omega?
Last year at the 2021 Cardano Summit, IOHK provided a YouTube video that overviews the Ouroboros family of protocols developed since 2016, the consensus enhancements and security features they provide, and how Ouroboros Omega will be the culmination of this research.
IOHK published a paper in 2019 on privacy-preserving proof of stake called Ouroboros Crypsinous. The aim of the research was to provide a formal treatment of how a private ledger (ie, private transactions and private balances) could be attained using zk-SNARKS in a proof-of-stake consensus mechanism. The research seems to be inspired by Zcash (then called Zerocash).
There hasn't really been any mention of progress or development of Ouroboros Crypsinous since. Does anyone know if this work will be included in Ouroboros Omega? If not, do you know the reason? Is there still regulatory uncertainty about the use of private ledgers in public blockchains?

There is currently no plan for IOG to implement Ouroboros Crypsinous
https://iohk-io.netlify.app/en/blog/posts/2022/06/03/from-classic-to-chronos-the-implementations-of-ouroboros-explained/


text:
can't understand which part of the code is not "PlutusTx"
I'm trying to  write a very simple NFT minting policy myself and I can't get rid of the following error
Program error: GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable Ledger.Typed.Scripts.MonetaryPolicies.wrapMintingPolicy
            No unfolding

Context: Compiling expr: Ledger.Typed.Scripts.MonetaryPolicies.wrapMintingPolicy

Context: Compiling expr: Ledger.Typed.Scripts.MonetaryPolicies.wrapMintingPolicy
                           @ NFTVM.Validator.ThreadTokenPolicy.TTRedeemer

Context: Compiling expr: Ledger.Typed.Scripts.MonetaryPolicies.wrapMintingPolicy
                           @ NFTVM.Validator.ThreadTokenPolicy.TTRedeemer
                           NFTVM.Validator.ThreadTokenPolicy.$fUnsafeFromDataTTRedeemer

Context: Compiling expr: Ledger.Typed.Scripts.MonetaryPolicies.wrapMintingPolicy
                           @ NFTVM.Validator.ThreadTokenPolicy.TTRedeemer
                           NFTVM.Validator.ThreadTokenPolicy.$fUnsafeFromDataTTRedeemer
                           (NFTVM.Validator.ThreadTokenPolicy.makeThreadTokenLogic
                              utxo_ref' tn')

Context: Compiling expr: \ (tn' :: Plutus.V1.Ledger.Value.TokenName) ->
                           Ledger.Typed.Scripts.MonetaryPolicies.wrapMintingPolicy
                             @ NFTVM.Validator.ThreadTokenPolicy.TTRedeemer
                             NFTVM.Validator.ThreadTokenPolicy.$fUnsafeFromDataTTRedeemer
                             (NFTVM.Validator.ThreadTokenPolicy.makeThreadTokenLogic
                                utxo_ref' tn')

Context: Compiling expr: \ (utxo_ref' :: Plutus.V1.Ledger.Tx.TxOutRef)
                           (tn' :: Plutus.V1.Ledger.Value.TokenName) ->
                           Ledger.Typed.Scripts.MonetaryPolicies.wrapMintingPolicy
                             @ NFTVM.Validator.ThreadTokenPolicy.TTRedeemer
                             NFTVM.Validator.ThreadTokenPolicy.$fUnsafeFromDataTTRedeemer
                             (NFTVM.Validator.ThreadTokenPolicy.makeThreadTokenLogic
                                utxo_ref' tn')

reading this answer from a similar question I understood that this kind of error rises when using a non-inlineable piece of code
from the error message I can also understand that the incriminated code is the following
threadTokenPolicy :: TTParams -> Scripts.MintingPolicy
threadTokenPolicy params = Scripts.mkMintingPolicyScript (
        $$(PlutusTx.compile [|| wrappedMintingPolicy ||])
        `PlutusTx.applyCode` PlutusTx.liftCode params
    )
    where
        wrappedMintingPolicy = Scripts.wrapMintingPolicy @TTRedeemer . makeThreadTokenLogic

and I can confirm my assumption since removing this part removes also the error
can anyone please explain to me which part is the "non-inlineable" part?

I'll leave here the full code in case it can help having more context
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings   #-}

{-# LANGUAGE NoImplicitPrelude   #-}

{-# LANGUAGE DeriveAnyClass      #-}
{-# LANGUAGE DeriveGeneric       #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE NumericUnderscores  #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications    #-}
{-# LANGUAGE TypeFamilies        #-}
{-# LANGUAGE TypeOperators       #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# LANGUAGE MultiParamTypeClasses #-}

module NFTVM.Validator.ThreadTokenPolicy (
    TTRedeemer(..), -- exporting the type and all his constructors ( Start and Close )
    makeThreadTokenLogic,
    threadTokenPolicy
    )
where

import qualified Plutus.V1.Ledger.Contexts as Ctx
    (
        ScriptContext, scriptContextTxInfo,
        ownCurrencySymbol,
        TxInfo, txInfoSignatories, txInfoMint
    )
import qualified Plutus.V1.Ledger.Value    as Value
    (
        CurrencySymbol,
        TokenName,
        flattenValue
    )
import qualified Plutus.V1.Ledger.Crypto   as Cryptography (PubKeyHash)-- CurrencySymbol
import qualified PlutusTx.Trace            as Trace (traceError, traceIfFalse)-- traceError , traceIfFalse
import qualified PlutusTx
    (
        makeLift,
        makeIsDataIndexed,
        compile, applyCode, liftCode
    )
import Ledger
    (
        scriptHashAddress,
        TxOutRef,
        TxInfo (txInfoInputs),
        TxInInfo (txInInfoOutRef),
        TokenName
    )
import qualified Ledger.Typed.Scripts      as Scripts
    (
        MintingPolicy, wrapMintingPolicy
    )
import qualified Ledger.Scripts            as Scripts
import           PlutusTx.Prelude          as Prelude
    (
        Bool (False), Integer,
        any, length,
        (==), (/=), (&&), (.), (!!),
        head, map, elem
    )
import PlutusTx (makeIsDataIndexed)

data TTParams = TTParams {
    getTokenName :: Value.TokenName,
    getUTxO :: Ledger.TxOutRef
}

PlutusTx.makeLift ''TTParams

data TTRedeemer = Start | Close

PlutusTx.makeIsDataIndexed ''TTRedeemer [
                                            ( 'Start , 0 ), -- Constr 0 [] -- means start, aka mints the thread NFT
                                            ( 'Close , 1 )  -- Constr 1 [] -- means close, aka burns the thread NFT
                                        ]

{-# INLINEABLE makeThreadTokenLogic #-}
makeThreadTokenLogic :: TTParams -> TTRedeemer -> Ctx.ScriptContext -> Bool
makeThreadTokenLogic params action ctx =
    correctUTxO &&
    case action of
        Start -> ensureTokenMinted
        Close -> ensureTokenBurned
        _ -> Trace.traceError "unexpected redeemer"
    where
        txInfos :: Ctx.TxInfo
        txInfos = Ctx.scriptContextTxInfo ctx

        correctUTxO :: Bool
        correctUTxO = getUTxO params `elem` map txInInfoOutRef (txInfoInputs txInfos)

        ensureOnlyThisTokenMinted_ForAmount :: Integer -> Bool
        ensureOnlyThisTokenMinted_ForAmount amtToMint =
            case Value.flattenValue (Ctx.txInfoMint txInfos) of
                -- if the list contains only one minting policy
                [( currSym, tn, amt )] -> amt == amtToMint && currSym == Ctx.ownCurrencySymbol ctx && getTokenName params == tn
                -- else fails
                _ ->  Trace.traceError "txInfoMint value contained more than 1 element; only 1 token minted is allowed"

        ensureTokenMinted :: Bool
        ensureTokenMinted = ensureOnlyThisTokenMinted_ForAmount 1

        ensureTokenBurned :: Bool
        ensureTokenBurned = ensureOnlyThisTokenMinted_ForAmount (-1)

threadTokenPolicy :: TTParams -> Scripts.MintingPolicy
threadTokenPolicy params = Scripts.mkMintingPolicyScript (
        $$(PlutusTx.compile [|| wrappedMintingPolicy ||])
        `PlutusTx.applyCode` PlutusTx.liftCode params
    )
    where
        wrappedMintingPolicy = Scripts.wrapMintingPolicy @TTRedeemer . makeThreadTokenLogic

Update
I do get the same error in the same kind of error compiling the Week05.NFT code from the plutus-pioneer-program;
migth that be something wrong with any evironment configuration?

The name wrappedMintingPolicy in the where statement is not indicated with the INLINABLE pragma. Maybe adding the line
{-# INLINEABLE wrappedMintingPolicy #-}
solves the problem.

If that was the case shouldn't I have the same error inside the makeThreadTokenLogic function?

Maybe GHC applies the INLINEABLE hint to all where clauses as well. And then wrappedMintingPolicy is the only function not "covered by it".

As a second answer, you can also try to inline wrappedMintingPolicy by hand by doing:
threadTokenPolicy :: TTParams -> Scripts.MintingPolicy
threadTokenPolicy params = Scripts.mkMintingPolicyScript (
        $$(PlutusTx.compile [|| \x -> Scripts.wrapMintingPolicy @TTRedeemer (makeThreadTokenLogic x) ||])
        `PlutusTx.applyCode` PlutusTx.liftCode params
    )


text:
Building alonzo transaction using cardano-cli and signing it with serialization-lib
I created an API that based on a request builds the body of a transaction with cardano-cli and returns the cbor to the front-end. In the front-end, I'm using the cardano-serialization-lib to load the transaction and send it to the wallet, requesting a signature.
This is the code in the front-end (I'm using the new --cddl-format option, so no need to clear the witness set)
export async function signTx(api, cbor) {
  // load tx cbor
  const tx = Loader.Cardano.Transaction.from_bytes(Buffer.from(cbor, "hex"));

  const witneses = await cardano.signTx(
    Buffer.from(tx.to_bytes(), "hex").toString("hex")
  );

  const signedTx = Loader.Cardano.Transaction.new(
    tx.body(),
    Loader.Cardano.TransactionWitnessSet.from_bytes(
      Buffer.from(witneses, "hex")
    )
  );

  const txhash = await api.submitTx(
    Buffer.from(signedTx.to_bytes(), "hex").toString("hex")
  );

  return txhash;
}

The wallet asks me to sign the transaction nicely and I'm able to confirm it, but when it tries to submit the transaction, it gives me this error
transaction submit error ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (PPViewHashesDontMatch (SJust (SafeHash \"e84ed35a172ed46da854a132db880a608f73e0e61d385c9475a5b14fe4b9e4a9\")) SNothing),UtxowFailure (WrappedShelleyEraFailure (MissingScriptWitnessesUTXOW (fromList [ScriptHash \"1ef6f56f2e174d5e0328f24aa30d55b81f3bf871361f9280dd4090c2\"]))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (UtxosFailure (CollectErrors [NoRedeemer (Minting (PolicyID {policyID = ScriptHash \"1ef6f56f2e174d5e0328f24aa30d55b81f3bf871361f9280dd4090c2\"})),NoWitness (ScriptHash \"1ef6f56f2e174d5e0328f24aa30d55b81f3bf871361f9280dd4090c2\")]))))])

I suppose it has to do with the fact that my transaction has minting policies (with redeemers) and an embeded datum and for some reason they are not present. If that's the case, how can I add them? Do I need to add the redeemers once in cardano-cli and again in the serialization-lib? If it's not the case, what am I doing wrong?
Also, if I do need to add the redeemers to the witness-set in the serialization-lib, is there any way I can send a "witness file" from the back-end and simply load it?

both tools serialize in different ways.. even hashes in different ways, i would suggest to take a look to the CBOR And try to see whats going on there.


text:
Not enough ADA leftover to include non-ADA assets in a change address
I am getting the error when using @emurgo\cardano-serialization-lib-asmjs
txBuilder.add_change_if_needed(shelleyChangeAddress)
throws an exception
Not enough ADA leftover to include non-ADA assets in a change address

I'm not familiar with that code, but in general moving native assets needs to go along with some ADA eg 1 or 2 ADA.
Does your input UTxO have enough ADA balance to cover everything eg fees and output ADA?
If not then you can add a second input UTxO that has more ADA into the transaction.

thanks, its a stange issue. if i execute couple of time the same code it work after couple of retries. but I have a different problem in submitting the transaction. Sign the tx is fine Error: submit tx failed: Error: 400:
0: "278ad827cb923ed800fcb2028114ee8e9bca875059e1389ca1f49755c1c9a629"
at checkResponseNoError (apiDom.ts:334:1)
at Object.submitTx (apiDom.ts:270:1)

Can you post the full input code, and response output/errors/messages. There are often multiple messages in the output which give better clues.

Posting an alternative where you don't need to build a transaction in front-end https://cardano.stackexchange.com/a/7658/117

Unexpected error value: "Not enough ADA leftover to include non-ADA assets in a change address" I am getting this error, using nami, I have 5+ ada as collateral. I get the message when I try to harvest in the farm.

If you have a question then please raise it as a new question with full details of what you were trying to do and how, and what errors/output to received. The Answers space here is intended for answers to the question above about the library cardano-serialization-lib-asmjs, not for a new question. We're happy to help but as a new question, cheers.

Comment converted into answer:
I'm not familiar with that code, but in general moving native assets needs to go along with some ADA eg 1 or 2 ADA. Does your input UTxO have enough ADA balance to cover everything eg fees and output ADA? If not then you can add a second input UTxO that has more ADA into the transaction.

(1) Make sure you have enough ADA in your wallet that can be used to pay for transaction fees. Transaction fees are increasing the more native assets you add to the transaction.
(2) If you use add_change_if_needed make sure to add enough inputs before calling this method that can cover the transaction fees.
(3) If you hardcode your input UTxO like you probably did with 278ad827cb923ed800fcb2028114ee8e9bca875059e1389ca1f49755c1c9a629 then running your code multiple time with of course fail, because you've consumed the unspent output with your first execution. Any second try won't be able  to spend this output again, since it's already been spent.
You will need to update your code manually or write some logic to select the new UTxO.


text:
Error: submit tx failed: Error: 400: 0: "278ad827cb923ed800fcb2028114ee8e9bca875059e1389ca1f49755c1c9a629"
this.API.submitTx is throwing error
Error: submit tx failed: Error: 400:
0: "278ad827cb923ed800fcb2028114ee8e9bca875059e1389ca1f49755c1c9a629"
at checkResponseNoError (apiDom.ts:334:1)
at Object.submitTx (apiDom.ts:270:1)

Is 278ad827cb923ed800fcb2028114ee8e9bca875059e1389ca1f49755c1c9a629 one of your input UTxOs? Do you recognise this hash? Help us to help you.

An alternative to avoid building transaction in front-end https://cardano.stackexchange.com/a/7636/117


text:
Specs for local-state queries
Does anyone know where I can find on-the-wire specs / cddl for the ledger-specific payloads of the local-state queries?
I have the specs for the top-level state-machine messages of the polymorphic request-response Ouroboros mini-protocol, but I can't find the specs for the concrete queries.

You are probably looking for Cardano.Api.Query.

Link is dead now.


text:
Confusing configuring of multiple relay nodes, multi host pool and SRV DNS
When one building Stake Pool with "Future-proof" and scalability in mind it would make sense to make your setup right from the beginning. While there are various guides about pool setup I haven't found any good resource about multi host setup.
cardano-cli stake-pool registration-certificate -h
--multi-host-pool-relay STRING
    The stake pool relay's DNS name that corresponds to an SRV DNS record

based on that and multiple sources of community docs I would expect:
If I have e.g. 3 Relay nodes then I would perform following setup.
_cardano._tcp.relays.cardano.example.com. 300 IN SRV 10 5 6000 relay-1.example.com.
_cardano._tcp.relays.cardano.example.com. 300 IN SRV 10 5 6000 relay-2.example.com.
_cardano._tcp.relays.cardano.example.com. 300 IN SRV 10 20 6000 relay-backup.example.com.
relay-1.example.com 200 IN A 1.2.3.4
relay-2.example.com 200 IN A 1.2.3.5
relay-backup.example.com 200 IN A 1.2.3.6

however looking at IOHK relays-new.cardano-mainnet.iohk.io it seems that is simply  round-robin DNS A records
dig relays-new.cardano-mainnet.iohk.io
;; ANSWER SECTION:
relays-new.cardano-mainnet.iohk.io. 288 IN A    54.176.152.50
relays-new.cardano-mainnet.iohk.io. 288 IN A    13.114.93.89
relays-new.cardano-mainnet.iohk.io. 288 IN A    18.133.59.65
relays-new.cardano-mainnet.iohk.io. 288 IN A    3.16.84.177
relays-new.cardano-mainnet.iohk.io. 288 IN A    3.129.48.231
relays-new.cardano-mainnet.iohk.io. 288 IN A    184.72.21.211
relays-new.cardano-mainnet.iohk.io. 288 IN A    3.19.78.159
relays-new.cardano-mainnet.iohk.io. 288 IN A    3.121.10.14

Have I missed some crucial part of documentation about usage of --multi-host-pool-relay or is SRV DNS record part misleading and is meant to be used when one assigns multiple relay IP's to singlehostname? e.g.
relays.cardano.example.com 300 IN A 1.2.3.4
relays.cardano.example.com 300 IN A 1.2.3.5
relays.cardano.example.com 300 IN A 1.2.3.6

Hope here is some big brain who can clarify how is it then right way to setup relays.cardano.example.com such than I could easily scale up or down relays when needed in the feature.

So from a big picture perspective, what are you trying to achieve? In terms of a physical/virtual layer and a logical layer, what is the end goal with this? I am just better trying to wrap my head around the question. Thanks!

I think OP is trying to figure out if it is possible to use SRV records with cardano node. It is quite handy and should work much better then regular A record with round robin.
Seems SRV records do work, only it seems it is not yet supported officially(1 year old info, though): https://github.com/input-output-hk/cardano-node/issues/2517

@os11k indeed I'm looking for if it is possible to use SRV records with cardano node since there are some comments and references to it e.g. CoinCashew tutorial mentions that SRV Records should be supported for multi-host-pool-relay however I haven't found any official info about the implementation and is it supported or not.


text:
Convert xpub public key from ccvault to bech32 or acct_ public key
Trying to import my wallet into Koinly for tax-purposes and unfortunately it doesn't accept xpub public addresses.
They just recently added Cardano Native Tokens to their platform and they support act_ keys (and bech32?)
Just wondering if there's a way I can convert xpub to either an act_ key or a bech32-compatible key so I can import my ccvault wallet into Koinly.
I tried the bech32.exe program for Windows but I could not figure out how to use it or convert my public key.

You can use the bech32 command line software that comes preinstalled with cardano-wallet.
Install bech32 or cardano-wallet.
Here is an example:
Say I have an cc.xpub file from ccvault like this: xpub1vep8yyse8ja7yspv0ytjdu0rnk4ek08prkuvre6t76mwryp6cdq7azzd684psvm2j55qp2rhm3zpl0x7en96p2esnvfj905pax48czc7hc0f6
From your command line, run: cat cc.xpub | bech32 >> cc.b32 - this will output the bech32 format (in the above example, it would be 66427212193cbbe2402c791726f1e39dab9b3ce11db8c1e74bf6b6e1903ac341ee884dd1ea18336a952800a877dc441fbcdecccba0ab309b1322be81e9aa7c0b), and save it under the file cc.b32
Next, run: bech32 acct_xvk <<< $(cat cc.b32) >> cc.xvk
This will convert the bech32 encoded cc.b32 key into a cardano-wallet compatible acct_xvk, saved under the file cc.xvk
In the above example, the result is: acct_xvk1vep8yyse8ja7yspv0ytjdu0rnk4ek08prkuvre6t76mwryp6cdq7azzd684psvm2j55qp2rhm3zpl0x7en96p2esnvfj905pax48czcdg4029

This worked! Thank you very much! Can't upvote unfortunately due to low karma.


text:
How to take powers in validator
I was trying to implement some El Gamal cryptography in plutus, basic verification of statements. But while trying to implement an efficient modular exponential function I noticed that the current PlutusTx.Prelude does not even provide a simple power function (^). Digging even deeper I saw that the PlutusTx.Prelude only povides an even function and not even an odd function. How can I contribute to add these function to PlutusTx.Prelude?
Is my implementation correct? I import Plutus.Prelude as Prel. Do I also need to add the template haskell inlinable pragma if I make this a library?
power :: Integer -> Integer -> Integer
power x n |(n==1) = x
        | Prel.even n       = (power x ( Prel.divide n 2))*(pow x ( Prel.divide n 2))
        | Prel.even (n-1)   = x * (power x (n-1))

expMod :: Integer -> Integer -> Integer -> Integer
expMod b e m
    | b == 1    = b
    | e == 0    = 1
    | e == 1    = b `Prel.modulo` m
    | even e    = let p = expMod b (e `Prel.divide` 2) m `Prel.modulo` m
                   in (power p (2::Integer)) `Prel.modulo` m
    | otherwise = (b * expMod b (e-1) m) `Prel.modulo` m

which seems to compile without the pragma in a validator.

Try this function:
power x n
    | n == 0  =  1
    | x == 0  =  0
    | even n = ( power x (n 'div' 2) ) * ( power x (n 'div' 2) )
    | otherwise n = x * ( power x ((n - 1) 'div' 2)) * ( power x ((n - 1) 'div' 2) )

Look at the type signature for even:
even :: (Integral a) => a -> Bool.
odd has a similar signature.
So you can see that even and odd take any type of the Integral typeclass and evaluate it. Then look at the signature for /:
(/) :: (Fractional a) => a -> a -> a.
/ takes only Fractional types, not Integral ones. It's impossible for one type to be evaluated by both those functions. In this case, there's an easy fix: use div instead of /.
Note that if you use div as an infix function (place it between the arguments) you'll need to put backticks around div.

Thank you for correcting my bad cases, but note that the use of odd here is not allowed since PlutusTx.Prelude does not have this.

Well in this case should otherwise (instead of odd) also work, but an odd would be also great.


text:
No tAda after requesting from faucet
I'm following the docs and ran:
cardano-cli query utxo \
    --address $(cat payment.addr) \
    --testnet-magic 1097911063

and it shows my address but no tAda several minutes after requesting from this faucet. My testnet is synced and I'm doing this from Debian 11. It wasn't fully synced yet; that was the problem.

I just tried the faucet and received the 1,000 tADA after about 4 minutes.
You can check the testnet explorer for your initial attempt to see what it says: https://explorer.cardano-testnet.iohkdev.io/en
What is your test address, I'll send you the 1,000 tADA.
Edit (for others that end up on this page)
Ensure you are fully synced, check with:

cardano-cli query tip --testnet-magic 1097911063

addr_test1qzfdl3vkyjemg28jfnewsd4qldhemrnrl5np268dswzeaehavclrvqjk72kgfpfs567zpp2r9klu6hkhwynrgjdyr0lq2fpzgv

Explorer shows two transactions but still no balance locally. Not sure if I'm supposed to install the wallet or if just running the node and cli is enough.

Ok it sounds like a local sync issue. Can you run cardano-cli query tip --testnet-magic 1097911063 to see if you're local storage is fully synced.

Also, check your node log file for any issues/errors.

{     "era": "Alonzo",     "syncProgress": "91.73",     "hash": "40f26cdcfff0319d11f3eacb0fb7230fcbf5694afc85499188178229cf87264e",     "epoch": 178,     "slot": 46727389,     "block": 3202975 }
Guess I'm not fully synced yet though the stdout messages don't have any 'progress bars' or anything.

It's progressing but very slowly so I think something's off.

Ok, only 91% synced (syncProgress). Also use https://explorer.cardano-testnet.iohkdev.io/en.html to see the latest SLOT and BLOCK values, and compare to your values. Once synced you'll see your trxs and balance.

cardano-cli query tip --testnet-magic 1097911063

showed that it wasn't fully-synced yet.

I am tempted to delete this answer as it is more a hint than an explanation.  The guidelines in [answer] will help improve your answers.


text:
Is there a 'Cardano Naming Service' available?
Is there any services like ENS (Ethereum Naming Service) for Cardano available now?
If no, how difficult it is to come up with one?

I don't think anything is currently set up for domains.
ADAHandle.com exists for human-readable wallet address mapping, and has a roadmap for extending this.
These are effectively an NFT that a wallet holds.
Adding meta-data for a URL in the future would seem trivial.
Or if you want you could put forward a proposal to https://cardano.ideascale.com/ to build something more suitable.
The current and next funding rounds have $16,000,000 each to fund project ideas.
The community votes on which ones to fund.

Adatar.me is a Project Catalyst funded project that fits the description.

Earlier comment converted to answer to reduce duplicate answers:
I don't think anything is currently set up for domains. ADAHandle.com exists for human-readable wallet address mapping, and has a roadmap for extending this. These are effectively an NFT that a wallet holds. Adding meta-data for a URL in the future would seem trivial. Or if you want you could put forward a proposal to cardano.ideascale.com to build something more suitable. The current and next funding rounds have $16,000,000 each to fund project ideas. The community votes on which ones to fund. – MC_Brisbane 7 hours ago


text:
How to install cardano-node and cardano-cli on Mac M1
I tried to install cardano-cli and cardano-node using this documentation and stuck on below step
mkdir -p $HOME/.local/bin
cp -p "$(./scripts/bin-path.sh cardano-node)" $HOME/.local/bin/
cp -p "$(./scripts/bin-path.sh cardano-cli)" $HOME/.local/bin/

that shows an error like these

anyone with Mac has solved this?

These means that you didn't complied cardano-node properly. Try to run again cabal build all and put here what error you are getting if any.

FYI cabal build cardano-node cardano-cli takes a while to run. If it appears to completes quickly then there is an error. If there is an error you should see a message displayed - we will need to see that message to help further. It would also pay to make sure that all of the environment variables noted in the guide that you are following are set correctly before running cabal build cardano-node cardano-cli.

here it is @os11k, please see this screenshot also https://i.stack.imgur.com/uMkGs.png

Don't use print-screen for sharing error messages, these is really inconvenient. I would recommend to delete cardano-node directory and start from scratch

How sure are you that all previous steps in the guide completed successfully?
I would step through the guide again from the start and make sure there are not issues after each step.
Some errors/failures are subtle.

The solution is much easier:

go to https://github.com/input-output-hk/cardano-node/releases
expand the "Downloads" for the latest release
click on "Hydra binaries"
click on "cardano-node-macos", which for the 1.34.1 version points to https://hydra.iohk.io/build/13065616
download the binary distribution (https://hydra.iohk.io/build/13065616/download/1/cardano-node-1.34.1-macos.tar.gz)
extract the file and copy the extracted binaries to /usr/local/bin or ~/.local/bin

There is no need to compile the binaries on your mac. Why would you? Are you compiling every program you install on your mac?

the latest versions (such as the current 1.35.3) are only available for compilation. Also, you would need to compile the sources for Mac M1 users as these aren't available at all for download from hydra build servers as of today.

I have been successful using nix for this task, if you are open to it.  Here's how I set up nix on a Mac M1 (note that this post is a bit old, so YMMV):
https://www.reddit.com/r/cardano/comments/mmzut6/macos_plutus_playground_build_instructions/ .  Only the first 6 steps are so are nix-specific, the rest are for building plutus.
then you can proceed with building the cardano-node and cardano-cli executables:
nix-build -A cardano-node -o result/mainnet/cardano-node
nix-build -A cardano-cli -o result/mainnet/cardano-cli

this page also has info, tho I have not used it specifically it might be helpful:
https://github.com/input-output-hk/cardano-node/blob/master/doc/getting-started/building-the-node-using-nix.md#building-and-running-with-nix


text:
Is the daedalus wallet seed phrase caps sensitive?
I noticed my written down recovery phrase you can't really tell between caps and not caps and I have specifically drawn an arrow to "no caps" on a B on one sheet and some of the words that start with S or M are really hard to tell.
Should I send all my ADA back to Coinbase and make a new one just in case and make a notepad version so you can make a distinction between caps and non-caps but stick it on a USB as well as paper?
Also what situation would I need the recovery phrase? because I want to avoid the nerve-wracking of having to use it at all.
Im thinking of switching to YOROI instead maybe, or buy some more and store some in each wallet.
Many Thanks,
Jack.

Cardano, Bitcoin, and many other protocols use the BIP-39 standard for mnemonics. It is not case sensitive, as it always defaults to lower case.
Your recovery phrase is a secret you can use to derive/re-derive your wallet and its keys. You will need it anytime you wish to restore your wallet on any wallet software, like Daedalus, Yoroi, Nami, etc. It is essential to keep it safe and secure.
Generally speaking, a hardware wallet like Ledger or Trezor are your best bet if avoiding nerve-wrecking is what you're optimizing for.
On the other hand, if hardware wallets are not an option (whether you can't get your hands on them, or you're a power user with high customization requirements), then be very careful with what computer(s) you input your recovery phrase into. Airgapping is your friend here.

Thanks, I got a reply on another forum earlier and for reference it's not cap sensitive and you can actually test it and get the green light in Daedalus settings. Recommendations say you do this every 6 months.
Mine went green so all good.
Here is the video someone linked me where you can check your seed phrase has been written down correctly by inputting it into daedalus any time you want.
https://www.youtube.com/watch?v=AZEdSOs5Emw&feature=emb_title
Hope this helps future concerns for people's seed phrase being correct.


text:
Disable GitHub Actions when forking cardano-node
Would you please give me a hint of where to look or modify? I don't even know if they have a charge associated.
If  you were to fork https://github.com/input-output-hk/cardano-node.git, the GitHub Actions would continue running autonomously.

github actions are triggered by the contents of the /.github directory - specifically the workflows subdir.
https://github.com/input-output-hk/cardano-node/tree/master/.github
See https://docs.github.com/en/actions/quickstart
You can delete or rename the directory to stop github actions.
Or disable them on your fork
https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow


text:
nix attribute not found setting up Dapp repo
I modified slightly  cabal.project of the  plutus-apps to serve as base for my own application repo. It includes another repo of my own that is also a sligh modification of the plutus repo. If my own git repo that substitutes plutus is xxxx. Now this error happens when executing nix-shell

nix-shell
error: attribute 'xxxx' missing....

I suppose that this attribute should be added somewhere in flakes or some other nix configuration but I had no clue.  Looking for information I figured out and I added it to flake.nix. Since my repo is a modification of Plutus, I put it instead of the plutus repo
plutus-core = {
  url = "github:agocorona/plutus"; #"github:input-output-hk/plutus"
  flake = false;
};

But the error is the same.

I Finally got the solution here: https://github.com/input-output-hk/haskell.nix/issues/1427


text:
Listing all UTXOs spend by a script as well as the public key it came from
How do I list all Utxos that is in my script as well as the public key addresses that it came from.I am using the result as a parameter for a different function.I want to know if a public key address has already send a transaction to this script , if they have then do something , and if they have not then do something else.

Scripts do not spend utxos, transactions do. Do you mean all outputs that belong to the script at any given time?, including or excluding current unsuspended outputs?

Yep, like outputs that belong to the script.

sorry can you please be more specific?
what exactly do you mean "ist all Utxos that were consumed by my script " ?
do you need a list of UTXOs for a specific address?
and additionally, do you need the address from the sender of this UTXOs?
if yes, please see below.
find all UTXOs
fullUtxo=/fullUtxo.out
myAddr=addr1qljkdlgamadjnlh8xmgxln4535kj5j3lgl9mawrr99nkrt2meqa2z
cardano-cli query utxo --address $myAddr --mainnet > $fullUtxo

find sender
        in_addr=$(curl -H 'project_id: MainnetBlockfrostProjectNameID' https://cardano-mainnet.blockfrost.io/api/v0/txs/${tx_hash}/utxos | jq '.inputs' | jq '.[0]' | jq '.address' | sed 's/^.//;s/.$//')

if that helps you, would be great if you vote for my answer and give me some credits :)
have a nice day mate,
pool operator for TTS17

Yep, i wanted a list of UTXOs for a specific address and the address from the sender of this UTXOs.How can i also get the amount of times an address has send UTXOs to a script.

i dont understand what is your goal, because either i need to sell / send something to everyone for each transaction..... or i can send back tokens to many addresses ,who sent transactions, in the same transaction i send. - - - - if you want to know "how many times " of something, you can create a txt file with one line for each transaction and then execute this commands to find the number of lines "wc -l fileName.txt"   -#-#-#-#-

I want to see how many times an address has send UTXOs to a script. I am going to use that value as parameters for the script. I want to create a logic like if this public address has send UTXOs to this script once before , something happens.

like i said, i would add create a new file txt will all the tx you have currently "echo ${tx_in} >> $txsin" and better for your case, add tx there based on the sender....here you can see what i do, maybe related... if that helps you


text:
how to query the chain index tx endpoint?
The following curl is constructed via swagger that says it just needs the string, but this fails.
What am I doing wrong?
$curl -X 'POST' \
>   'http://localhost:9083/tx' \
>   -H 'accept: application/json;charset=utf-8' \
>   -H 'Content-Type: application/json;charset=utf-8' \
>   -d '"c42669c4818e04d732e77b9ed3efb22697ba4b1cd7540d2bab8c44f9a5e4fbb6"'
Error in $: parsing Plutus.V1.Ledger.TxId.TxId(TxId) failed, expected Object, but encountered String

I can pull out the tx data in sqlite3 so I think I've ruled out it being a bad id

The following substitution works
...
-d '{"getTxId" : "c42669c4818e04d732e77b9ed3efb22697ba4b1cd7540d2bab8c44f9a5e4fbb6"}'
...


text:
How to allow non deterministic spent output
I would like a validator (or a minting policy) to succeed always but only to spend the output if some conditions are met;
an example use case of such behaviour is to allow burning token (kind of a "ticket" to use the smart contract) in both cases if the conditions are met or not;
also, I would like the user not to know if it is allowed to spend an output (therefore to meet the conditions) because if that was the case then it would be enough just a condition that asserts that 0 token are minted form the offchain if it should fail; or a tot-token are minted if it should succed; but this would require the user to know the result in order to build the rigth transaction.
I know Cardano smart contracts are designed to prevent failing smart contract to execute, but is there a way to allow this bheaviour if controlled such as in this case?

It is not possible to design a smart contract validator in a way that the user does not know if it will succeed or not. The validator can only "see" the transaction. This means that the validator logic cannot use any information that the submitting user does not also have.
What you can do, though, is to structure the process into two steps, where the user first submits a transaction to request an action, and then you react based on some off-chain information. This will make the whole process centralised, i.e. dependent on you.

Good answer. While I do not think that user "submits a transaction" is required, if you mean submitting to blockchain. You can have user-sign-tx-first DApp arch, with user signing it first, and server signing it second and submiting to blockchain.

To add to Jey's answer, UTxOs will always be deterministic, but, as he said, you can create a two-steps flow that would allow results unknown for the first user.
The idea proposed by him would require some centralised off-chain component, but you could also make it decentralised depending on the problem. See this example from the Plutus Pioneers Program:
We want to create a rock paper scissors on-chain game. So Alice could send to our script some ADA with her "answer" as the datum, let's say "rock". She would hash that alongside with some dust value (like a password). So, the datum would be, for example, hash(rock|foo).
Then, Bob would do the same, but now he doesn't need to hash it he can just put the value it self. The datum would now be {alice: hash(rock|foo), bob: paper}.
Finally, since Alice's choice is hashed, she now has a deadline to reveal her answer. If she does, our logic will verify both values and give the ADA to Bob (because paper beats rock). If she doesn't (maybe because she noticed she would lose) and the deadline passes, Bob can automatically get all the ADA from the script.

You can design the off chain code in a way that it will not pass validation of the contract but that would lead to consuming the collateral of the transaction which I don't think is what you're trying to achieve.


text:
Get UTXO or tnx hash from nami Collateral
I am using the function cardano.getCollateral() in the nami wallet library which gives me the utxo of a collateral, lets say it is: "8282582059aca4594629e55a25e2ef20ac8b58fe65a946f215639dbde038f598d0f25a040082583900b9e79b67bc322d4d9b0a2d5449353e58f22aeea3bd349cdd363543fc4ec0b90c580c1091a8bc26989d288402ed015c1c747d5290698a15f41a004c4b40".
How can i go get from this the utxo of the collateral or the transaction ID in cardano-client-lib?
Thank you

You need to do something like this:
    /**
     * The collateral is need for working with Plutus Scripts
     * Essentially you need to provide collateral to pay for fees if the
     * script execution fails after the script has been validated...
     * this should be an uncommon occurrence and would suggest the smart contract
     * would have been incorrectly written.
     * The amount of collateral to use is set in the wallet
     * @returns {Promise<void>}
     */
    getCollateral = async () => {

        let CollatUtxos = [];

        try {

            let collateral = [];

            const wallet = this.state.whichWalletSelected;
            if (wallet === "nami") {
                collateral = await this.API.experimental.getCollateral();
            } else {
                collateral = await this.API.getCollateral();
            }

            for (const x of collateral) {
                const utxo = TransactionUnspentOutput.from_bytes(Buffer.from(x, "hex"));
                CollatUtxos.push(utxo)
                // console.log(utxo)
            }
            this.setState({CollatUtxos})
        } catch (err) {
            console.log(err)
        }

    }

There is a working example in this repo:
https://github.com/dynamicstrategies/cardano-wallet-connector


text:
Cbor address to bech32 type address in JS or python
I have managed to retrive a user address from a dapp connector wallet using JS:
api_promise = window.cardano.{wallet}.enable();
api_promise.then(function(api) {
  addr_promise = api.getUsedAddresses();
  addr_promise.then(
    function(addr) {
      value[0];  // this is a CBOR address !
...

I get this type of (presumably CBOR) address: 012f4d0b584ecb52e4e4b8e78e4ce77a6f822e59ede3277305fd526b71824b2d2740284cf6a28e2a512cc4a00f41004c18ed728a0f7a04eb29
Apparently with some skill it could be read using this -> https://cbor.me.
# Is there any method to extract a shelley addr_34.... using JS or python?
Working implementations are available in node.js, but I'm using flask (python + JS). And I'm struggling to make it work wit packages cbor2 and bech32.
For example I tried cbor2.loads(bytes(addr_str, 'utf-8')) without success.
My further goal is to query blockfrost.

You can also use typhonjs used by typhonwallet. It's a Pure JS library not dependent on WASM.
Install
npm i @stricahq/typhonjs

Usage
const typhonjs =  require("@stricahq/typhonjs");

const bech32Address = typhonjs.utils
  .getAddressFromHex("012f4d0b584ecb52e4e4b8e78e4ce77a6f822e59ede3277305fd526b71824b2d2740284cf6a28e2a512cc4a00f41004c18ed728a0f7a04eb29")
  .getBech32();

I might appear clueless, but I am running code via python Flask. It means the javascript is executed client-side. In the background, everything is executed via python and ajax queries. Will I be able to execute this client side?

Yes, you can execute this code client side :) @Lokinou

First install the npm module:
npm i @emurgo/cardano-serialization-lib-browser

Then you need a wasm loader module
class wasm {
  async load() {
    if (this._wasm) return;
    /**
     * @private
     */
    this._wasm = await import(
      "@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib"
    );
  }

  get Cardano() {
    return this._wasm;
  }
}

export default new wasm();

Then import into your module/component using:
import WASMLoader from "../../utils/Loader";

Now you should be able to use wasm module to convert the CBOR address into bech32 (addr1.., stake1.. etc)
const getAddressToBech32 = async () => {
    await WASMLoader.load();
    const address = (await api.getUsedAddresses())[0];
    return WASMLoader.Cardano.Address.from_bytes(Buffer.from(address,"hex")).to_bech32();
};

Now that you have a bech32 address you should be able to use with for blockfrost API queries


text:
Payment2.addr: no such file or directory
I know I'm missing something super obvious but I'm on this part and I don't see where payment2.addr gets created so of course it says it doesn't exist. I'm trying to submit the transaction on the testnet.

That is just an arbitrary address that you also control, in addition to the address (payment.addr) that the assets originate from. It can be any second, third, fourth etc address that you've created. Think of it as sending stuff from your wallet A to your wallet B.
In other words, payment2.addr is any address other than payment.addr

Further to what zhekson mentioned, there are normally at least 2 tx-out addresses, 1) the payment and 2) for the change (or remainder). Eg tx-in has 100ADA, you send 15 to payment1.addr and the change (85) to payment2.addr (which is one of you addresses)


text:
Where is the mnemonic stored in Daedalus?
I'd like to know where the mnemonic (if at all) is stored in the Daedalus directory. I am running on Ubuntu 20.04, and I'd like to extract the mnemonic from the filesystem. (Assuming I am not using a hardware wallet).

Mnemonic is used to make it easier for us to create the root private key (for signing transactions). When you insert your mnemonic, behind the scene it's actually using the BIP39 mechanism to create the root private key. And this private key is the one that is actually being stored, not the mnemonic seed phrase itself. If you'd like, you can 'walk back' the private key into a mnemonic seed phrase, but it's quite tasking.
I don't really know much about the Daedalus wallet, but with a light wallet (Like Eternl, Nami, Yoroi, etc), the private key is stored encrypted with your wallet password.
References on how BIP39 and Key Derivation works in Cardano:

https://developers.cardano.org/docs/get-started/technical-concepts#mnemonic-seed-phrase-bip39
https://developers.cardano.org/docs/get-started/technical-concepts#key-derivation

In newer Daedalus, there isn't any information regarding the location of the secret.key, only in older Daedalus.

https://iohk.zendesk.com/hc/en-us/articles/900000623463-Importing-wallets
https://forum.cardano.org/t/where-are-the-public-and-private-keys-located-in-daedalus/6522


text:
How to set a specific amount for native token when calling CIP30 api.getUtxos() method in Nami, CCvault, Flint and other CIP30-compliant wallets?
In the CIP30 spec, we are supposed to be able to get a subset of the user's UTXOs if we specify an "amount" when calling the method getUtxos():
api.getUtxos(amount: cbor\ = undefined, paginate: Paginate = undefined): Promise\

And this "amount" parameter, is supposed to allow a Value type which further contains MultiAsset types.
But calling this method like so:
let ScriptHash = csl.ScriptHash.from_bytes( Buffer.from(policyId, "hex") );

let Assets = csl.Assets.new();
Assets.insert(
    csl.AssetName.new( Buffer.from(assetName, "hex") ),
    csl.BigNum.from_str(amount)
);

let MultiAsset = csl.MultiAsset.new();
MultiAsset.insert(ScriptHash, Assets);

let reqdValue = csl.Value.new_from_assets(MultiAsset);
let inputUtxos = await wallet.activeApi.getUtxos(reqdValue); // CIP30 method call

... always gives me the following errors.
In CCVault/Eternl:
Error: invalid input: amount: TypeError: byteaString.startsWith is not a function

In Nami:
Inputs do not conform to this spec or are otherwise invalid.

In Flint:
An error occurred during execution of this API call.

What am I doing wrong here? What is the correct way of passing a Value parameter to getUtxos()?


text:
Transaction submit error
Is there anything wrong with
cardano-cli transaction build-raw \
    --tx-in 2b67b1d3cbab8004f469a2a2f260738704810744350119d75079d7b6f4b1842a#0 \
    --tx-out $(cat payment2.addr)+100000000 \
    --tx-out $(cat payment.addr)+997320350 \
    --invalid-hereafter 53808126 \
    --fee 1679650 \
    --out-file tx.raw

because I'm getting
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 0 (fromList [])) (Value 20000000 (fromList []))))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (BadInputsUTxO (fromList [TxInCompact (TxId {_unTxId = SafeHash "4e3a6e7fdcb0d0efa17bf79c13aed2b4cb9baf37fb1aa2e39553d5bd720c5c99"}) 4])))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 168273) (Coin 167965)))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (OutsideValidityIntervalUTxO (ValidityInterval {invalidBefore = SNothing, invalidHereafter = SJust (SlotNo 369400)}) (SlotNo 53808413))))])

My math might be off. I have a billion test LoveLace in that address.
Update:
cardano-cli transaction build-raw \
    --tx-in 2b67b1d3cbab8004f469a2a2f260738704810744350119d75079d7b6f4b1842a#0 \
    --tx-out $(cat payment2.addr)+100000000 \
    --tx-out $(cat payment.addr)+899823103 \
    --invalid-hereafter 54208180 \
    --fee 176897 \
    --out-file tx.raw

still doesn't work:
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 168273) (Coin 167965)))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (OutsideValidityIntervalUTxO (ValidityInterval {invalidBefore = SNothing, invalidHereafter = SJust (SlotNo 53808126)}) (SlotNo 54205604))))])

Your trx has --fee 1679650
In the error it notes:

FeeTooSmallUTxO (Coin 168273) (Coin 167965))

Note (Coin 167965) is similar to the fee of 1679650. Could there be a typo somewhere?
Probably good to re-calc the fee amount.
Also, what is the balance of UTxO 2b67b1d3cbab8004f469a2a2f260738704810744350119d75079d7b6f4b1842a#0 ?
To match your trx outputs and fee it should be: 1,099,000,000
If you have 1billion exactly then change:
--tx-out $(cat payment.addr)+997320350 to
--tx-out $(cat payment.addr)+898320350 so that it balances.

I have 1000000000 lovelace + TxOutDatumNone.

Still doesn't work:
`cardano-cli transaction build-raw \
--tx-in 2b67b1d3cbab8004f469a2a2f260738704810744350119d75079d7b6f4b1842a#0 \
--tx-out $(cat payment2.addr)+100000000 \
--tx-out $(cat payment.addr)+898320350 \
--invalid-hereafter 53808126 \
--fee 167965 \
--out-file tx.raw`

It keeps mentioning 167965 even though I put the zero at the end.

Your comment notes a diff fee of '--fee 167965' - this then changes the amount for --tx-out but you did not update that value.  Your amounts have to balance eg --tx-in amount = (--tx-out amount + --tx-out amount + --fee amount) 2) Re-calculate the fee to ensure the correct amount to use eg 'cardano-cli transaction calculate-min-fee ....'
You need to also increase the '--invalid-hereafter' value to beyond the latest maximum testnet slot, check the latest value here https://explorer.cardano-testnet.iohkdev.io/en.html and add about 500 to it.

After doing the above can you then post the command used and error message received.

Refer to this guide to construct a simple trx:  https://developers.cardano.org/docs/stake-pool-course/handbook/create-simple-transaction/

Please check update.

First let's confirm that your local node is 100% synced. Try the command cardano-cli query tip --testnet-magic 1097911063 . Note the "syncProgress" value. Also note the 'slot' value and use that plus 10000 as your '--invalid-hereafter' value.

What CLI version are you using? Try cardano-cli --version . Also, try adding --alonzo-era if on the latest version.

The error still notes 'FeeTooSmallUTxO' - can you copy/paste to your question the full steps taken to calculate the fee. Too much detail is better than not enough.

Also, remove file tx.raw to ensure it gets re-created during your steps, and copy/paste in your 'submit' command too so we can see everything that is taking place, thanks.

I've been giving https://forum.cardano.org/t/how-to-set-up-a-pool-in-a-few-minutes-and-register-using-cntools/48767 a shot. Is there another way to get tAda outside the official faucet since it only lets you get some once a day?

How much tADA do you need for testing with?
If you need a heap of tADA you could ask on Cardano discord for tADA donations from people.

The slot# error is because the transaction expired - the error indicates you submitted an expired transaction.
Use the higher fee as you did in the second tx, as well as a larger slot expiration. Set the --invalid-hereafter to 60000000 and let it rip!


text:
Cardano Wallet - Using existing wallet and/or address generated from cardano-cli
I'm kinda new in blockchain / crypto world (also Cardano world) and still learning things around.
Already setup cardano-node with cardano-wallets properly, both working good with testnet, by following this guide as a starter path.
All good and I understand bit-by-bit. BUT, when I reach this part, which the second part, where it use cardano-wallets, I got some questions.

Is it possible if we use previously created wallet and address, .skey, .vkey and .addr, that being created from cardano-cli on cardano-wallet?

If it's possible, how we can do that? I tried to check around the docs, but seems none mentioning it. As far as I check on forum, this discussion is the closest and this one. But, I'm still not really understand it. Is there any documentation or link about it?

From No.2 above, is that link is the one that I want to achieve? since, when I read thoroughly, seems it's not the guide I'm looking for

Thanks for your time! :)


text:
cardano db-sync won't authenticate to postgres?
Trying to get db sync to do the initial database setup. I have this running on another ubuntu 20 box, and I trying to recreate it from scratch with all of the same versions and this time I am getting an error trying to run it
Running : migration-1-0000-20190730.sql
psql: error: fe_sendauth: no password supplied
ExitFailure 2

i know that it seems the pgpass file because when I run
PGPASSFILE=config/pgpass-mainnet scripts/postgresql-setup.sh --createdb

It recognizes the username I put in there. And the password is in there as well
Here is the db sync command I am running:
PGPASSFILE=/home/user/cardano-db-sync/config/pgpass-mainnet \
  /home/user/cardano-db-sync/db-sync-node/bin/cardano-db-sync \
      --config /home/user/cardano-db-sync/config/mainnet-config.yaml \
      --socket-path /var/ada/node.socket \
      --state-dir /home/user/cardano-db-sync/ledger-state/mainnet \
      --schema-dir /home/user/cardano-db-sync/schema/ \

which results in the following response
[db-sync-node:Info:6] [2022-03-25 03:22:50.40 UTC] Schema migration files validated
[db-sync-node:Info:6] [2022-03-25 03:22:50.40 UTC] Running database migrations
[db-sync-node:Info:6] [2022-03-25 03:22:50.40 UTC] Enviroment variable DbSyncAbortOnPanic: False
ExitFailure 2

Errors in file: /tmp/migrate-2022-03-25T032250.log

and the log file is what contains the authentication error.. my pgpass looks like
/var/run/postgresql:5432:cexplorer:username:'userpass'

I have also tried using localhost and 127.0.0.1. I notice when running
PGPASSFILE=config/pgpass-mainnet psql cexplorer

it asks me to authenticate for my current user, NOT the user in the mgpass file but when running the previous command for creating db it asks me the password for the correct user in the pgpass file. Both users can log into postgres regardless and actually have the same password at the moment. Any clues would be appreciated this is with cradno-db-sync 12.0.2 the latest node release.

Sorry, this is totally a PostgreSQL setup issue and nothing at all to do with db-sync. You might get some more information by running:
PGPASSFILE=config/pgpass-mainnet scripts/postgresql-setup.sh --check

If that doesn't give you any clues I would read up on user authentication in the PostgreSQL documentation.

ok ty I will look into this


text:
Is Ed25519 is EUF-CMA secure?
Is the signature scheme of shelley (Ed25519) is EUF-CMA secure?  The Existential Unforgeability under Chosen Message Attack experiment works like this:

The challenger generates a valid keypair (pk, sk) and gives pk to the attacker.

The attacker may now repeatedly ask for signatures on chosen messages $(M_1, \dots, M_q)$ of its choosing, and receives the valid signatures $(\sigma_1, \dots, \sigma_q)$ in response.

At the conclusion of the experiment, the attacker must output a message and signature $M^$, $\sigma^$ such that (1) the message $M^*$ was not one of the messages requested in the previous step, and (2) the message/signature verifies correctly under the public key (Ref).

Now I guess the used signature scheme by Shelley is EUF-CMA secure since by assuming the contrary it would break the blockchain?

EDIT
The only problem I see with assuming the contraposition of the statement is that the messages $(M_1,\dots, M_q)$ are chosen by the adversary. This is not the case in a public ledger though it could be extracted?

Yes, Ed25519 provides the existential unforgeability property. There is a nice work that studies the different variants of Ed25519 signatures
https://eprint.iacr.org/2020/823.pdf
As specified in that document, the different variants of ed25519 provide different security properties, but all are existentially unforgeable under chosen message attacks.
Indeed, as you point out, if an adversary could forge valid signatures to messages not signed by the key owner, the security of the blockchain could be compromised.

Thank you for that paper! Its quite a "recent" paper and as it states in the abstract "no detailed proofs have ever been given for these security properties for EdDSA". I am glad that these security proofs are given just before shelley was launched :)


text:
How expressive & secure is the Plutarch eDSL?
The Plutarch eDSL tries to control how plutus core is generated to create a smaller and thus a more efficient validator script (their GitHub).
I am not an in depth user of this tool. Does its approach reduce the expressiveness of the validator script? Moreover, does it reduce the intention of the script and thus lead to a loss of security?
This question is especially relevant due to recent MinSwap exploit (they use Plutarch).

I'm approaching the tool so I would not consider myself a Plutarch expert
however to my understanding, Plutarch is designed to be compatible with the entire PlutusTx API
since the real code of smart contracts (that goes on-chain) is Untyped  Plutus Core (UPLC) and both PlutusTx and Plutarch do fully cover UPLC Abstract Syntax Tree Plutarch should be equivalent in terms of expressiveness to PlutusTx.
regarding security what Plutarch does more than PlutusTx is just being strictly-evaluated so the underlying logic should not be different, only the way to get to the final result changes
MinSwap did used both PlutusTx and Plutarch for the smart contracts, and the incriminated code (validateMintNFT) was written using PlutusTx
in particular the function isUnity was allowing to duplicate (not so much) Non Fungible Tokens
tweag (the company that audited the smart-contracts prior releasing them) has an entire dedicated article