text:
Is there a standard for represanting traits in metadata for NFT collectables
Projects like jpg store or cnft tools collect information from blockchain about minted NFTs (collectables to be exact) and present that information for users to filter, buy, sell and similar.
Most of projects use cip25 which defines a standard way how to represent NFT metadata. With this standard, services like jpg.store and cnft.tools can find NFTs on blockchain (via 721 label) and render NFT metadata as described in cip25 (there are required and optional fields like description or name that can be expected in metadata).
Collectables like The Ape Society or SpaceBudz usually have set of traits and sites like jpg.store or cnft.tools render them, filter them, or they calculate rarity score or rank as shown:

What I noticed on pool.pm is that there is no unique format or specification how trait data should look. For example this nft defines traits as body of attribues field:
        "attributes": {
          "Creature": "Jambo",
          "Skin": "Silver",
          "Special": "None",
          "Type 1": "Beast",
          "Type 2": "Normal"
        },

and jpg.store correctly renders traits:

Note that in the example above jpg.store didn't take other fields like:
        "Twitter": "https://twitter.com/summoners_guild",
        "Website": "https://summonersguild.io",

and use them as traits.
So far I would think there is a rule: All fields within attributes will be used as traits.
But then these two examples don't use any attributes field as a set of traits but instead it looks like they collect every field within metadata and their traits are still rendered correctly :

As there is no specification on how trait data should be represented in NFT metadata (at least not within cip25) I wonder how sites like the ones mentioned above (jpg.store, cnft.tools, cnftjungle.io) decide what is a trait and what isn't? It seems they have reached some sort of consensus because they render NFT traits correctly but the rules are not obvious to me.

There is no standard and they have to check manually how each collection has set up the traits.
In practice, the different sites most likely have some code to check for common patterns. E.g. is there an array of "traits" or "attributes"? Or they exclude common non-trait values like "Twitter" or "Website" automatically.


text:
Cardano-Node Preprod Testnet PeerStatusChangeFailure on Mac
I am trying to run Cardano-node with preprod testnet configuration files from :
curl -O -J https://book.world.dev.cardano.org/environments/preprod/config.json
curl -O -J https://book.world.dev.cardano.org/environments/preprod/db-sync-config.json
curl -O -J https://book.world.dev.cardano.org/environments/preprod/submit-api-config.json
curl -O -J https://book.world.dev.cardano.org/environments/preprod/topology.json
curl -O -J https://book.world.dev.cardano.org/environments/preprod/byron-genesis.json
curl -O -J https://book.world.dev.cardano.org/environments/preprod/shelley-genesis.json
curl -O -J https://book.world.dev.cardano.org/environments/preprod/alonzo-genesis.json

I am using node version 1.35.3 on MacOS Monterey 12.4 using the command :
cardano-node run \
--config $HOME/cardano/preprod/config.json \
--database-path $HOME/cardano/preprod/db/ \
--socket-path $HOME/cardano/preprod/db/node.socket \
--host-addr 0.0.0.0 \
--port 1337 \
--topology $HOME/cardano/preprod/topology.json

I tried to change the host-addr and downloaded all the config files for preprod but still getting this error :
[ip-192-1:cardano.node.Server:Notice:56] [2022-10-20 13:37:56.26 UTC] TrServerStarted [0.0.0.0:1337]
[ip-192-1:cardano.node.LocalRootPeers:Info:54] [2022-10-20 13:37:56.26 UTC] TraceLocalRootDomains [(1,fromList [])]
[ip-192-1:cardano.node.PeerSelection:Notice:55] [2022-10-20 13:37:56.27 UTC] TraceTargetsChanged (PeerSelectionTargets {targetNumberOfRootPeers = 0, targetNumberOfKnownPeers = 0, targetNumberOfEstablishedPeers = 0, targetNumberOfActivePeers = 0}) (PeerSelectionTargets {targetNumberOfRootPeers = 100, targetNumberOfKnownPeers = 100, targetNumberOfEstablishedPeers = 50, targetNumberOfActivePeers = 2})
[ip-192-1:cardano.node.LocalRootPeers:Info:54] [2022-10-20 13:37:56.26 UTC] TraceLocalRootGroups (fromList [(1,fromList [])])
[ip-192-1:cardano.node.PeerSelection:Info:55] [2022-10-20 13:37:56.27 UTC] TracePublicRootsRequest 100 0
[ip-192-1:cardano.node.LedgerPeers:Info:50] [2022-10-20 13:37:56.27 UTC] [String "FetchingNewLedgerState",Number 0.0]
[ip-192-1:cardano.node.LedgerPeers:Info:50] [2022-10-20 13:37:56.27 UTC] [String "FallingBackToBootstrapPeers"]
[ip-192-1:cardano.node.LedgerPeers:Info:50] [2022-10-20 13:37:56.27 UTC] [String "UseLedgerAfter",Number 4642000.0]
[ip-192-1:cardano.node.PublicRootPeers:Info:60] [2022-10-20 13:37:56.27 UTC] TracePublicRootRelayAccessPoint [RelayAccessDomain "preprod-node.world.dev.cardano.org" 30000]
[ip-192-1:cardano.node.PublicRootPeers:Info:60] [2022-10-20 13:37:56.27 UTC] TracePublicRootRelayAccessPoint [RelayAccessDomain "preprod-node.world.dev.cardano.org" 30000]
[ip-192-1:cardano.node.PublicRootPeers:Info:60] [2022-10-20 13:37:56.34 UTC] TracePublicRootResult "preprod-node.world.dev.cardano.org" [(3.72.231.105,60)]
[ip-192-1:cardano.node.PeerSelection:Info:55] [2022-10-20 13:37:56.34 UTC] TracePublicRootsResults (fromList [3.72.231.105:30000]) 0 60s
[ip-192-1:cardano.node.PeerSelectionCounters:Info:55] [2022-10-20 13:37:56.34 UTC] PeerSelectionCounters {coldPeers = 1, warmPeers = 0, hotPeers = 0}
[ip-192-1:cardano.node.PeerSelection:Info:55] [2022-10-20 13:37:56.34 UTC] TracePromoteColdPeers 50 0 (fromList [3.72.231.105:30000])
[ip-192-1:cardano.node.ConnectionManager:Info:65] [2022-10-20 13:37:56.34 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 0})
[ip-192-1:cardano.node.ConnectionManager:Info:65] [2022-10-20 13:37:56.48 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 1})
[ip-192-1:cardano.node.ConnectionManager:Info:66] [2022-10-20 13:37:56.63 UTC] TrConnectionHandler (ConnectionId {localAddress = 172.27.228.239:1337, remoteAddress = 3.72.231.105:30000}) (TrError OutboundError (MuxError MuxBearerClosed "<socket: 30> closed when reading data, waiting on next header False") ShutdownPeer)
[ip-192-1:cardano.node.ConnectionManager:Info:66] [2022-10-20 13:37:56.63 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 0})
[ip-192-1:cardano.node.ConnectionManager:Info:65] [2022-10-20 13:37:56.63 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 0})
[ip-192-1:cardano.node.PeerSelectionActions:Error:65] [2022-10-20 13:37:56.63 UTC] PeerStatusChangeFailure (ColdToWarm Nothing 3.72.231.105:30000) (HandleFailure (MuxError MuxBearerClosed "<socket: 30> closed when reading data, waiting on next header False"))
[ip-192-1:cardano.node.PeerSelection:Info:55] [2022-10-20 13:37:56.63 UTC] TracePromoteColdFailed 50 0 3.72.231.105:30000 6.615296391013s (MuxError MuxBearerClosed "<socket: 30> closed when reading data, waiting on next header False")

Preprod environment is currently is being relaunched, so you need to wait at least 2 more days from today(20-Oct-2022).
https://t.me/SPOannouncements/227

Can you help me on how to use RPC calls on the preprod testnet server

source: Stack Exchange

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

sort: votes


text:
Is there an easy way to export a CSV file of all transactions from a specific address or wallet?
Is there an easy way, without writing code, to export a CSV file of all transactions from a specific address or wallet? (not Daedalus)

If you're using Nami you can use this https://github.com/Et9797/tx-history-viewer

Address or wallet?
The distinction is important for UTXO chains following the BIP-44 standard, because a single extended public key (wallet key) can generate a virtually infinite number of addresses. Are you looking to query a single one of these addresses, or all of the addresses associated with a single wallet?
In the case of the former, I am unaware of any easy third party solution for TX export by individual addresses. If there are none, the only option would be to query from an API endpoint like Blockfrost, or to query from your own db-sync instance.
In the case of the latter however, light wallets (like Eternl) have easy export options for the entire wallet history. You do not have to fully restore your wallet to access these features. You can instead import your wallet as read-only (requiring only the extended public key of the wallet, no signing keys), and export TX history in CSV format.

There are two ways of doing this. One is with cardano-db-sync as mentioned in @zhekson's response.
The other way is by querying the cardano-wallet executable (bundled with Daedalus) as per the documentation at https://input-output-hk.github.io/cardano-wallet/api/edge/
I have a script like this:
#!/bin/bash -eu

# https://input-output-hk.github.io/cardano-wallet/api/edge/

progname=$(basename "$0")

curl --version > /dev/null 2>&1 || { echo "${progname}: 'curl' program is missing." >&2 ; exit 1 ; }
jq --version > /dev/null 2>&1 || { echo "${progname}: 'jq' program is missing." >&2 ; exit 1 ; }

wallet_pid=$(pidof cardano-wallet)
http_port=$(lsof -Pan -iTCP -sTCP:LISTEN -p "${wallet_pid}" | tail -1 | sed 's/.*://;s/ .*//')

function api () {
  curl --silent --cert ~/.local/share/Daedalus/mainnet/tls/client/client.crt \
    --cacert ~/.local/share/Daedalus/mainnet/tls/client/ca.crt \
    --key ~/.local/share/Daedalus/mainnet/tls/client/client.key \
    "https://localhost:${http_port}/v2/$1"
}

function wallets () {
  api wallets | jq '.[] | {name: .name, id: .id, state:.state.status, pool:.delegation.active.target, balance: (.balance.total.quantity / 1000000) }'
}

function transactions () {
  echo "TransactionId,Timestamp,Direction,AmountAda"
  api "wallets/$1/transactions" \
    | jq -r '.[] | [.id, .inserted_at.time, .direction, .amount.quantity / 1000000] | @csv' \
    | sort --field-separator=',' --key 2
}

function usage_exit {
  echo
  echo "Usage:"
  echo "  $progname wallets                   - List the known wallets."
  echo "  $progname transactions <wallet>     - List all transactions for a given wallet."
  echo
  exit 0
}

case "${1:-""}" in
  wallets)
    wallets
    ;;
  transactions)
    shift
    if test $# -eq 1 ; then
      transactions "$1"
    else
      echo
      echo "Error: A wallet needs to be specified."
      usage_exit
      fi
    ;;
  *)
    usage_exit
  esac

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


text:
What are the types of data that are stored on the Cardano blockchain?
Is anything other than blocks which contain zero or more transactions, stored? Is e.g ledger state stored, is there anything special added at epoch boundaries?

Ledger state is not stored on the blockchain, but if you start with the correct initial ledger state and apply all blocks, in the correct sequence, from genesis to the current tip, you can recreate ledger state.
The things stored on the block chain include (may not be a complete list):

Blocks.
Transactions.
Stake pool registration certificates.
Stake pool parameter changes.
Stake address registrations certificates.
Staking delegation certificates (basically a special part of a transaction).
Proposals and voting for protocol parameters changes.

Things that are part of ledger state that is not stored on the blockchain (may also be incomplete):

The current UTxO state.
Current amount of ADA delegated to each stake pool.
Which stake address is currently delegated to each pool.
Rewards account balances for each stake address.
Current protocol parameters.

is there anything special added at epoch boundaries?

For the first Byron era there was an Epoch Boundary Block, but for all eras after that, there are no Epoch Boundary Blocks.

A follow-up question: given that Cardano is written in Haskell, is there an ADT somewhere that represents the single item that goes on the chain. Something like data Block = Txs ... | StakePoolAction ... | Proposal ...?

Unfortunately there is not a single type. The main complication is that all the types you mention are unique for each era (eg Byron, Shelley, Allegra, Mary, Alonzon, Babbage etc).  IMO this is an implementation detail that leaks out of cardano-api. For each era Block is a product type (ie a struct) with fields for transactions and all the other components. The current best way to access this is via cardano-api in the cardano-node repo.

I think this answer is partly wrong then: https://cardano.stackexchange.com/questions/1977/how-is-the-active-stake-of-a-stake-pool-calculated/1993#1993. It says "Data captured by the snapshot is stored on-chain as a part of the ledger state", for me that sentence implies that ledger state is stored on-chain as well.

Maybe its the other answer that is wrong. Some (but not all) parts of ledger state are available indirectly on chain. For instance, if you extract all the stake delegations from the chain, you can reconstruct the stake distribution for an epoch, but the stake distribution for an epoch is not directly stored on chain. The reward accounts for all stake addresses can be reconstructed by playing back the block chain, but the reward account balances are not on chain,

Also the full ledger state is HUGE . When stored on disk (db-sync actually does this) in a relatively compact form a single ledger state snapshot is about 2 gigaybtes in size. If that data was stored on chain, the chain would be significantly bigger than it is.

On the transaction you can store some (little metadata)
But a blockchain is not a distributed database.
usage of such feature is dependente on your use case.
Example:
I want to have in the blockchain all repair information of my car.
I'd attach to the transaction a hash that represents data on an "open database" so the record if changed no longer has the hash that was stored on chain.
then your car has its own wallet and anyone can see it's repair history...with confidence it's not faked


text:
No relay IP at https://explorer.mainnet.cardano.org/relays/topology.json after more than 2 weeks
I have to say, that i have already done 1 SPO about month ago, and all was fine.
Today i have struggling with another one that i have to set up.
All looks like fine, but i can't see mine realay IP on https://explorer.mainnet.cardano.org/relays/topology.json and no metter what i do.. (First SPO relay was there really quick)
So please help me to figure out what is wrong now..
ScreenShots (let me know if need any more)

All looks like fine, but i can't see mine realay IP on https://explorer.mainnet.cardano.org/relays/topology.json and no metter what i do

That URL only fetches relays that are registered as part of pool registration and can be reached publicly - besides, it is refreshed to catch peers publicly twice a week (might have changed since). So if you have modified your pool registration details to include your new relay, and your pool is reachable publicly - you might want to wait for a few days before trying to query that URL.
Your outbound topology.json file or subscription to topology Updater is irrelevant to be listed on the mentioned link.

RdLrT thansk for anwser. I'm a little be confused, so it's no metter if my relay ip is not there? It's still will work correctly and produce blocks?
I ask it, cose all tutorials says that i have to be in that list, before continue set up SPO. In another words if you not in that list, your SPO will not produce block or will produce but no rewards will be generated..
P.S. It's new SPO with 1 bp and 1 relay. It's not extend currenct SPO with another relay.

Btw that file last update was: last-modified: Thu, 22 Sep 2022 20:29:47 GMT or last-modified: Thu, 01 Sep 2022 14:00:21 GMT it's depends what file loaded (cose there is 2 different files). It's obviously is something wrong with that..

You need incoming peers (be it via topologyUpdater or other manual peering arrangements with different SPOs) - but the link you're looking at isn't a source of truth, and the peers that appear in the list are as mentioned in the reply


text:
Attempting to build (NFT) transaction in Python and push through Cardano-cli

right now I am getting the system can't find the path specified but I have tried with and without passing the path in as a variable.
I am running this in Python 3.6+ in Visual Studio Code on Windows.

Is there a particular reason why you don't use a Python library (like Pycardano) for building transactions?

I know there are other libaries, but I am looking to build from ground up just to understand the process.


text:
Obtain a wallet address from PKH and wallet ID in python?
I need a bech32 wallet address and all that I have is my wallet PKH and a wallet Id. Is there a way to derive that bech32 address in python?
Needed to perform queries on blockfrost and find how much amount of ADA I have in my wallet.

You can use pycardano to derive the address from a public key file.
Example:
from pycardano import Key, Address, Network

pk = Key.load("/path/to/payment.vkey")
pkh = pk.hash()
addr = Address(payment_part=pkh, Network.MAINNET)
print(addr)

If you already have the public key hash, use the following code to get pkh:
from pycardano import VerificationKeyHash
pkh = VerificationKeyHash(bytes.fromhex("1234abcd..."))

You can learn more about key and address manipulations in this page: https://pycardano.readthedocs.io/en/latest/guides/address.html

The PKH is for verifying the authenticity of a signed transaction. We couldn't convert it to the bech32 wallet address. Hashing is a one-way function. It means that if you hash a piece of data, it is impossible to revert the hash to its original form.
For instance, we consider a simple function used to get the modulus of 3 and a list of the input value
1 `mod` 3 = 1
2 `mod` 3 = 2
3 `mod` 3 = 3
4 `mod` 3 = 1

In this example, the list of the input value is [1,2,3,4] and the list of hash results is [1,2,3,1]. So the 1 can be from 1, 4, 7, and so on. This is for the demonstration only, In practice hash functions shouldn't result in a small range of values like this.


text:
Does it make sense to talk of reference script in the context of parameterized script?
In my understanding, if my script is parameterized, I would need to know the parameters to generate the script and then store it at an address to be later referred. But usually set of possible values for parameters could be very large, so am I right in assuming that design decision of making script parameterized would make me lose the benefit of referencing it?

You are correct, if you have a parametrized script which you did not 'inject' yet with the parameters, you cannot leverage the referencing of the script.
Note that script referencing is also costly, the initial transaction that attaches the script to an output is expensive. You pay for the size you put on the active part of the chain. If your script is used often, you can save these costs by having lower transaction costs when referencing the script. This break even point has to be considered! If you only use it once, you won't get the cost of it out of the usage.
That said, you could also inject this parametrized data via another way! That is, do not parametrize your script, but retrieve the data from a reference input. Important here, do not forget to mark this input with an NFT to make it secure (remember that anybody can send anything anywhere). The location of the NFT + data in datum is your choice. You could make it so that you can update it, or so that you can have multiple instances of it. So, you can reference an unparametrized script this way :)


text:
User error: Caused by: [ (builtin unConstrData) (con data #187b) ] while trying to unlock tokens from contract
hi I am getting this error while trying to unlock tokens from my treasury contract it is already topp up with tokens when trying to unlock with the access token doesn't know the exact reason behind this pls help me out
StackingTreasury.hs
{-# LANGUAGE DeriveAnyClass        #-}
{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
module Stake.StackingTreasury where

import              Ledger              hiding (singleton)
import qualified Ledger.Typed.Scripts as Scripts
import              Ledger.Value        as Value
import              Ledger.Ada
import qualified    PlutusTx
import              PlutusTx.Prelude    hiding (Semigroup (..), unless)

import              Stake.StackingTypes

{-# INLINEABLE mkValidator #-}
mkValidator :: TreasuryParam -> WithdrawalDatum -> StackingDetails -> ScriptContext -> Bool
mkValidator tp dat b ctx =    traceIfFalse "Only Issuer can change Treasury"              signedByIssuer ||
                              traceIfFalse "Access token missing from input"              inputHasAuthToken &&
                              traceIfFalse "Access token missing from contract output"    contractOutputHasAuthToken &&
                              traceIfFalse "Output Value must match StackingDetails"      checkValueToStackingContract &&
                              traceIfFalse "Treasury must keep remaining tokens"          treasuryGetsTokensBack &&
                              traceIfFalse "redeemer is not datum"                        checkReIsOutDat

  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    signedByIssuer :: Bool
    signedByIssuer = txSignedBy info $ tTreasuryIssuerPkh tp

    -- Create a list of all CurrencySymbol in tx input
    inVals :: [CurrencySymbol]
    inVals = symbols $ valueSpent info

    -- Check that list of CurrencySymbols includes Auth CurrencySymbol
    inputHasAuthToken :: Bool
    inputHasAuthToken = tAccessTokenPolicyId tp `elem` inVals

    -- The Value to be included in Stacking Contract UTXO
    toStackingContract :: Value
    toStackingContract = valueLockedBy info (bountyContractHash tp)

    -- Check that the Auth Token is sent to Bounty Contract UTXO
    contractOutputHasAuthToken :: Bool
    contractOutputHasAuthToken = tAccessTokenPolicyId tp `elem` symbols toStackingContract

    -- Check that the Value sent to Contract UTXO matches what is specified in the Redeemer
    -- Note: For now, we can just remember to match Treasury Redeemer to Bounty Datum
    -- when we build transactions
    checkValueToStackingContract :: Bool
    checkValueToStackingContract =  valueOf toStackingContract (tBountyTokenPolicyId tp) (tBountyTokenName tp) >= tokenAmount b

    -- The UTXO input from Treasury
    ownInput :: TxOut
    ownInput = case findOwnInput ctx of
        Nothing -> traceError "treasury input missing"
        Just i  -> txInInfoResolved i

    -- The UTXO output back to Treasury
    ownOutput :: TxOut
    ownOutput = case getContinuingOutputs ctx of
        [o] -> o -- There must be exactly ONE output UTXO
        _   -> traceError "expected exactly one treasury output"

    -- Values of each
    treasuryInputValue :: Value
    treasuryInputValue = txOutValue ownInput

    treasuryOutputValue :: Value
    treasuryOutputValue = txOutValue ownOutput

    -- Compare Values from and to Treasury to make sure that Treasury gets the right value back.

    treasuryGetsTokensBack :: Bool
    treasuryGetsTokensBack = valueOf treasuryInputValue (tBountyTokenPolicyId tp) (tBountyTokenName tp) - valueOf treasuryOutputValue (tBountyTokenPolicyId tp) (tBountyTokenName tp) <= valueOf toStackingContract (tBountyTokenPolicyId tp) (tBountyTokenName tp)

    getStackingDatum :: Maybe StackingDatum
    getStackingDatum = let os = [ o | o <- txInfoOutputs info, txOutValue o == toStackingContract ] in
                  case os of
                    [o] -> stackingDatum o (`findDatum` info)
                    _   -> Nothing

    checkReIsOutDat :: Bool
    checkReIsOutDat = case getStackingDatum of
      Nothing -> False
      Just ns -> bedIssuerPkh   ns == issuerPkh b &&
                 bedContributorPkh ns == contributorPkh b &&
                 bedTokenAmount ns == tokenAmount b &&
                 bedExpirationTime ns == expirationTime b

-- typedValidator :: TreasuryParam -> TypedValidator TreasuryTypes
-- typedValidator tp =
--   mkTypedValidator @TreasuryTypes
--     $$(PlutusTx.compile [||mkValidator||]) `PlutusTx.applyCode` PlutusTx.liftCode tp
--     $$(PlutusTx.compile [||wrap||])
--   where
--     wrap = wrapValidator @WithdrawalDatum @StackingDetails

-- validator :: TreasuryParam -> Validator
-- validator = validatorScript . typedValidator

typedValidator :: TreasuryParam -> Scripts.TypedValidator TreasuryTypes
typedValidator tp = Scripts.mkTypedValidator @TreasuryTypes
    ($$(PlutusTx.compile [|| mkValidator ||])
        `PlutusTx.applyCode` PlutusTx.liftCode tp)
    $$(PlutusTx.compile [|| wrap ||])
  where
    wrap = Scripts.wrapValidator @WithdrawalDatum @StackingDetails

validator :: TreasuryParam -> Validator
validator = Scripts.validatorScript . typedValidator

utxo at treasury address with datum hash of 123
cardano-cli query utxo --address addr_test1wpcsng9wvph3yn6felqewnq9wwcvuwpwdumrax2dset0vecwhasah --testnet-magic 1

result
                     TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
0e4f0c3c372bb3c3d044f4ff72f200ad962f0f51190794dc43ca8f119b0faec2     1        2000000 lovelace + 99999999 d7d0b7e1195d3c51fefcf4e40146de39fe11162dcc56427f9e9db196.48616c + TxOutDatumHash ScriptDataInBabbageEra "7cfec515f56d4413375aa9775f5de15ee60180861e9eaa954bcf9d015054857c"

getting this error while trying to unlock funds from treasury conttract to stacking contract
Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with:
The Plutus script evaluation failed: An error has occurred:  User error:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: [ (builtin unConstrData) (con data #187b) ]
Script debugging logs:

unlocking command
CONTRACT_TXIN="0e4f0c3c372bb3c3d044f4ff72f200ad962f0f51190794dc43ca8f119b0faec2#1"
TOKENS_BACK_TO_TREASURY=99999989
BOUNTY_ADDR=addr_test1wz0r05r5gmfykqzt6uavku4ncacxxd60sj2auadaefudntc3cyvrk
BOUNTY_ASSET="d7d0b7e1195d3c51fefcf4e40146de39fe11162dcc56427f9e9db196.48616c"
CONTRIBUTOR_ASSET="e8abf29fc898134b44c1af4148ad15a6840c53d4d5e67483fba24ac3.6e696b6b69"
TREASURY_ADDR=addr_test1wpcsng9wvph3yn6felqewnq9wwcvuwpwdumrax2dset0vecwhasah
TREASURY_PLUTUS_SCRIPT="output/treasury.plutus"
BOUNTY_DATUM="datum.json"
CONTRIBUTOR=addr_test1vr5uap3n4mu4kcetl0luz25re3x93yfjc3kdq0ud4c2xassvq0wsd
TXIN1="b61083800814c048d1c464d8306cc817a559565e6ca10d7f887eb23cfd3e5f1b#1"
TXIN2="b72f8592ab7f740f46ba461d0302f82a69c0134c95df1622fb31ca7b5141f405#0"
COLLATERAL="290fa91f253f968f20fa347c9a8371263c7e852e9bf611a7eb91c35818fd0edf#0"
BOUNTY_AMOUNT=10

cardano-cli transaction build \
--babbage-era \
--tx-in $CONTRACT_TXIN \
--tx-in-script-file $TREASURY_PLUTUS_SCRIPT \
--tx-in-datum-value 123 \
--tx-in-redeemer-file $BOUNTY_DATUM \
--tx-in $TXIN1 \
--tx-in $TXIN2 \
--tx-in-collateral $COLLATERAL \
--tx-out $BOUNTY_ADDR+"2000000 + 1 $CONTRIBUTOR_ASSET + $BOUNTY_AMOUNT $BOUNTY_ASSET" \
--tx-out-datum-embed-file $BOUNTY_DATUM \
--tx-out $TREASURY_ADDR+"2000000 + $TOKENS_BACK_TO_TREASURY $BOUNTY_ASSET" \
--tx-out-datum-hash 7cfec515f56d4413375aa9775f5de15ee60180861e9eaa954bcf9d015054857c \
--change-address $CONTRIBUTOR \
--protocol-params-file protocol.json \
--testnet-magic 1 \
--out-file commitment-tx.draft

You need to provide datum and redeemer that match the types your validator is expecting. Those funds cannot be unlocked now because the datum hash is for a value of a different type.
You're using datum value 123, which is of type Integer but your validator expects WithdrawalDatum. You're passing datum.json for your redeemer, that must be using correct schema for type StackingDetails.

i used datum hash of 123 for locking funds should I try a different datum with unlocking

is there no way to unlock a utxo that was instansiated with the wrong datum type?

There's currently no way to unlock utxo with a hash for the wrong datum type, same goes for the absence of hash.


text:
Is there a possibility to fetch the volumen of e.g Minswap with Koios or Blockfrost?
I am looking for a way to get the volume of certain protocols on Cardano(e.g. Minswap or SundaeSwap). I thought of using Koios or Blockfrost, but I am not entirely sure how to get volume. If there's some math involved I don't have a problem.
I'm happy with any approach that might work. xD

IMHO, the best way to fetch stats from specific protocols is to use their APIs or data points. You can reach out to their teams to know more about this. Discord servers seem to be a good starting point, since the majority of the Devs are there.
In the meantime, I suggest checking this post that already has information on some DEXes.

Thanks for your answer. It helps a lot.


text:
Compile errors when importing Cardano Serialization Lib Browser in React
I'm getting several compile errors as soon as I import @emurgo/cardano-serialization-lib-browser in my project, all of them similar to these:
ERROR in ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js 19251:82-105
Can't import the named export '__wbindgen_realloc' (imported as 'wasm') from default-exporting module (only default export is available)

ERROR in ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js 19280:36-58
Can't import the named export '__wbindgen_malloc' (imported as 'wasm') from default-exporting module (only default export is available)

ERROR in ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js 19280:60-83
Can't import the named export '__wbindgen_realloc' (imported as 'wasm') from default-exporting module (only default export is available)

ERROR in ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js 19482:36-58
Can't import the named export '__wbindgen_malloc' (imported as 'wasm') from default-exporting module (only default export is available)

ERROR in ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js 19482:60-83
Can't import the named export '__wbindgen_realloc' (imported as 'wasm') from default-exporting module (only default export is available)

ERROR in ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js 19497:12-23
Can't import the named export 'memory' (imported as 'wasm') from default-exporting module (only default export is available)

Is there any other library I should use on a React project to handle wallet interaction?

I suggest using dcSpark's Cardano Multiplatform Lib: https://www.npmjs.com/package/@dcspark/cardano-multiplatform-lib-browser.


text:
How can I add Webpack to a React app so I can use Lucid with it?
I have a React app (created with npx create-react-app) that doesn't have Webpack installed. I want to add lucid-cardano to it. Going through Lucid documentation, I found that Webpack is a dependency, since I need to enable webpack.config.js file with the following configuration to make it work:
experiments: {
    asyncWebAssembly: true,
    topLevelAwait: true,
    layers: true // optional, with some bundlers/frameworks it doesn't work without
}

I tried to install Webpack in my project but it seems I am missing a lot of things, since I not only have to add the webpack.config.js file but also some loaders and a server to serve the bundle.js generated (I got to this point with no issues).
This is the webpack.config.js file I generated for my project:
// Webpack uses this to work with directories
const path = require('path');

// This is the main configuration object.
// Here, you write different options and tell Webpack what to do
module.exports = {

  experiments: {
    asyncWebAssembly: true,
    topLevelAwait: true,
    layers: true // optional, with some bundlers/frameworks it doesn't work without
  },
  resolve: {
    extensions: ['', '.js', '.jsx', '.css']
  },
  // Path to your entry point. From this file Webpack will begin its work
  entry: './src/index.js',

  // Path and filename of your result bundle.
  // Webpack will bundle all JavaScript into this file
  output: {
    path: path.resolve(__dirname, 'dist'),
    publicPath: '',
    filename: 'bundle.js'
  },

  // Default mode for Webpack is production.
  // Depending on mode Webpack will apply different things
  // on the final bundle. For now, we don't need production's JavaScript
  // minifying and other things, so let's set mode to development
  mode: 'development',
  module: {
    rules: [
        {
          test: /\.js$/,
          exclude: /(node_modules)/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env']
            }
          }
        },
        { test: /\.css$/, use: { loader: "css-loader" } }
    ]
  }
};

What are the steps I am missing to correctly serve my frontend and be able to use lucid-cardano?

You do need webpack to work with lucid-cardano.
This is a very good and complete guide on how you can add webpack to a react app: https://jsramblings.com/creating-a-react-app-with-webpack/.


text:
Can't submit transaction on Ada on Babbage era. BabbageOutputTooSmallUTxO error
I'm following the official documentation to send a transaction but I'm still getting the same issue even after to double checked my protocol.json. Based on the protocol, it's supposed to be "minUTxOValue": 1000000
On my account on the mainnet we can see my UTXO
// cardano-cli query utxo --address $(cat payment.addr) --mainnet

                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
0c1188f9b5eed8ed8c4b7031ba0bd05cd3d38fea947f1acb1467bcc5baba9583     0        40000000 lovelace + TxOutDatumNone
e663b2e14f180ae341a49bcbde247d074d944942cc3b8794277645ac1e49d377     0        8336205 lovelace + TxOutDatumNone

And I'm running this to submit my transaction:
cardano-cli transaction build-raw \
    --tx-in 0c1188f9b5eed8ed8c4b7031ba0bd05cd3d38fea947f1acb1467bcc5baba9583#0 \
    --tx-out $(cat payment2.addr)+20000000 \
    --tx-out $(cat payment.addr)+20000000 \
    --invalid-hereafter 0 \
    --fee 0 \
    --out-file tx.draft

I know the fees can change but keep in mind I'm using the most recent everytime.
cardano-cli transaction calculate-min-fee \
    --tx-body-file tx.draft \
    --tx-in-count 1 \
    --tx-out-count 2 \
    --witness-count 1 \
    --byron-witness-count 0 \
    --mainnet \
    --protocol-params-file protocol.json

The result for this one is: 176765
expr 40000000 - 20000000 - 176765

For this one the result will be: 19823235.
Then, to update my draft I'm doing this:
cardano-cli transaction build-raw \
    --tx-in 0c1188f9b5eed8ed8c4b7031ba0bd05cd3d38fea947f1acb1467bcc5baba9583#0 \
    --tx-out $(cat payment2.addr)+20000000 \
    --tx-out $(cat payment.addr)+19823235 \
    --invalid-hereafter 75301753 \
    --fee 176765 \
    --out-file tx.draft

Finally I'm signing and sending like this:
// to sign
cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --mainnet \
    --out-file tx.signed

// to submit
cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet

The result is every time is:
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (BabbageOutputTooSmallUTxO [((Addr Mainnet (KeyHashObj (KeyHash "fe424f32d70231494b27921b57a2485fe4e293ae76b7620216703f9c")) (StakeRefBase (KeyHashObj (KeyHash "5d452ab59c3d40e339da2cc8fe5b57d280363eddd5152374adc4cd23"))),Value 826271 (fromList []),NoDatum,SNothing),Coin 969750)])),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (OutsideValidityIntervalUTxO (ValidityInterval {invalidBefore = SNothing, invalidHereafter = SJust (SlotNo 75259418)}) (SlotNo 75302578))))])

This is my environment:
cardano-cli 1.35.3 - linux-x86_64 - ghc-8.10

I was wondering if it's an issue from Cardano because I'm clearly following the official documentation.
Thank you so much to the people who can help me.

You're building tx.draft then signing tx.raw. Check you're not using an old txbody.

Thank you so much mate <3


text:
Plutus Emulator trace halting with MintingPolicyNotFoundError
I have the following simple minting script:
{-# INLINABLE unrestricted #-}
unrestricted :: () -> ScriptContext -> Bool
unrestricted () _ = True

unrestricted_policy :: MintingPolicy
unrestricted_policy
    = mkMintingPolicyScript
    $ $$(PlutusTx.compile [|| mkUntypedMintingPolicy unrestricted ||])

unrestricted_policy_sym :: CurrencySymbol
unrestricted_policy_sym = scriptCurrencySymbol unrestricted_policy

annd the following off-chain code:
contract0 :: Contract () Empty Text ()
contract0 = do
    Contract.logInfo @String "unrestricted starting..."
    let val = Value.singleton unrestricted_policy_sym (TokenName "ABC") 1
    let lookups = C.mintingPolicy unrestricted_policy
    let tx = C.mustMintValue val
    ledgerTx <- submitTxConstraintsWith @Void lookups tx
    void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
    Contract.logInfo @String "unrestricted done!"

Any ideas why it's failing?
When I run in the emulator I get the following error:
Slot 00001: *** CONTRACT STOPPED WITH ERROR: "\"ConstraintResolutionContractError (MintingPolicyNotFound 3e112e7d22026ab6ad0e1c77c950cbb8fd5c8568bc5a63950e11bda1)\""

I don't think this would even compile with latest main branch due to mintingPolicy :: Versioned MintingPolicy -> ScriptLookups a.
Can you update and replace C.mintingPolicy with C.plutusV1MintingPolicy

Thanks - it's working now!


text:
Problem when importing Lucid in Next.js project with Typescript
I am getting the following error when trying to import lucid-cardano in a Next.js Typescript project:
TypeError: Cannot set property Headers of #<Object> which has only a getter
    at file:/node_modules/lucid-cardano/esm/src/core/core.js:12:20 {
  page: '/'
}

I also found this recent issue submitted to Lucid: https://github.com/spacebudz/lucid/issues/106
Any ideas?

There was an error in lucid-cardano library. It was fixed in this PR. I was able to re-test and my Next.js project is working as expected.


text:
cardano-db-sync different tx, same hash?
I'm listening for new records added on block table and have noticed that sometimes two blocks are added almost at the same time with basically the same info except for block hash (maybe a slot battle/rollback, since eventually one of the blocks gets removed?).
The thing is when asking for the block's transactions UTXOS the block got removed return transactions with the same hash that the one who finally stays on chain but the transaction inputs/outputs are different (empty in this case).
So essentially the process is the following:

New block gets added into dbsync
Get block info (pool, transactions)
Get block transactions utxos which are empty. Probably empty is just one case and the important here is the fact that the tx for the two blocks are different but has the same hash.
Another block gets added into dbsync
Repeat step 2
Get block transactions utxos which aren't empty but have the same tx hash of the one returned by previous block

How is this posible, I think blocks is ok that enter into dbsync and the get removed due to rollbacks/slot battles but why the two blocks ended up with different txs (inputs/outputs) but the same hash?.
here is an example:
// arrive time [2022-10-28 13:40:52 UTC]
block info:
{
    "id": "7956798",
    "hash": "4eafa57522c951c571ef7f1f4f6c834b033ad2183121e4a02c9fd6f46ab91b8f",
    "epoch_no": 372,
    "slot_no": "75398161",
    "epoch_slot_no": 57361,
    "block_no": 7941775,
    "previous_block": 7941774,
    "next_block": null,
    "slot_leader": "pool17kew7rtakc7g6qzydntann5umw08xq3ll2j7spk7en4kvff69fa",
    "size": 58863,
    "time": "2022-10-28T13:40:52.000Z",
    "tx_count": "36",
    "out_sum": "6189878553712",
    "fees": "11268611",
    "confirmations": 1,
    "op_cert": "bf9af4d99bb361e89db95bde6303f756d864f85142691f92d897bafd986df8a9",
    "vrf_key": "vrf_vk1ygptnml8rkgw9dmguft6dr8dnjaapk80lsynqdwzl9aap08qg6mslll3fc",
    "pool": {
        "pool_id": "pool17kew7rtakc7g6qzydntann5umw08xq3ll2j7spk7en4kvff69fa",
        "raw_id": "f5b2ef0d7db63c8d00446cd7d9ce9cdb9e73023ffaa5e806decceb66",
        "url": "https://bloompool.io/bloom-3.metadata.json",
        "hash": "3cdd486927f8819dadb60ad8e9be691b8ba0ffa94b0356c38fe031b8f55b905f",
        "name": "Bloom Three",
        "ticker": "BLOOM",
        "homepage": "https://bloompool.io/",
        "description": "Bloom is committed to providing top quality staking services to our delegates through low latency, 24/7 uptime, and the highest return on stake. Operated by bigpey."
    },
    "transactions": [
        {
            "id": "53459220",
            "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
            "block_id": "7956798",
            "block_index": 25,
            "out_sum": "107197930",
            "fee": "183849",
            "deposit": "0",
            "size": 642,
            "invalid_before": null,
            "invalid_hereafter": "75408970",
            "valid_contract": true,
            "script_size": 0,
            "outputs": [],
            "inputs": []
        }
    ]
}

// arrive time [2022-10-28 13:40:53 UTC]
block info:
{
    "id": "7956799",
    "hash": "4d8296d03f2a0a471a16e34f2204026ac3c82311dfa2569fbb7f680e4cf3e66b",
    "epoch_no": 372,
    "slot_no": "75398161",
    "epoch_slot_no": 57361,
    "block_no": 7941775,
    "previous_block": 7941774,
    "next_block": null,
    "slot_leader": "pool1ddg6t2h9kj6lqlec4ncjs945lzj43m3ggrgdhf5sgzhtygpkznz",
    "size": 58863,
    "time": "2022-10-28T13:40:52.000Z",
    "tx_count": "36",
    "out_sum": "6189878553712",
    "fees": "11268611",
    "confirmations": 1,
    "op_cert": "d5b849f9757cd2ef60c883b092a7e985d27c22f89aac7648b13d3cfd4cce4737",
    "vrf_key": "vrf_vk1m5tnjq3exhpu8mfcy6rl5xe5jedd8adzx6n5syju3vj8p5yhfels900hls",
    "pool": {
        "pool_id": "pool1ddg6t2h9kj6lqlec4ncjs945lzj43m3ggrgdhf5sgzhtygpkznz",
        "raw_id": "6b51a5aae5b4b5f07f38acf12816b4f8a558ee2840d0dba69040aeb2",
        "url": "https://fairpool.eu/fair01.json",
        "hash": "8127f98bbad5af53a473e609d11e90f4135c2ae8cc86f27fafada12681a25d37",
        "name": "Fair Pool #01",
        "ticker": "FAIR",
        "homepage": "https://fairpool.eu",
        "description": "Highly available pool with a fair margin of 0.5%"
    },
    "transactions": [
        {
            "id": "53459256",
            "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
            "block_id": "7956799",
            "block_index": 25,
            "out_sum": "107197930",
            "fee": "183849",
            "deposit": "0",
            "size": 642,
            "invalid_before": null,
            "invalid_hereafter": "75408970",
            "valid_contract": true,
            "script_size": 0,
            "outputs": [
                {
                    "address": "addr1qydesz3sg492xwwynmv9hq4jn5t9fw4gz9gm8z7vxzzssa5m4mchcz7v3u7xrhssl83yah25vxgcjahdlp5u03t3sd2sx48u9r",
                    "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
                    "index": 1,
                    "value": "72197930",
                    "smart_contract": false,
                    "assets": [
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5933",
                            "fingerprint": "asset1mnj2sgz8jufya0t9q3ccv8k5xxzsmwafzcvptc"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands6359",
                            "fingerprint": "asset154fae8j77qnn99ku6k507h5plltrfmey9ap4ff"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4121",
                            "fingerprint": "asset13ul3yk367rgsn6jn9dcyflm6vel4rf0gns86kr"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1482",
                            "fingerprint": "asset1cwllcee0vm2630skuxhnkqchz8rel2qpl0nxwy"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5324",
                            "fingerprint": "asset1wr6uxxamarkwmg5thf0f0dmwy06r7trse3xwp2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5160",
                            "fingerprint": "asset13pk5cux9xue205w52vjl66xgu428tz63rhn4u3"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5682",
                            "fingerprint": "asset1wmw0pw6ft3f5myajkvxfwd5d884u9hhqj49dhz"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1990",
                            "fingerprint": "asset1ha6at2s482re94tqazh5hlq28tv9nu6z4t3jwx"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5777",
                            "fingerprint": "asset122ue962qgvy3kc0qazlpn2ljdnlsdczl8l7a9t"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4925",
                            "fingerprint": "asset18lhkp5al2xs5zu5pq7zjehymnne8md5ypy7nhp"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands7245",
                            "fingerprint": "asset1usc3r3rmthdpgs3894z6s8vc926vwjcxzd7te2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands3366",
                            "fingerprint": "asset1mua39yqstznzxwscuql2krmrayh0f7achj0qzx"
                        }
                    ]
                },
                {
                    "address": "addr1v97783v9dgj5vh6xlgwxazmgem2mpm0lz90vmgjs0kpz24sjc0usf",
                    "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
                    "index": 0,
                    "value": "35000000",
                    "smart_contract": false,
                    "assets": []
                }
            ],
            "inputs": [
                {
                    "address": "addr1q8j27e5gt6jwy3nqx9x2g85c5zmwlfdvqnv3v9xer2dymh5m4mchcz7v3u7xrhssl83yah25vxgcjahdlp5u03t3sd2s86ucr3",
                    "hash": "9589e00ac142b8a42813efc01da95f52fe8d3cac5263ef7d4888e02a072b250b",
                    "index": 1,
                    "value": "107381779",
                    "smart_contract": false,
                    "assets": [
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5160",
                            "fingerprint": "asset13pk5cux9xue205w52vjl66xgu428tz63rhn4u3"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4121",
                            "fingerprint": "asset13ul3yk367rgsn6jn9dcyflm6vel4rf0gns86kr"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands3366",
                            "fingerprint": "asset1mua39yqstznzxwscuql2krmrayh0f7achj0qzx"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5777",
                            "fingerprint": "asset122ue962qgvy3kc0qazlpn2ljdnlsdczl8l7a9t"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5324",
                            "fingerprint": "asset1wr6uxxamarkwmg5thf0f0dmwy06r7trse3xwp2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands6359",
                            "fingerprint": "asset154fae8j77qnn99ku6k507h5plltrfmey9ap4ff"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands7245",
                            "fingerprint": "asset1usc3r3rmthdpgs3894z6s8vc926vwjcxzd7te2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4925",
                            "fingerprint": "asset18lhkp5al2xs5zu5pq7zjehymnne8md5ypy7nhp"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5682",
                            "fingerprint": "asset1wmw0pw6ft3f5myajkvxfwd5d884u9hhqj49dhz"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1482",
                            "fingerprint": "asset1cwllcee0vm2630skuxhnkqchz8rel2qpl0nxwy"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5933",
                            "fingerprint": "asset1mnj2sgz8jufya0t9q3ccv8k5xxzsmwafzcvptc"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1990",
                            "fingerprint": "asset1ha6at2s482re94tqazh5hlq28tv9nu6z4t3jwx"
                        }
                    ]
                }
            ]
        }
    ]
}

I'm listening for new records added on block table and have noticed that sometimes two blocks are added almost at the same time with basically the same info except for block hash.

Yes this is a result of a rollback which is often (but not always) a result of a slot battle. As part of this rollback, db-sync will end up deleting one of these blocks.

... why the two blocks ended up with different txs (inputs/outputs) but the same hash?.

But the hashes are not the same. For the first its 4eafa57522c951c571ef7f1f4f6c834b033ad2183121e4a02c9fd6f46ab91b8f and for the second its 4d8296d03f2a0a471a16e34f2204026ac3c82311dfa2569fbb7f680e4cf3e66b. The both start with a 4 but are not the same.

Hi, thanks for the quick reply. About the same hash I was referring to the tx hash no block hash. It seems the issue is some gaps between my logic fetching the data and the slot battle/rollback happening.

Two blocks targeting the same block height are likely to have predominantly the same set of transactions. If one of these  blocks gets rolled back, all the transactions in that block will also be rolled back.


text:
db-sync "Killed" sometimes. Why?
I have cardano-node and db-sync running just fine, latest versions.
Every now and then though, db-sync stops and message in console says "Killed".
This was not the case before the Vasil HF.
Why does db-sync stop and exit with message "Killed" ?
I start it back up, and it starts np - and runs fine for awhile, but sooner or later, after days...for some reason it will stop and the last thing in the console window is one line with the word: Killed.

RAM. That's it.
I have 32 GB on board, but although it was enough until recently the node & db-sync combined on one machine are using about 26 GB - which on Ubuntu, unless I do some tweaking, makes 32 GB not quite enough.
Thanks George & Erik.
here's a couple screen caps to show:

Luckily the system tells me there's space enough to expand to 64 GB, so I will.

The best solution is to add RAM, but adding say 8G of swap space might be a good shorter term solution.

db-sync has a rather high memory usage. We (I am one of the developers) are working on reducing it, but for now, the only solution is to provide more memory.
If you are running node on the same machine as db-sync (this is the recommended setup) the machine will likely need 32G of RAM.

I am not sure for the current version, but the previous version (which worked with cardano-node 1.34.1) did not run for many days with only 32 GB of RAM. I had to increase to 48 GB RAM to avoid it being killed for out of memory.

ok, thank you George & Erik. I got a machine that has 32 GB of RAM as that was the spec given in the docs at the time I was setting it up. I will examine using dmesg -T to see if that msg is indicating RAM exhaustion is indeed the culprit.
If so, I'll just be glad I have determined the cause and buy more RAM.
I will say though: pre-Vasil HF I was running on the 32 GB of RAM and never experienced the same over months of running.
I will leave this open and once examined, report back here.

This has little or nothing to do with Vasil. Its caused by the growing size of the blockchain itself and the number of stake addresses slowly increasing.

Even with 32G you will still need swap space.

Most likely it is killed because the server's RAM is exhausted. How much RAM does the server have? I assume it is running on mainnet.
You can double check with dmesg -T to see if it was really killed for Out of Memory (oom).
You should see something like this (but for cardano-db-sync, not for cardano-node):
[Wed Sep 21 15:18:41 2022] Out of memory: Kill process 77436 (cardano-node) score 637 or sacrifice child
[Wed Sep 21 15:18:41 2022] Killed process 77436 (cardano-node) total-vm:1075768476kB, anon-rss:13651644kB, file-rss:0kB, shmem-rss:0kB


text:
Can I access the epoch nonce from inside a Plutus script?
Is is possible to access the epoch nonce from your Plutus script, to use as a trusted source or randomness  ?
The only suggestion for on-chain randomness I have found, is using an RNG oracle. But the Chain already produces a random number during each epoch!
If I would like to create a Application that uses randomness infrequently, the epoch nonce is a much better candidate, since it has a much stronger source of trust than any oracle, at least the foreseeable future.
Is this possible with the current Plutus V2 implementation ?

I do not think there is a way to get the epoch nonce but I also think that in most cases, the epoch nonce is a good source of " trusted source of randomness".
Maybe explain a bit more thoroughly of what you are trying to achieve.

For example If I would like to make a grand Strategy game where the map gets generated and players get assigned spots based on a Random Number(seed), this would not have to happen often, just every time a game starts and the games can take months so no real reason to need an RNG oracle.
Or for a lottery that happens every 5 days. Epoch nonce is definitely the most trusted randomness to use for a fair draw of the winner.

Using the random-ness for a game is probably fine, but I would definitely not consider it a good source of random-ness for cryptography.

Why not for Cryptography ? Not for seed generation or anything like that(since it is obviously not private), but for a VRF scheme like Ourobors uses for the leadership schedule should be fine.

I am by no means a cryptography expert, but my understanding is that cryptography requires very high quality randomness, specifically, well beyond a single 64 bit nonce on a blockchain.


text:
What is the use of BFT node in cardano blockchain?
I searched in Cardano docs but couldn't find much related to the BFT node and how it works. And how it is used in consensus. Why is it needed? Any insights would be great. Thanks.

BFT? Do you mean OBFT (Ouroboros Byzantine Fault Tolerant)?
OBFT was the consensus mechanism used on the Cardano network towards the end of the Byron era. Block production in the Byron era was not decentralized as all blocks were created by a small set of nodes run by IOHK/IOG.
The Shelley era (which started in 2020) dropped OBFT in favor of a fully decentralized Oroborous concensus mechanism.
While OBFT is no longer used by the Cardano network, OBFT may be useful for private permissioned blockchains.


text:
Calculated fee too small for StakeRegistration cert submission via cardano-serialization-lib wallet connect
Having some issues getting a submit Stake Registration certificate using cardano-serialization-lib. The transaction builds, can can be signed, but what's weird is the correct fee is not being calculated. I have a console.log output of the fee that is being calculated at "calculated fee:166953" but the network is asking for 171177
Error: {"requiredFee":171177,"actualFee":166953}
Any ideas why the fee is not being calculated correctly by CSL ?
buildStakeRegistrationTransaction = async () => {

        const txBuilder = await this.initTransactionBuilder();
        const shelleyChangeAddress = Address.from_bech32(this.state.changeAddress);

        //obtaining my payment address
        const baseAddress = BaseAddress.from_address(Address.from_bech32(this.state.changeAddress));

        // Find the available UTXOs in the wallet and
        // us them as Inputs
        const txUnspentOutputs = await this.getTxUnspentOutputs();
        txBuilder.add_inputs_from(txUnspentOutputs, 1)

        const certs = Certificates.new();

        //Adding StakeRegistration Certificate
        certs.add(
            Certificate.new_stake_registration(
                StakeRegistration.new(
                    baseAddress.stake_cred()
                )
            )
        );

        txBuilder.set_certs(certs)

        txBuilder.add_change_if_needed(Address.from_bech32(this.state.changeAddress))

        const txBody = txBuilder.build();

        //
        console.log("calculated fee:" + txBuilder.get_fee_if_set().to_str() );

        // add witness --> shouldnt really be needed as its just a StakeReg cert ?
        const transactionWitnessSet = TransactionWitnessSet.new();
        const tx = Transaction.new(
            txBody,
            TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes())
        )

        // transaction witness / sign:
        let txVkeyWitnesses = await this.API.signTx(Buffer.from(tx.to_bytes(), "utf8").toString("hex"), true);
        console.log("txVkeyWitnesses:" + txVkeyWitnesses)
        txVkeyWitnesses = TransactionWitnessSet.from_bytes(Buffer.from(txVkeyWitnesses, "hex"));
        transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());

        const signedTx = Transaction.new(
            tx.body(),
            transactionWitnessSet
        );

        // submit TX:
        const submittedTxHash = await this.API.submitTx(Buffer.from(signedTx.to_bytes(), "utf8").toString("hex"));
        console.log("Submitted TX Hash:" + submittedTxHash)
        this.setState({submittedTxHash});

}

Error:
Uncaught (in promise) Error: submit tx failed: Error: 400:
0: {"requiredFee":171177,"actualFee":166953}

When you initialized the CSL you should  enter the protocol parameters.
That is the first place I would be looking at.

const txBuilderCfg = CardanoWasm.TransactionBuilderConfigBuilder.new()
.fee_algo(linearFee)
.pool_deposit(CardanoWasm.BigNum.from_str('500000000'))
.key_deposit(CardanoWasm.BigNum.from_str('2000000'))
.max_value_size(4000)
.max_tx_size(8000)
.coins_per_utxo_word(CardanoWasm.BigNum.from_str('34482'))
.build();

Also fee structures changed with the Vasil hard-fork. So if you have not updated your CLS to the latest version it will probably not calculate the fees corectly.

Hi Leo, thanks for the input. That is also what i thought, however other transactions  calculate fee correctly.  I have the parameters:
    this.protocolParams = {
        linearFee: {
            minFeeA: "44",
            minFeeB: "155381",
        },
        minUtxo: "34482",
        poolDeposit: "500000000",
        keyDeposit: "2000000",
        maxValSize: 5000,
        maxTxSize: 16384,
        priceMem: 0.0577,
        priceStep: 0.0000721,
        coinsPerUtxoWord: "34482",
    }

I encountered this same issue:
Fee too small required vs actual.
I sent the available ADA in the wallet to itself....i.e. an 'internal' transfer?
After doing that, the fee too small error did not occur.
I suspect it has something to do with how there was not enough ADA in any one utxo that was selected for use in the tx - but I ma not sure.
Doing that consolidated the available ADA into a single utxo though, and that was what allowed me to get past the "fee too small" error.


text:
What's the difference between sidechains and hardforks?
What are the pros and cons of creating a new sidechain versus hardforking Cardano if making a variant is desired?
Does a sidechain have the same inherent security and as the mainchain thru stake pools? Forked tokens versus new sidechain tokens?
Example: If in the future Cardano Voltaire Governance Era, a tradeoff is made to decentralization, the reward equation, or new research is introduced, etc, a a party wants to create a new Cardano variant. Should the party decide to create a sidechain, or hardfork Cardano? Are they the same thing? What should be considered?

Sidechains and hardforks are definitely not the same thing.
As outlined in the original Why Cardano essay, the whole point of Layer 1 Cardano is to serve as a settlement layer for domain-specific computation performed by a collection of Layer 2 "sidechains". The explicit bifurcation of one settlement layer and many execution layers allows for much of the heavy computation to be spread out with domain-specificity.
The extent to which a sidechain inherits Cardano's security depends on how frequently and tightly they interact. Although there may be overlap, sidechains can and will have their own accounting models, consensus mechanisms, validator sets, e.t.c. Their "security" will depend on which of the many trade offs they've made.
So, the decision of whether to sidechain or hardfork depends on what you are trying to achieve. Are you trying to deploy some killer new execution/consensus/dApp engine? A privacy chain? Do you want smooth interoperability with everyone else's new chain? Go sidechain.
Or, do you want to make such radical changes to the settlement layer of all this infrastructure that the HFC and voltaire-era governance procedures are not enough? Then hardfork. (This is unlikely to be viable).

A sidechain is simply an alternate/secondary chain that shares a two-way link/peg with another chain that is the primary chain (frankly primary/secondary are philosophical roles that are interchangeable per case), to exchange messages and assets.
With that said, creating a variant of Cardano via a fork of the canonical chain from a point or a whole new chain/genesis block from the original codebase (with changes), doesn't automatically make that variant a sidechain of Cardano or inherit the security of the original Cardano network.
This is because
A) bridge and relevant cross-chain protocols need to be deployed for interoperability as a sidechain.
B)security on the canonical chain is weighted in ADA stake which is tied to real world value and largely recognised by global actors. The variant will simply have a bunch of ADA tokens that do not in anyway reflect value of ADA from the canonical network. It will also lack the integrations and network effect of users and SPOs to solidify its place.
So a Sidechain is not a forked chain by default, and vice versa, but arrangements can be made to make a forked chain become a sidechain.
P.S. The whole point of Sidechains, starting from Bitcoin was about building alternate networks that communicated with the original network but had the flexibility to make/follow its own custom rules. This is the idea for sidechains on Cardano, where parties can build their own sidechains with their own rules should they feel misaligned for some reason or experimental.


text:
I'd like to get assets from the wallet using blockfrost, but some errors occur

export const callApi = async (endPoint: string) => {
try {
const request: string = env.REACT_APP_BLOCKFROST_URL + endPoint
const response = await fetch(request, {
//@ts-ignore
headers: {
"Content-Type": "application/json",
project_id: process.env.REACT_APP_BLOCKFROST_KEY,
},
method: "GET",
})
let data = await response.json()
return data
} catch (error) {}
}
export const findAssets = async (stakeAddress: string) => {
const endPoint = accounts/${stakeAddress}/addresses/assets
const result = await callApi(endPoint)
return result
}

As you can see in the error message, the address you provide is not in the expected format.
Addresses on testnets start with "addr_test1" but the address you provide starts with "addr1" (probably a mainnet address).
Try to add a testnet address to the request and it should work.
Example testnet address: addr_test1qpmtp5t0t5y6cqkaz7rfsyrx7mld77kpvksgkwm0p7en7qum7a589n30e80tclzrrnj8qr4qvzj6al0vpgtnmrkkksnqd8upj0
Also note that you probably want to use the PreProd network instead of the testnet. Testnet has been broken a while ago.

Thanks for your great answer!

You're welcome. I see you're new here. If this has answered your question, you can mark the answer as accepted.

As mentioned in the error message, you're using invalid (mainnet) address against testnet endpoint


text:
What are Leader VRF and Block VRF values on Pooltool?
During slot battles or height battles between stake pools, the realtime chain tip on Pooltool displays (B) and (L) for the pool that has a lower "Block" and "Leader" VRF value, respectively. Here is an example of one such instance (height battle).
My question is twofold:

What are Block and Leader VRF values?
How do they relate to the winners/losers of slot battles and/or height battles?

My crude understanding is:
What is a VFR?

"A Verifiable Random Function (VRF) [MRV99] is the public-key version
of a keyed cryptographic hash.  Only the holder of the private VRF
key can compute the hash, but anyone with corresponding public key
can verify the correctness of the hash." Ref 1

What are Block and Leader VRF values?

In the Leader Log, assigned blocks are chosen by their VRF values or score. The
pools with the lowest VFR wins (Andrew Westberg described it as, who
can do the lowest Limbo).

How do they relate to the winners/losers of slot battles and/or height battles?

In the case of slot or height battles, the pool with the lowest VRF
wins. It use to be the case that small pools had a slight advantage
for slot/height battles. In the Vasil upgrade (Praos), that is no
longer the case Ref 2

The source of truth is the Shelley Ledger Spec.


text:
Which address types are allowed for collateral inputs
Collateral inputs are required to be added to a transaction when any Plutus script is executed within that tx (i.e. spending a Plutus address utxo or minting a Plutus policy asset).
Obvious that a collateral input cannot be from a Plutus script address, as spending them would require for the script to be executed, which then would require a different collateral to be used, in case the script fails.
But what address types are allowed for collateral inputs at all? Is it only general vkey addresses or Native script addresses are allowed as well (since they themselves don't require collateral to be spent)?

The payment credential for any address in a collateral input must be a vkey credential (so not even native script).
You can see this check in the feesOK function in Figure 2 of the Babbage spec. Or here in the implementation.

Thank you, Jared!


text:
Is there full list of Ouroboros mini-protocols that the node supports (preferably official and kept up to date)?
A paper from 2019 I found that describes mini-protocols: https://hydra.iohk.io/build/1070091/download/1/network.pdf. Have more protocols been added?

The network specs used for creation of that document (updated version from 2019) lives in ouroboros-network repository, and you can find the latest CI build of the document here

Following from the github repo, the main technical overview is in the "The Shelley Networking Protocol" pdf here: https://hydra.iohk.io/build/20405228/download/2/network-spec.pdf#chapter.3, and a lighter overview in the Cardano documentation here https://docs.cardano.org/explore-cardano/cardano-network/networking-protocol (need to scroll down, couldn't link to appropriate subsection)

Documentation link is dead.

It's here now https://input-output-hk.github.io/ouroboros-network/pdfs/network-spec/network-spec.pdf


text:
How to properly start a new Plutus project, from scratch
I'm from ETH's ecosystem and recently just decided to get into Cardano development, specifically Plutus dev work thanks to Demeter.Run, and after going through the Plutus starters on there, I noticed there weren't any guides on how to start a fresh project from scratch. I did a speedrun through the latest iteration of the Plutus Pioneer course and found out that most of the work was either done in the Playground, the Repl, or built from the top of an existing project(which still doesn't add up to me).
Tried moving some sample .hs code from Plutus-apps and Alonzo-testnet repos hoping to compile and submit them for my own experience and only ended up fighting with GHC and Cabal errors because the sample code used other dependencies and structures different from the secondhand project I was guided to build on top of.
I don't want to start a project by piggybacking on some already existing files and .cabal and .project configs with specs I don't know/understand.
If I was starting a NodeJs project I'd begin with npm init then go from there
My question is, how can I start a new Plutus project from scratch such that I know

how to setup my .cabal file dependencies
how to setup what's needed for the .project file
where to input my fresh code (or borrowed code from Plutus-apps samples to test) because there's the "main.hs" in the app folder which I learned from Haskell but Plutus samples put their .hs code files in the "src" folder, the "main.hs" in the app folder contains something completely different.
how to compile my .hs to .plutus

Everything that comes after these 4 steps i.e. submitting that new .plutus file to the chain (serialised) and building Tx's I know how to do.
I am using Demeter.Run and working from the Terminal and Cardano-CLI from the workspaces, I am under the impression every dependency from IOHK/IOG is setup. I don't know nix and the plutus starter samples didn't need that so hope to progress that way.
I have very minimal Haskell but learning the basics hasn't been tough but I'm good with front-end Javascript and some Solidity.
Please be as detailed/technical as you like, thank you.
Note: I went through the previous questions posed in the links below but still did not get it.
Starting a new Plutus Project
How to Start a New Project

This is a great question. It would be great if there is a guide that show every step from zero to a working dapp on testnet. Plutus Pioneer Program doesn't provide the complete picture. Plutus Playground doesn't compile most of the time. I previously thought it's just me.

A well formatted question deserves a well formatted answer! I will go into some depths, but also keep some things at a “magical” level. This is a long read so take your time!
Before we start, it is good to note that most of the Cardano stack is written in Haskell, and thus, managing a Plutus project is just managing a Haskell project. There are multiple ways of doing this, just a plain Cabal project or one of the many Nix ways of building (cabal2nix, Haskell.nix and many others). Now there are good reason to use these Nixs ways (most notably reproducibility and caching), but in this answer I will focus on a more understandable way of just using GHC + cabal on Ubuntu 22.04 (not the minimal install).
A disclaimer, building everything yourself requires lots of ram (you can also re-run the cabal run command if you run out of memory mid-process). The good thing, however, once build you have these Haskell artifact locally prebuilt in your ~/.cabal/ folder.
The dependencies
Before we can even build a general all-purpose Haskell/plutus project, we need some basic building tools necessary to even start compiling! These mainly consist of the following tools,

OS dependent dependencies
GHC and Cabal
A special version of libsodium
A special version of libsecp256k1

OS dependent dependencies
To build everything, you at least need these dependencies
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 curl libtool postgresql libpq-dev autoconf -y

Note that translating these OS dependent dependencies to other operating systems is hard and out of the scope of this post (this is why you might want nix). They may also change in the future as the project might add new dependencies.
GHC and Cabal
It is recommended by IOG to use GHC version 8.10.7 and Cabal version 3.6.2.0. These can be installed via GHCUP via,
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

You can press enter for all question the installer asks. Then reload your terminal (to make ghcup appear in your path) and,
ghcup install ghc 8.10.7
ghcup set ghc 8.10.7
ghcup install cabal 3.6.2.0
ghcup set cabal 3.6.2.0

Reload your terminal again to make these appear in your path and set
cabal configure --with-compiler=ghc-8.10.7

A special version of libsodium
Libsodium is a tool chain (written for performance) for cryptographic derivatives, for example you can create signatures and hashes with it. We require a particular version of it that adds VRF cryptography to it (used for the Cardano consensus mechanism). Installing this can be done via,
git clone https://github.com/input-output-hk/libsodium
cd libsodium
git checkout 66f017f1
./autogen.sh
./configure
make
sudo make install

In addition to this add the following to your ~/.bashrc and reload your terminal again to add it to your path
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

A special version of libsecp256k1
Since the Vasil hard fork Cardano has the secp256K1 signature scheme available in plutus. This allows for the validation of Bitcoin signatures and will make it easier to build bridges. Bitcoin is not the only blockchain that use this signature scheme, many others do. So to install this library (again a particular audited version) you use,
git clone https://github.com/bitcoin-core/secp256k1
cd secp256k1
git checkout ac83be33
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install

A preconfigure project
We are ready to build a Plutus project! Before I tell how you can set up such a project, I want to share an already set up example. This so that you can test that you correctly installed the dependencies above. To run this example you use
git clone https://github.com/perturbing/example-project-basic.git
cd example-project-basic
cabal update
cabal run

I would like to reiterate, if you do not have sufficient ram available, for example because you run this example in a VM, you can cabal run again if your memory overflows. This example ran for me in a vm with 10gb ram.
Now how is this project setup?
This project and its structure is not constructed arbitrarily. It is namely derived from the latest release of the plutus-apps repository. This repository and its management of dependencies is chosen because it imports and exposes almost all important Haskell packages written for Cardano.
Now, how to concretely set up and copy the essential bits of this repo? It consists of the following steps.
To start we execute
mkdir my-plutus-project
cd my-plutus-project
cabal init
touch cabal.project

You could also use the flag --interactive for a more detailed set up with cabal init.
Next, we copy the cabal.project file of plutus-apps from its latest release (do not pick the main branch, consider this is unstable). Currently, the latest version of this file is this. Next, we need to adjust some pieces of this file to make it work for us.
The first thing to change, this cabal.project file does not import the plutus-apps repo (since it was part of the original one). So, we need to add that by changing the code that declared the to build packages of the plutus-apps repo. It also does not declare our new build artifacts of our cabal project, we have to change the exposed packages it has to build. Both can be achieved by changing,
packages: cardano-streaming
          doc
          freer-extras
          marconi
          marconi-mamba
          playground-common
          pab-blockfrost
          plutus-chain-index
          plutus-chain-index-core
          plutus-contract
          plutus-contract-certification
          plutus-example
          plutus-ledger
          plutus-ledger-constraints
          plutus-pab
          plutus-pab-executables
          plutus-script-utils
          plutus-tx-constraints
          plutus-use-cases
          rewindable-index

to
packages: ./

source-repository-package
    type: git
    location: https://github.com/input-output-hk/plutus-apps
    tag: the_latest_release_tag_used_here_CHANGE_ME!!!
    subdir:
          cardano-streaming
          doc
          freer-extras
          marconi
          marconi-mamba
          playground-common
          pab-blockfrost
          plutus-chain-index
          plutus-chain-index-core
          plutus-contract
          plutus-contract-certification
          plutus-example
          plutus-ledger
          plutus-ledger-constraints
          plutus-pab
          plutus-pab-executables
          plutus-script-utils
          plutus-tx-constraints
          plutus-use-cases
          rewindable-index

Next up, we can add to our executables and/or libraries on which modules they depend. For example, we might add to our my-plutus-project.cabal file that the executable depends on
    build-depends:    base ^>=4.14.3.0
                    , aeson
                    , bytestring
                    , containers
                    , cardano-api
                    , data-default
                    , plutus-ledger
                    , plutus-ledger-api
                    , plutus-ledger-constraints
                    , plutus-script-utils
                    , plutus-tx-plugin
                    , plutus-tx
                    , text
                    , serialise

And lastly, we can write our app/Main.hs file to execute some functions for us. A simple cabal update and a cabal run will execute your Main.hs executable.
Some last words
This is a long answer, and in no way is complete. I advise anyone who is eager to learn more about Haskell to take the Haskell course from IOG (it also covers cabal!). I hope this gets you started!

Since this question was posted Plutus-alternatives have been developed by the community that allow doing DApp development in JavaScript only. One such library is https://github.com/hyperion-bt/Helios
https://www.hyperion-bt.org/Helios-Book/api/picoswap/index.html is a step-by-step guide on how to implement a simple marketplace. The example code can be found here, and a demo is hosted here

Helios seems very interesting, although my confidence in the project decline the second I saw they chose to build Helios in JavaScript.

There isn't really an alternative for javascript if you want to build pure client-side DApps

The fact that the Helios compiler uses javascript to compile to plutus untyped core is a huge advantage and allows for the dynamic compiling to plutus core on any architecture that supports javascript  (browser, mobile devices, etc).   The helios language itself is a functional programming language, so you get all the benefits of a strongly typed functional programming language for writing your smart contracts, but you can compile it almost anywhere.

doesn't answer the question

People who are struggling with Plutus should know there are easier alternatives

You can start with cloning https://github.com/input-output-hk/plutus-starter
and follow the readme in that repo


text:
What are the values in a Transaction Datum?
Below is a link for the "inspect" window on Cardanoscan.
What are the values in the json?
(Example: 2486ff67c9772a45ed705adc7266c62ce8e2ad2e61c2656606ba966f)
https://cardanoscan.io/datumInspector?datum=d8799f581c2486ff67c9772a45ed705adc7266c62ce8e2ad2e61c2656606ba966f9fd8799fd8799fd8799f581c4b031cbfd476d7efd6ec84012aeaa11a5ec9aa4ce53973764f5099bfffd8799fd8799fd8799f581ce1f33ea56cbc61dc3f9159175025efab8e55d92380482b4760360038ffffffffa140d8799f00a1401a02ebae40ffffd8799fd8799fd8799f581c70e60f3b5ea7153e0acc7a803e4401d44b8ed1bae1c7baaad1a62a72ffd8799fd8799fd8799f581c1e78aae7c90cc36d624f7b3bb6d86b52696dc84e490f343eba89005fffffffffa140d8799f00a1401a00d59f80ffffd8799fd8799fd8799f581c2486ff67c9772a45ed705adc7266c62ce8e2ad2e61c2656606ba966fffd8799fd8799fd8799f581cff0b7b5daf9200ff5881de87ab95e4e891725051f4b252ef468e3816ffffffffa140d8799f00a1401a25f7d940ffffffff

A guess:
The first set bytes (2486...) is the payment_cred key hash (pkh).
The second and third set bytes is a Cardano address that has been split.
The forth and fifth is also a Cardano address that has been split.

payment_cred is certainly part of it, and the addresses involved in the use of the outputs are indeed in there too it seems - I have finally begun to understand what I am looking at in there and how to decipher it. Thank you for responding.


text:
convert hex encoded bytes string to something readable
I'm using nami wallet's api, and if I call cardano.getUsedAddresses() it return a "hex encoded bytes string" and I would like to  know how I can convert that to something readable

First, getUsedAddresses() returns a list of all used (included in some on-chain transaction) addresses controlled by the wallet1.
To decode, can use decodeHexAddress on getUsedAddresses() elements.

1 https://cips.cardano.org/cips/cip30/#apigetusedaddressespaginatepaginateundefinedpromiseaddress

that file is written in typescript. I have used javascript. should I switch to typescript?

Entirely up to you. You can import this function inside your JS project, like so: import { decodeHexAddress } from '@cardano-foundation/cardano-connect-with-wallet'.


text:
Cardano Node 1.35.4 problems
I am running cardano node 1.35.4 on Windows 10 it syncs to 100% then gives me the following screen

If you are asking about Unsupported remote target address ... errors (ipv6), then I suspect that you start the node only specifying IPv4 address.  To get IPv6 address either:

do not specify ip addresses at all (then the node should discover which addresses the host machine supports); or
specify both IPv4 and IPv6

If you just specify one of them, the node will only bind to that address, and be able to use outbound connections using that IP version.  This allows us to support environments where IPv4 or IPv6 is not available.

Thanks for your help , I am currently not specifying any IP address
cardano-node run --topology "configuration\cardano\testnet-topology.json" --database-path "db" --socket-path "\.\pipe\cardano-node-testnet" --port 3001 --config "configuration\cardano\testnet-config.json"


text:
Cardano-Wallet register a wallet generated by Cardano-cli
I created a Wallet with Cardano-Cli following this instructions:
cardano-cli address key-gen   --verification-key-file vkf.payment --signing-key-file  skf.payment

After that I derived the address of that wallet
What I need to do now is to register this wallet on the Cardano-Wallet server, to feed the PA>B. But the Cardano-Wallet-Server requires a pub key hash or a nemonic phrase wallet recovery, to generate the WALLET_ID.
But the cardano-cli offers none of them.
Does anyone knows how to move from payment verification and signing keys to a public address or a mnemonic phrase useful to register my wallet on Cardano-Wallet-Server?
Thanks in advance.

Does anyone knows how to move from payment verification and signing
keys to a public address or a mnemonic phrase useful to register my
wallet on Cardano-Wallet-Server?

I think you're not able to make that kind of derivation since we are dealing with addr.xsk (from derivation path root.xsk -> acct.xsk -> addr.xsk). And wallet needs to know about root and acct keys.
You can however use cardano-addresses to create all those keys and generate address with them, and then use cardano-cli key convert-cardano-address-key to convert them into format that is readable by cardano-cli if you wish:

Generate mnemonics

$ cardano-address recovery-phrase generate --size 24 > mnemonics.txt

Using these mnemonics you can already restore the wallet on cardano-wallet server.

Create root.xsk

$ cardano-address key from-recovery-phrase Shelley < mnemonics.txt > root.xsk

(BTW, at this point you can already figure out what will be wallet id)
$ cardano-address key walletid < root.xsk

Derive addr.xsk and stake.xsk

$ cardano-address key child 1852H/1815H/0H/0/0 < root.xsk > addr.xsk
$ cardano-address key child 1852H/1815H/0H/2/0 < root.xsk > stake.xsk

Generate public/verification keys:

$ cardano-address key public --without-chain-code < addr.xsk > payment.vkey
$ cardano-address key public --without-chain-code < stake.xsk > stake.vkey

Generate wallet address:

$ cardano-address address payment --network-tag preprod < payment.vkey \
  | cardano-address address delegation $(cat stake.vkey) > payment.addr

addr.xsk -> 1852H/1815H/0H/0/0, so this is going to be first address on the wallet, next in the sequence would be 1852H/1815H/0H/0/1 etc. (stake.xsk stays the same)
The address can be also generated with cardano-cli:
cardano-cli address build \
 --payment-verification-key-file payment.vkey \
 --stake-verification-key-file stake.vkey \
 --out-file paymentCli.addr \
 --testnet-magic 1 # preprod

You'll notice that payment.addr == paymentCli.addr.

Now, if you'd like to spend from the address also with cardano-cli:

Convert xsk:
$ cardano-cli key convert-cardano-address-key --shelley-payment-key --signing-key-file addr.xsk --out-file payment.skey
$ cardano-cli key convert-cardano-address-key --shelley-payment-key --signing-key-file stake.xsk --out-file stake.skey

Now, you can spend the address using cardano-cli (with payment.skey or stake.skey), e.g.:
$ cardano-cli query utxo --address $(cat payment.addr) --testnet-magic 1

$ cardano-cli query protocol-parameters \
   --testnet-magic 1 \
   --out-file protocol.json

$ cardano-cli transaction build  \
    --babbage-era  \
    --testnet-magic 1 \
    --tx-in "3f546b8d958d65b9e0f93030ac4afdc95b92c0dfdadaad1a063bf7024ee0378d#0"  \
    --tx-out "addr_test1qzfdywms54mk9hclupc3yhu8yev6w92swndcaewvxx53ux0vwaztjw0fjsgfmvdqtq3tn4df0ja9tgvxmmapehnmjcxq8u7f98+1000000" \
     --change-address $(cat payment.addr) \
--protocol-params-file protocol.json  \
--out-file body.tx

$ cardano-cli transaction sign \
   --tx-body-file body.tx \
   --testnet-magic 2 \
   --signing-key-file payment.skey \
   --out-file signed.tx

$ cardano-cli transaction submit --tx-file signed.tx --testnet-magic 1


text:
"You may need an additional loader to handle the result of these loaders."
I'd like to import Mercury module, but some errors occur.
I can't confirm this reason on react version or other things.
Can I solve this error using current react version? If It's impossible, other solution?
Thank you in advance.
"dependencies": {
    "@mercury-chat/react-chat": "^0.1.3",
    "@types/react": "^17.0.13",
    "@types/react-dom": "^17.0.8",
    "@types/react-router": "^5.1.16",
    "@types/react-router-dom": "^5.1.8",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.0",
    "typescript": "~4.0.5",
     ...
 },

import React from 'react';
import { MercuryChat } from '@mercury-chat/react-chat';
const App = () => {
  return (
    <div>
      <MercuryChat />
    </div>
  );
};
export default App;

Failed to compile.
./node_modules/@mercury-chat/react-chat/dist/index.js 509:5
Module parse failed: Unexpected token (509:5)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| //---------------------------------------------------------------------------//
| class EmbeddedWalletAPI {
>   api;
|   wallet;
|   //---------------------------------------------------------------------------//


text:
Get Delegations in Cardano
I am going to get delegations list for specific pool, epoch.
https://docs.blockfrost.io/#tag/Cardano-Epochs/paths/~1epochs~1{number}~1stakes~1{pool_id}/get
I found blockfrost api and tested.
My test pool: ac66c8efb8edba3991576235e421ef0524ab351a22598de520de7b16, Epoch: 378
I got 9 delegations from blockfrost api.
[
    {
        "stake_address": "stake1uyyp9ydgm834vnhhv0wd9sd9xlxwsmcv37xs6uw0f66626scn5v6z",
        "amount": "3326619748"
    },
    {
        "stake_address": "stake1uy8vrh3a8ujzqanlw2r3rf23lc6uelnd390lanxwulsdhqqudsl8m",
        "amount": "116381727"
    },
    {
        "stake_address": "stake1uyjv3s932h8ar2zudw6q30h65kn76g00v0z7kmz2td5cgdsx5dl7r",
        "amount": "1024314243"
    },
    {
        "stake_address": "stake1uy4kl6dyg3hegqapvx53y6lazgx3z79g4p2ds4rc80lcvuc4j9v4h",
        "amount": "7062695853"
    },
    {
        "stake_address": "stake1u927nhw76vzpmtufuc5fa4nj74tkw9mhugqrqdz9hklw9hctcfv4y",
        "amount": "15260602"
    },
    {
        "stake_address": "stake1ux3rkq6grckauj72qyfm9mcs8y49phzrm9el00rzdh6n3kcnnspzy",
        "amount": "771665304"
    },
    {
        "stake_address": "stake1u820d54llavvwctmuvr6gugytlqlglp4slyy30vl4w43wag6dn4ya",
        "amount": "0"
    },
    {
        "stake_address": "stake1u84euhe0va89n55t02y4xdydtpd0gau48e73wahhmuplj4chr87cv",
        "amount": "169480944"
    },
    {
        "stake_address": "stake1u8aa3nq3vf98jw36977lu6s09pa2xtfr3v65sagl7nywhys5jxvfa",
        "amount": "226565423"
    }
]

If I check by cardanoscan.io explorer, I can see 12 delegators.
https://cardanoscan.io/pool/ac66c8efb8edba3991576235e421ef0524ab351a22598de520de7b16?tab=delegators
I think I should get 12 delegations from api, but I got 9 delegations.
Could anyone help me to get exact delegations?

You are looking at a number of delegators for the active epoch (therefore the state of delegators two epochs ago) and cardanoscan is showing you the live delegations, which are two different things.
To get the current list of delegators, you need to use the /pools/delegators endpoint:
$ curl -s  -H "project_id: ..." "https://cardano-mainnet.blockfrost.io/api/v0/pools/ac66c8efb8edba3991576235e421ef0524ab351a22598de520de7b16/delegators" \
   | jq .[].address \
   | wc -l
12

Thank you for your answer. 378 is current epoch. Could you explain why it is two epochs ago?

When you're talking about delegation against an epoch, you're expected to be looking at active stake of delegators for said epoch (as that's what you're getting blocks assigned for, and rewarded accordingly), not live stake/delegators


text:
cardano-submit-api install error
I'm trying to install cardano-submit-api on my linux node following IOhk documentation:
cardano-node $ cabal install cardano-submit-api --overwrite-policy=always
but I have an error:
...
Got NamedPackage ouroboros-consensus-cardano-tools
CallStack (from HasCallStack):
error, called at src/Distribution/Client/CmdInstall.hs:474:33 in main:Distribution.Client.CmdInstall
Can anybody help me please? I cannot find any solution :(
Many thanks in advance!
Jaialai

What git tag/branch are you using? Starting with 1.35.4, they moved a lot of compilation to CHaP, but for 1.35.4 tag in particular - the cabal install was broken, was fixed on master since. But you should still be able to use build commands for submit-api, and then copy the generated binary to your $PATH

Thanks for your response, yes I'm trying with 1.35.4 version. Finally what I did is take the binary for submit-api directly (compiled for someone who knows more than me :) and it works perfectly. I found it in Armada Alliance Team.
Best regards.


text:
How can I interact with smart contract created from Marlowe in the testnet/mainnet?
I create a smart contract with Marlowe from https://play.marlowe-finance.io
I now want to deploy the contract in the preview testnet and later mainnet. I imagine it must be somehow converted into plutus script. And then use the plutus script to create transaction via cardano-cli.
Is there a way to convert Marlowe into plutus script?
If not, how can I interact with smart contract created from Marlowe in the testnet/mainnet?

Here are four methods for running Marlowe on the blockchain, in increasing order of difficulty:

If you want to run your contract at the command line using marlowe-cli, install marlowe-cli and follow the instructions in the tutorial for running contracts with marlowe-cli. Here is a video lecture that provides an overview of marlowe-cli.
If you want to run your contract in a Jupyter notebook, then use git to clone github.com/input-output-hk/marlowe-cardano, run nix develop --command jupyter-lab from the marlowe-cli/ folder, open the notebook marlowe-cli/lectures/04-marlowe-cli-concrete.ipynb, and follow the instructions. Here is a video lecture of running a contract from within a Jupyter notebook.
If you want to run your contract from the command-line using the Marlowe Runtime backend, then follow the tutorial for Marlowe Runtime. Here is a video demonstration.
If you want to run your contract using Marlowe Lambda, follow the example for using Marlowe Lambda from the command line or study the example web application for Marlowe Lambda. Here is video of a command-line example and here is a video of a web app example.

Is there a way to convert Marlowe into plutus script? If not, how can I interact with smart contract created from Marlowe in the testnet/mainnet?

Marlowe contracts are run as datum in the Marlowe validator, which is a Plutus script that can run any Marlowe contract. There is no need (or possibility) of converting a Marlowe contract directly to Plutus.
Also, mainnet is disabled in the Marlowe tools, but you can alter the source code here and/or here to enable mainnet if you want to run there. Note that Marlowe's audit is not complete, so it is not advisable to run on mainnet.

Damn! you're good

Just realize you're the guy in the video, the creator himself. Good job, man.

Here are some more example Marlowe contracts: https://github.com/input-output-hk/real-world-marlowe#gallery-of-marlowe-contracts-on-cardano-mainnet.