text:
Cardano-cli Handshake error after Daedalus update
After updating Daedalus for the Vasil hardfork, I get the below error when running this cardano-cli command
cardano-cli get-tip --testnet-magic 1097911063

cardano-cli: HandshakeError (VersionMismatch [NodeToClientV_9,NodeToClientV_10,NodeToClientV_11] [12,13])

My cardano-cli is still version 1.33.0 but I have already updated Daedalus. Is there anything I need to do on my part after updating Daedalus?

My cardano-cli is still version 1.33.0 but I have already updated Daedalus.

That is the problem right there. I suspect the node that is started by Daedalus is either 1.35.0 or 1.35.1 (ie these releases support the Vasil HF). The cardano-cli version needs to match.

You need to use Daedalus version >= v4.12.0 , the download links can be found here.
In case you see older version, clear the browser cache or open the page in Incognito mode.


text:
How does db-sync query raw block data if cardano-node doesn't expose them?
I was trying to find a way to get raw block/transaction data and came across this question. The answer was that there is no way to do that currently but db-sync somehow does that. How does it do that? More specifically I was looking for some sort of documentation on how to do that myself (an API reference with the protocol specified).

The answer to that other question is only partly correct ie the node does make this data available, but not in an easy to digest manner.
The node does expose a local chain sync protocol. However this local chain sync protocol is written in Haskell and uses CBOR encoded data. It is theoretically possible to write code in another language that connects to this local chain sync protocol (I think there is Rust code somewhere to do this).
The local chain sync protocol only supports on-chain data. Data that is part of ledger state like epoch rewards and epoch stake distribution are not included.

Looking more into the chain-sync protocol, ogmios wraps it in a websocket API, so I think that's exactly what I am looking for, thanks!

source: Stack Exchange

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

sort: votes


text:
How Can I Collect Pool Operator Submit APIs?
Submit apis are possible given the current state of the chain, however, where can I go to verify that a submit API is genuine? The ideal solution would be a way to check stake pools for the API that can be automated.

Sorry, what do you mean by "submit API"? Do you mean the transaction submission API? If so. I can't think of any way to verify that they are genuine. Worst case, for a non-genuine one, is that your transaction will not be submitted. The person running the transaction submission API cannot steal your funds because they do not have the private key that signed the transaction.

Unfortunately, there's no such way to do that.
Anyone running cardano-node can also run cardano-submit-api and expose it for you to send transactions. This means that not only SPOs can do it, so I guess it is not possible to verify if the service is legit or not.

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


text:
How can I determine which smart contracts / script addresses are associated with which dApps?
I have seen numerous examples of blockchain explorers providing information about the on chain activity of specific dApps. For example:

opencnft.io aggregates data about various token marketplaces
cexplorer.io has a list of the most active contracts and their associated dApps
eutxo.org provides information on transactions associated with a specific dApp

How do all of these sites map smart contracts / script addresses to a specific dApp? Do they manually determine which smart contracts a dApp is using or is this info listed somewhere?

I could not even begin to guess how they are doing this. Instead I suggest you ask the people working on those sites.

One way of determining it is to interact with such a dApp and follow the money.

Do they manually determine which smart contracts a dApp is using or is this info listed somewhere?

Yes, they manually gather the data of which script hash belongs to which dApp. This information is not registered anywhere on the blockchain or in any official central place.
There are many ways to gather this information, as suggested in the comments you could use the dApp yourself and check the resulting Tx or simply ask the developers.
If you want to build a new app you could of course also scrape the data from other existing sources like the websites you have listed above.


text:
Handling time & slots in cardano-node clients
At hydra we do have a protocol which ensures something is not happening before some given deadline. The system would need to submit a transaction to set the deadline (txA) and another transaction once this deadline passed txB. The deadline is determined from a txAs upper validity bound given as slot sA . Let's assume that deadline is at slot sT and our scripts will ensure that txBs lower validity bound sB is sB > sT.
How would should our application determine the "right time" to publish transaction txA and txB?
We would need to know about current time (in slots) to kick things off by determining sA and sT. But also to know when sB is to not have a failing txB. So far we have tried two approaches:

Use getLocalChainTip from cardano-api to get the slot of the current chain tip. This seems to be the slot of the last seen block and hence up to ~20 seconds in the past. Which is fine for txA, but problematic for txB as we would need to know that offset for correctly determining sB .
Use wallclockToSlot from ouroboros-consensus to get the current slot given wall clock. This gives us the projected, actual slot (even hard-fork and era history compatible?) so it's better in determining slots sA and sB. However, we get a ledger error when submitting txB as the ledger seems to think it's still slot of the last block (like option 1). For example: ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (OutsideValidityIntervalUTxO (ValidityInterval {invalidBefore = SJust (SlotNo 220), invalidHereafter = SNothing}) (SlotNo 211))))] when wall clock time and the cardano-node logs confirm was around slot 220 and the last block was forged at slot 211.

Any other options or ideas how to handle this in a properly integrated, non-hacky fashion?

What is the scale of difference in time between sA and sT?

Does this difference have bounds? Preferably, a lower one?

For this issue at hand here we can assume sT - sA to be sufficiently low, say 20 to 50 slots. (We have other problems of the period being too high and not being able to compute the POSIXTime equivalent as it's "past the horizon")


text:
Is there a Cardano VM?
Does Cardano have a virtual machine? Throughout crypto we hear a lot about EVM but have never heard any reference to a Cardano VM? Is there a need for a VM for Cardano or has the system been architected in away that eliminates the need?

Ethereum, Solana, and other blockchains that use an accounts-based ledger model can each be thought of as one big box of logical interdependencies, whose state is constantly changing, all replicated, maintained, and updated by many nodes. Keeping track of and executing all these interdependencies requires a "VM" - a sort of universe in which all these logical structures can live in context with one another. This allows for a high degree of flexibility and customizability, but also makes it difficult to model and prevent chaotic side effects.
Bitcoin, Cardano, and other blockchains that use a UTXO-based ledger model are different. Instead of thinking of the blockchain as one big box (as in the previous case), it is better to think of it as a collection, or a set, of many little boxes (a.k.a UTXOs). The whole UTXO set is replicated and constantly changing like any other blockchain, but there are no interdependencies between the UTXOs themselves. Instead, each UTXO contains just enough information it needs to only ever be spent exactly how the creator of the UTXO intended it. There is no notion of a shared "global state", and hence no need for a VM.

The "VM" aspect is not dependent on how state is managed or what transaction record models are implemented in a given blockchain stack (that's a bonus), but rather the approaches by which execution code is equipped to interface with hardware platforms. Case in point: Fuel uses the Fuel VM with a UTXO transaction recording model.
Languages like C and Haskell are able to interface well with native machines due to maturity in builds/compilers/libraries whereas Java for example requires the JRE (JVM + other components) as helpers to function, or in this case Solidity with the EVM.

My answer as shared under your twitter comment here
It's not necessary, Plutus is a subset of Haskell which has a mature library i.e. GHC (runtime env, toolchains, etc) and is able compile instructions directly to machine code.
It can still utilise one like WASM/LLVM for various needs.
TL;DR: The Cardano Node is the machine.

Plutus is not compiled directly to machine code, but to a defined language called Plutus Core. Plutus Core is an eagerly-evaluated version of the untyped lambda calculus extended with some “built-in” types and functions; it is intended for the implementation of validation scripts on the Cardano blockchain (from the plutus-core-specification document)


text:
Error when connectiong BP node and Relay
I am setting up a stake pool on mainnet after practicing on testnet for a while, but I can't get over this issue. BP is supposed to connect to my relay only, but I get the following:
BP:
[vmi92943:cardano.node.IpSubscription:Info:376] [2022-07-22 02:37:28.30 UTC] IPs: 0.0.0.0:0 [RelayIP:6000] Connection Attempt Start, destination RelayIP:6000
[vmi92943:cardano.node.IpSubscription:Error:376] [2022-07-22 02:37:31.36 UTC] IPs: 0.0.0.0:0 [RelayIP:6000] Connection Attempt Exception, destination RelayIP:6000 exception: Network.Socket.connect: <socket: 131>: does not exist (No route to host)
[vmi92943:cardano.node.ErrorPolicy:Notice:360] [2022-07-22 02:37:31.36 UTC] IP RelayIP:6000 ErrorPolicySuspendConsumer (Just (ConnectionExceptionTrace Network.Socket.connect: <socket: 131>: does not exist (No route to host))) 20s
[vmi92943:cardano.node.IpSubscription:Error:362] [2022-07-22 02:37:31.36 UTC] IPs: 0.0.0.0:0 [RelayIP:6000] Failed to start all required subscriptions

Relay:
[vmi92943:cardano.node.IpSubscription:Info:428] [2022-07-22 02:40:52.25 UTC] IPs: 0.0.0.0:0 [BPIP:6000] Skipping peer BPIP:6000
[vmi92943:cardano.node.IpSubscription:Error:428] [2022-07-22 02:40:52.25 UTC] IPs: 0.0.0.0:0 [BPIP:6000] Failed to start all required subscriptions
[vmi92943:cardano.node.IpSubscription:Info:428] [2022-07-22 02:40:53.25 UTC] IPs: 0.0.0.0:0 [BPIP:6000] Restarting Subscription after 1.004306329s desired valency 1 current valency 0

My topology seems to be fine:
BP:
{
  "Producers": [
    {
      "addr": "Relay ip",
      "port": 6000,
      "valency": 1
    }
  ]
}

Relay:
 {
    "Producers": [
      {
        "addr": "BP ip",
        "port": 6000,
        "valency": 1
      },
      {
        "addr": "relays-new.cardano-mainnet.iohk.io",
        "port": 3001,
        "valency": 2
      }
    ]
  }

Currently I have no firewall on both systems.
I can't figure out the source of this issue. Thanks in advance for your help.

Starting with the obvious, can you confirm that each node server can ping the other, and that each node is running on the expected port number. Then try netstat -tpan to see IPs, ports and processes - everything look as expected there (for the cardano node process)? Port 6000 is often used by X Windows - do you need to change it?

The nodes are running on Ubuntu, still, I changed the ports of bp and relay to 3002 and 3001, I am getting the same error as before. I runned  telnet relay/bp ip port and I get telnet: Unable to connect to remote host: No route to host in both machines.

I checked my ports at https://www.yougetsignal.com/tools/open-ports/ and both nodes show as open.

Let's hit these nodes one at a time - on your relay node can you see connections from other nodes? Use netstat -tpan as mentioned earlier to see IP, port and process. You should have other nodes connecting in and you will see their IP for the cardano-node process.

Also check your outbound firewall rules on each server to make sure it is not locked down for the IP+Port of the other server.

When running sudo ufw status numbered I get Status: inactive in both servers

That shows that ufw is not active/running - did you configure it fully or are you using some other firewall? Can you see other IPs connected to your relay server when using netstat -tpan - this is important to check so we get some idea about whether all connections are failing or only between your two servers.

My relay has an established connection with an iohk node, this connection shows correctly when running netstat -tpan I don't have any firewall running. I used sudo ufw --force disable at my very first steps in debugging this issue.

Ok that's good that you see a connection. Now check that the environment variable CARDANO_NODE_SOCKET_PATH is set correctly for the user/service that starts your nodes, and matches --socket-path in your start-up scripts. Use the absolute path to be sure. Do you start the nodes as a service or user script?

I start my nodes as a service. I just checked bashrc and my scripts and the path is correct.

Can you post your node .service file eg /etc/systemd/system/cardano-node.service so we can see more details (block IP/port as needed). It sounds like a path to socket mismatch, often due to use of $HOME to ~ so using the absolute path can help.

BP:
[Unit]
Description     = Cardano node service
Wants           = network-online.target
After           = network-online.target
[Service]
User            = cardanobp
Type            = simple
WorkingDirectory= /home/cardanobp/node
ExecStart       = /bin/bash -c '/home/cardanobp/node/startBlockProducingNode.sh'
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=300
LimitNOFILE=32768
Restart=always
RestartSec=5
SyslogIdentifier=cardano-node
[Install]
WantedBy= multi-user.target

Relay:
[Unit]
Description     = Cardano node service
Wants           = network-online.target
After           = network-online.target
[Service]
User            = cardanobp
Type            = simple
WorkingDirectory= /home/cardanobp/node
ExecStart       = /bin/bash -c '/home/cardanobp/node/startBlockProducingNode.sh'
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=300
LimitNOFILE=32768
Restart=always
RestartSec=5
SyslogIdentifier=cardano-node
[Install]
WantedBy= multi-user.target

BP script: #!/bin/bash
DIRECTORY=/home/cardanobp/node
PORT=3002
HOSTADDR=0.0.0.0
TOPOLOGY=${DIRECTORY}/mainnet-topology.json
DB_PATH=${DIRECTORY}/db
SOCKET_PATH=${DIRECTORY}/db/socket
CONFIG=${DIRECTORY}/mainnet-config.json
/home/cardanobp/.local/bin/cardano-node run +RTS -N -A16m -qg -qb -RTS --topology ${TOPOLOGY} --database-path ${DB_PATH} --socket-path ${SOCKET_PATH} --host-addr ${HOSTADDR} --port ${PORT} --config ${CONFIG}

Relay script:#!/bin/bash
DIRECTORY=/home/cardano/node
PORT=3001
HOSTADDR=0.0.0.0
TOPOLOGY=${DIRECTORY}/mainnet-topology.json
DB_PATH=${DIRECTORY}/db
SOCKET_PATH=${DIRECTORY}/db/socket
CONFIG=${DIRECTORY}/mainnet-config.json
/home/cardano/.local/bin/cardano-node run +RTS -N -A16m -qg -qb -RTS --topology ${TOPOLOGY} --database-path ${DB_PATH} --socket-path ${SOCKET_PATH} --host-addr ${HOSTADDR} --port ${PORT} --config ${CONFIG}

A couple of things I noticed 1) Your relay service refs cardanobp (in 3 spots) but relay script refs cardano - was that a bad copy/paste? 2) Is your socket file named $DIR/db/socket? Most people use $DIR/db/node.socket, not that it matters as long as you are consistent when setting CARDANO_NODE_SOCKET_PATH

Also, check the iptables rules (eg sudo iptables -S) for your IPs and Ports. Start UFW and make sure the node/relay ports are accepting from all IPs ie from 'Anywhere' eg sudo ufw status verbose (you can lock down the inbound IP of your relay on the BP node later, so then only the relay can connect to your BP), and monitor all updated logs in /var/log.

Create an answer and detail what you think was the likely fix, and accept that answer. This way other people can learn from your experience.

the error is caused by a connectivity problem, but we can't be sure of what is exactly causing the problem without you providing additional details, so I would start diagnosing the connectivity between the two hosts. Please post masked results.
Please check IP addresses, and make sure you have them correctly, run in each host. Please specify if both hosts belong to the same subnet or not and if possible your hosting provider (some may require a special routing setup or policies).:
ip a

Please use IP numbers for the other tests below (instead of hostnames).
Please ping and tracert from each host to the other.
ping other_host
sudo apt install traceroute
traceroute other_host

Check if ufw or iptables are running in each host:
sudo ufw status numbered
service iptables status

Check if there's something running in the expected port:
netstat -an |grep LISTEN |grep your_port_for_that_host

If there's connectivity (you've got ping replies), there's no firewall (at least in your hosts), and your ports are in LISTEN state, you should be able to connect. Otherwise we should start looking outside your hosts (i.e. a network firewall).
Please check that the host 1 port is reachable from host 2.
From host 1:
nc -zv host_2_ip host_2_port

Depending on the results for the above tests, we can test further.
EDIT: After the first batch of tests, it seems that TCP connectivity to the node ports exists between the two hosts.
What instructions did you follow to install the nodes? are you using guild-operators scripts or any other? How do you start the node?
If using systemd, could you provide the output of the following command for both nodes?
sudo systemctl -l --no-pager status cnode

Cheers,
Josep

There's connectivity (you've got ping replies), there's no firewall, my ports are in LISTEN state and nc -zv host_2_ip host_2_port succeeded in both servers. "should start looking outside your hosts (i.e. a network firewall)" we should roceed with this

What is the output of nc -zv? Why do you say it succeeds? if it does, you should see a message like "Connection to x.x.x.x x port [tcp/*] succeeded!". Please check in both directions. If it really succeeds, we should have a look at the nodes configuration.

Yes, That exact message. I runned it in both directions.

Great Alberto, please provide the output of "sudo systemctl -l --no-pager status cnode" for both nodes.

I have truly no idea why, but its working now. I haven't changed anything. When I run "netstat -tpan" I see the connection between the nodes. I will leave it working for some days before doing anything, I'll let you know.

Hey Alberto, I'm glad it is working now! Be aware that when you start the node and a database already exists, it can take some minutes, or hours if it's not in a clean state, to fully start the node and make the connections. Please be sure that you're able to stop/start the node and the system and that everything keeps working, and also get used to the time it takes each operation. Don't forget to mark the question as solved. Cheers!

Are you getting connection errors in the node log files? When was the date/time of last connection error?


text:
Can anyone explain how tAda locked with asset is calculated?
I have previously asked a similar question here Get Ada locked with asset from db-sync query? but I'm still really stuck with this and needing some help.
After looking at Nami Wallet, Eternl Wallet and DB-Sync I am now totally confused because it would appear that each show a different value for tAda locked with assets.

Nami shows tAda locked with assets as 0.193950t₳,
Eternl shows tAda locked with assets as 3.676430t₳
DB-Sync shows tAda with assets as 4.241040t₳
Can anyone help explain what is going on here? and more importantly how to get the correct value for the total tAda that is locked with all assets? to be honest I didn't think it would be this challenging or confusing.
Any help on this is appreciated!
Also thanks to Erik de Castro Lopo for giving me your suggestion on my last question but sadly I'm still at a loss.

I am only familiar with db-sync. What is the query you are running there?

In Cardano, each UTxO can contain a heterogeneous mixture of tokens and data, but must contain at least some amount of ADA (in this case, tADA as you are in Testnet). This is done on purpose to prevent both inadvertent and malicious chain bloat. You can read more about minUTXOvalues here.
On your Eternl wallet, you probably have a couple UTxOs with tokens such that the min amount of ADA in each of those UTxO's totals to the locked amount displayed to you by Eternl.
I know that Eternl calculation is accurate, I am not sure about Nami.
Finally, keep in mind that db-sync is not showing "tADA locked with assets" but "tADA with assets": these amounts are different.


text:
Research collaboration: past snapshots of Yoroi/Adapools pool rankings
We are an MIT-based team doing research on the evolution of the Cardano ecosystem. We are analyzing delegations and we find the current snapshot of Yoroi/Adapools rankings at

https://js.adapools.org/pools.json
https://a.adapools.org/yoroi-api/
https://adapools.yoroiwallet.com/

We are wondering if anyone in the community has saved * past * snapshots from either one of these sources. These will be immensely useful for our research.
Thank you. We'll discuss our research once it's completed and we hope to contribute to the progress of the community. Please feel free to reach out at jiageng@mit.edu.

Related questions about the Cardano ecosystem:

Why do Binance stake pools pledge nothing?
Rising trend in blocks missing: what could be the reason? Should we worry?

I do not have any such snapshots. However I think all of these rank pools on the same data, which is likely to be stored in cardano-db-sync . If you can request information about the methodology these sites use, then it should be possible to recreate pool rankings for past epochs using the db-sync data.

I’m voting to close this question because it does not fit the typical Q&A format. The call to get in contact privately via email is not something that will be beneficial to the users here on the SE. While it is an endeavor that may be supported by the community, the research itself is not even explained. Other avenues may be better, but I do not think with our current guidelines, this "question" should remain open.


text:
No space left on device, cardano-db-sync to blame?
I'm getting errors when starting up my producer suggesting I'm out of storage. It looks like db/immutable is the culprit taking almost 100g of space. I'm not super familiar with what this db is or what writes to it.
Is this possibly cardano-db-sync which I'm running by mistake? Is this unneeded for my producer and is it possible to safely delete these files and remove whatever process is writing them?

It looks like db/immutable is the culprit taking almost 100g of spac

Yes, that is part of the cardano-node's on disk storage. I have just checked mine (on Linux) and the disk space used is only 72G. Looks like you may have some extra files in there taking up space.

Is this possibly cardano-db-sync which I'm running by mistake?

Very unlikely. Look at the logs. If its db-sync it will very clearly say so. Likewise with the node.

db/immutable looks like the db for the Cardano node (please make sure, check full path). If so, it is safe to, stop the node, and then delete the contents of the db directory, but you will need to wait for a full sync after starting it again (which will take some time and around 72G of space once complete), or you could copy the directory from another node (i.e. one relay), and then start the node to finish sync, which will save you some time.
About checking for other services running, please check i.e. :
systemctl | grep running
systemctl list-unit-files | grep enabled
ps aux

If you think another process is writing to the directory, you could gather extra information using iotop or fatrace, i.e.:
sudo apt-get install fatrace
sudo fatrace | grep immutable

Cheers,
Josep


text:
Is the fact that EUTXO can use scripts to lock/unlock UTXOs really a difference from the UTXO model?
In the EUTXO explainer it says that

[The EUTXO model] generalizes the concept of ‘address’ by using the lock-and-key analogy. Instead of restricting locks to public keys and keys to signatures, addresses in the EUTXO model can contain arbitrary logic in the form of scripts. For example, when a node validates a transaction, the node determines whether or not the transaction is allowed to use a certain output as an input. The transaction will look up the script provided by the output's address and will execute the script if the transaction can use the output as an input.

But isn't this the same as locking/unlocking scripts as used in Bitcoin? I understand Cardano's scripts are more sophisticated, but that is a difference of degree.

EUTXO stands for (Extended Unspent Transaction Output), the mechanism is, in spirit, the same as Bitcoin UTXO (Unspent Transaction Output) but very much improved.
The first difference is between scripting languages, Bitcoin uses Script which is a very primitive scripting language and has around 90 available OP Codes for use. Cardano uses Plutus which is essentially Haskell, a very powerful functional programming language.
The second difference is the information the script has to work with, Bitcoin script does not have access to the context information of the transaction, the user locking funds in a Bitcoin UTXO provides a partial Bitcoin Script, and the spender must complete the Script in a way that the Script leaves the value true on the stack after the execution ends, but the script is blind to the details of the transaction (the script has access to the signatures, but not the details about how the value is being transferred between parties), for example:
OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL

This script will hash twice the given data with SHA-256 (see OP_HASH256) and compare the result to the embedded hash (in this case the data is Genesis block header).
A Cardano Plutus script on the other hand has full access to everything that is going on in the transaction, how the ADA is moving, signatures etc:
-- | A pending transaction. This is the view as seen by validator scripts, so some details are stripped out.
data TxInfo = TxInfo
    { txInfoInputs      :: [TxInInfo] -- ^ Transaction inputs
    , txInfoOutputs     :: [TxOut] -- ^ Transaction outputs
    , txInfoFee         :: Value -- ^ The fee paid by this transaction.
    , txInfoMint        :: Value -- ^ The 'Value' minted by this transaction.
    , txInfoDCert       :: [DCert] -- ^ Digests of certificates included in this transaction
    , txInfoWdrl        :: [(StakingCredential, Integer)] -- ^ Withdrawals
    , txInfoValidRange  :: POSIXTimeRange -- ^ The valid range for the transaction.
    , txInfoSignatories :: [PubKeyHash] -- ^ Signatures provided with the transaction, attested that they all signed the tx
    , txInfoData        :: [(DatumHash, Datum)]
    , txInfoId          :: TxId
    -- ^ Hash of the pending transaction (excluding witnesses)
    } deriving stock (Generic, Haskell.Show, Haskell.Eq)

And the third difference is the introduction of the concept of Datum and Reedemer, Datums are linked to EUTXOs and are useful to keep track of state, and Reedemer is data that can be provided to the EUTXO when we want to unlock it, both Datums and Redeemers can be arbitrary data structures.
This is a good resource from the Plutus Pioneer Program that goes into detail on how the EUTXO model work:
https://www.youtube.com/watch?v=bfofA4MM0QE
The EUTXO in general it's more expensive and powerful.

Very good explainer. I still think that the text I quoted is misleading; UTXOs in the UTXO model can be locked with scripts. I think it would be better if the Cardano docs were rewritten to explain how much more powerful Cardano's scripts are rather than claim that the difference is the possibility of using scripts.
I guess the EUTXO definition they use comes from a time when bitcoin did not support locking UTXOs with scripts, only (hashed) public keys.

Yes, but the Bitcoin blockchain does not store a datum on-chain. So the concept is similar but you are very limited what you can do with those scripts.


text:
Read key from cose_key returned in signData()
The following (await window.cardano['<wallet>'].enable()).signData('<addr>', '<payload>')
Returns an object
{ key: <key>, signature: <sig> }
I'm successfully parsing the key to a CoseKey with ermugo/message-signing in node.js, but struggling to pull the header which contains the key. Reading CIP-0030 I believe it is contained within the headers as x. Could someone explain how I read this in code, please? Thanks for your time.
edit: if there is documentation that explains how to do this please show me the way.

Since it's mentioned in CIP-0030 that the key for the header associated with the public key is -2, I spent some time in the debugger and managed to fetch it with this code.
const coseKey = MessageSigning.COSEKey.from_bytes(Buffer.from(key, 'hex'));

const keyHeaderBytes = coseKey.header(MessageSigning.Label.new_int(MessageSigning.Int.new_i32(-2))).as_bytes();

Not sure if this is the optimal solution but it seems to work. Open to feedback.


text:
@emurgo/cardano-serialization-lib-browser on NextJS error when running `npm run build`
I'm a complete NextJS / React and Wasm newbie, but I'm having fun learning and building a simple website.
I've added @emurgo/cardano-serialization-lib-browser as a dep to my NextJS 17 project w/ npm i @emurgo/cardano-serialization-lib-browser.
When I run in dev mode npm run dev all is fine, I can use the library and everything looks great.
Unfortunately, when I build the project to deploy it on Vercel, I get the following error:
[Error: ENOENT: no such file or directory, open '/Users/giovanni/Development/workspace/raffles-easystaking/.next/server/static/wasm/35db299fd815ad0d.wasm'] {
  type: 'Error',
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/giovanni/Development/workspace/raffles-easystaking/.next/server/static/wasm/35db299fd815ad0d.wasm'
}

This is my package.json
{
  "name": "raffles-easystaking",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@emurgo/cardano-serialization-lib-browser": "^10.2.0",
    "@fortawesome/fontawesome-svg-core": "^6.1.1",
    "@fortawesome/free-solid-svg-icons": "^6.1.1",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "next": "12.1.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-hot-toast": "^2.2.0"
  },
  "devDependencies": {
    "autoprefixer": "^10.4.7",
    "eslint": "8.20.0",
    "eslint-config-next": "12.2.2",
    "postcss": "^8.4.14",
    "tailwindcss": "^3.1.6"
  }
}

and this is my next.config
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  webpack: function (config, options) {
    config.experiments = { asyncWebAssembly: true, layers: true };
    return config;
  }
}

module.exports = nextConfig

I also use tailwind, but I don't think that would be the issue.
Any help appreciated.
Thanks!

Try adding this line to webpack config:
config.output.webassemblyModuleFilename = 'static/wasm/[modulehash].wasm'

Also try loading component utilizing the wasm library using dynamic:
import dynamic from 'next/dynamic';

const component = dynamic(() => import('./component'), { ssr: false });

Thanks, this helps, but unfortunately doesnt solve. So the module is created, but in the wrong folder.
Next looks for the module in .next/server/static/wasm/35db299fd815ad0d.wasm but find returns ./.next/server/chunks/static/wasm/35db299fd815ad0d.wasm.
Your suggestion influences both folders, and I don't seem to be able to fool webpack.
Also, I'm very noob and I'm not sure how to use your second suggestion. I import port the followings:
import { BaseAddress, Address } from '@emurgo/cardano-serialization-lib-browser'
EDIT: the bug https://github.com/vercel/next.js/issues/25852

Thanks @dzCodes, using dynamic fixed the issue. And for all teh noobs like me, you need to dynamic(ly) import the component using the wasm library, and not the library itself. In my case the lib was in the Nav component, so I did: ```import dynamic from 'next/dynamic';
const Nav = dynamic(() => import('./Nav'), { ssr: false })```

we fixed it is by doing a conditional import based on whether we are on browser or node. Mesh do this for you so you just import the package and it will do the rest for you. we have made Mesh open source https://github.com/MartifyLabs/mesh if you want to check our code implementation or demo at https://mesh.martify.io/


text:
Syncing from genesis instead of snapshot
I start the docker as followed in the guide:
export NETWORK=mainnet &&\
docker pull inputoutput/cardano-graphql:6.2.0-${NETWORK} &&\
docker pull inputoutput/cardano-graphql-hasura:6.2.0 &&\
docker pull cardanosolutions/cardano-node-ogmios:v5.1.0-${NETWORK} &&\
RESTORE_SNAPSHOT=https://update-cardano-mainnet.iohk.io/cardano-db-sync/13/db-sync-snapshot-schema-13-block-7519843-x86_64.tgz \
docker-compose up -d &&\
docker-compose logs -f

However, db-sync didn't start from a point where I passed as a RESTORE_SNAPSHOT parameter instead started at 0 to sync from genesis which takes too much time to get sync. Any recommendations? If I keep waiting to make it sync via genesis probably will last 2-3 weeks.

Rolling back to genesis like this can be due to 3 reasons: the node is not synced, the node and db-sync are running on different networks or wrong/missing ledger state directory.

What you mean by node is not Ogmios right? I mean my node and db-sync are running on same computer in different screens and it's sync. However, I did not pass any parameter while starting db-sync about the ledger path.

On the db-sync command line there is a --state-dir parameter. That specifies the directory where the ledger state is expected.

If the state directory is empty then it will roll back to genesis.

One common issue when using snapshots is that the ledger state part of the snapshot is restored to one place and db-sync expects it in another.

Do you mind sending the link where I pass the parameter while starting db-sync? I did follow the guide and I don't know how to pass --state-dir parameter when running via docker compose.

Documentation is at https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/building-running.md . The --state-dir parameter should point to the directory where the db-sync should store its ledge state data (assuming you are syncing from genesis) or where db-sync will find the ledger state data from the snapshot.

The snapshot will only be applied if cardano-node is synced past the snapshot point, since the benefit of using it would be eliminated given cardano-db-sync rolls back to genesis under these conditions. For best results, ensure the node is close to the network tip prior to upgrading.


text:
Connecting Node and DB-Sync
I'm running Cardano Node and Cardano GraphQL on the same network/computer. This is how I started the node:
 cardano-node run \
   --topology /home/ubuntu/cardano/cardano-src/cardano-node/mainnet-topology.json \
   --database-path /home/ubuntu/cardano/cardano-src/cardano-node/data \
   --socket-path /home/ubuntu/cardano/cardano-src/cardano-node/data/node.socket \
   --host-addr xxx.xxx.xxx.xxx \
   --port 1911 \
   --config /home/ubuntu/cardano/cardano-src/cardano-node/mainnet-config.json

Wallet Start:
cardano-wallet serve \
      --port 1919 \
      --node-socket /home/ubuntu/cardano/cardano-src/cardano-node/data/node.socket \
      --mainnet \
      --database /home/ubuntu/cardano/cardano-src/cardano-node/data \
      --listen-address 0.0.0.0 \

Docker, GraphQL:
export NETWORK=mainnet &&\
docker pull inputoutput/cardano-graphql:6.2.0-${NETWORK} &&\
docker pull inputoutput/cardano-graphql-hasura:6.2.0 &&\
docker pull cardanosolutions/cardano-node-ogmios:v5.1.0-${NETWORK} &&\
RESTORE_SNAPSHOT=https://update-cardano-mainnet.iohk.io/cardano-db-sync/13/db-sync-snapshot-schema-13-block-7519843-x86_64.tgz \
docker-compose up -d &&\
docker-compose logs -f

How db-sync and node will communicate I did not pass any path of node data directory. I feel like Ogmios is pulling the same data as node did before and I'm storing the same data twice.

The Ogmios image you're using has it's own node instance. From https://ogmios.dev/getting-started/docker :

Ogmios docker images come in two flavours: cardano-node-ogmios and ogmios. The former is used to run a single container that bundles both a Cardano-node and an Ogmios server running side-by-side. It is likely the easiest way to get started. The latter is a standalone Ogmios server, and you’ll need to run that container in orchestration with a cardano-node; this is made relatively easy with Docker compose.


text:
Can you open a cardano-cli wallet on nami or daedalus?
I'm extremely worried a wallet through cli can be corrupted as i'm using a virtual machine which often crashes and deletes to itself. In other crypto wallets you can insert a secret phrase or a key to open the address in other extension wallets. Is this possibly in cardano?

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

Seed phrases following the bip-39 standard do exist for Cardano. However, there is no way to generate a seed phrase from a signing key. Therefore, the private key generated with the cardano-cli cannot be imported into a wallet that uses the seed phase recovery method.
To quote the answer given here

Your best bet would likely be to generate a new set of wallets derived from mnemonic instead of a raw master seed (used in cardano-cli).

In other crypto wallets you can insert a secret phrase or a key to open the address in other extension wallets. Is this possibly in cardano?

Yes. It is possible.
As an aside: creating wallets from cardano-cli, you get paymeny.vkey and payment.skey . If you keep the keys safe from the malfunctioning VM, you can use them to recover the wallet from other machines.


text:
Cardano-node over HTTP? Or as stack/cabal dependency?
Is there a way to include cardano-node as a dependency in my project? (Stack dependency or cabal dependency). I tried and it keeps failing because not all dependencies can be built. Maybe I need to include it as a Nix dependency, using a Nix project?
I am trying to write code that can make use of some features of cardano-cli and cardano-node without having to be using files.
Alternatively, is there a web wrapper around cardano-node? (That would allow me to create transactions, submit, query utxos, etc..)

I use cabal exclusively. You can include cardano-node as a dependency in the top level cabal.project file using something like what db-sync does. This may require that you add some of the other source-repository-package s that db-sync uses.

Alternatively, is there a web wrapper around cardano-node? (That would allow me to create transactions, submit, query utxos, etc..)

That sounds like part of the feature set of cardano-db-sync and the rest seems to be cardano-tx-submit-api.


text:
Running db-sync via CLI
While running the db-sync what to pass as a parameters is unclear.
PGPASSFILE=config/pgpass-mainnet cabal run cardano-db-sync -- \
    --config config/mainnet-config.yaml \
    --socket-path /home/ubuntu/cardano/cardano-src/cardano-node/data/node.socket \
    --state-dir /home/ubuntu/cardano/cardano-src/cardano-node/data/ledger \
    --schema-dir schema/ \
    --disable-ledger

What should I pass to --state-dir? I did pass ledger folder where my node stores data.
I'm going to subscribe blocks to read information such as from & to addresses, amount etc. If I pass --disable-ledger would it be a problem?
While running db-sync I'd like to pass the latest snapshot in here how do I pass it? (https://update-cardano-mainnet.iohk.io/cardano-db-sync/index.html#13/)
How do I pass port which db-sync runs? When I was running it via docker it was 3100 by default.

Thanks in advance!

What should I pass to --state-dir? I did pass ledger folder where my node stores data.

This should not be the same as any directory the node uses. Its for db-sync and related programs only.

I'm going to subscribe blocks to read information such as from & to addresses, amount etc. If I pass --disable-ledger would it be a problem?

This is documented. --disable-ledger means you will get all on-chain data but you don't get reward payments from the reward account associated with each address (until after they have been withdrawn), you don't get the epoch stake distribution and a couple of other minor things.

While running db-sync I'd like to pass the latest snapshot in here how do I pass it?

Its documented. You make sure db-sync is not running, restore the snapshot, then you run db-sync.

How do I pass port which db-sync runs?

Port for what? The PostgreSQL port for accessing the database? That is set by the PostgreSQL configuration.


text:
problem connecting to testnet (1.34.1; testnet is in Vasil)
when starting the testnet node using
cardano-node run +RTS -N -A16m -qg -qb -RTS \
 --topology testnet-topology.json \
 --database-path testnet/node/db \
 --socket-path node/db/socket \
 --config testnet/node/config_files/testnet-config.json

the server starts correctly, but fails connecting to the peers (in order to sync)
my testnet-topology.json looks like this:
{
  "Producers": [
    {
      "addr": "relays-new.cardano-testnet.iohkdev.io",
      "port": 3001,
      "valency": 2
    }
  ]
}

which is the default one
the error I receive is the following
Domain: "relays-new.cardano-testnet.iohkdev.io" Connection Attempt Exception,
destination [<probably iohk ip but omitting anyway (ipv6)>]:3001
exception: Network.Socket.connect: <socket: 50>: does not exist (Network is unreachable)

and after a while
Domain: "relays-new.cardano-testnet.iohkdev.io" Application Exception: <some ipv4>:3001
MuxError (MuxIOException Network.Socket.recvBuf:
resource vanished (Connection reset by peer)) "(recv errored)"

so I assume the problem is in the topology.
is the topology wrong? if yes can you provide the right one?
is the node version a problem due to Vasil?

AFAIK 1.35.X is needed for Vasil.
Please check the url below for details:
https://iohk.io/en/blog/posts/2022/07/04/cardano-s-approaching-vasil-upgrade-what-to-expect/
Edit: Just for clarification, Becky from IOG posted on Discord today
"Please note that we are deprecating node versions 1.35.0 and 1.35.1 . These contain known issues and should not be used. SPOs wishing to test Vasil functions ON THE TESTNET ONLY should do so using node version 1.35.2. SPOs should continue to run 1.34.x on mainnet until an official mainnet release is confirmed."
Cheers,
Josep

You must be running node@1.35.3 to correctly interact with the post Vasil HF chain.

Problem seems more at the socket level, as said here:
exception: Network.Socket.connect: <socket: 50>: does not exist (Network is unreachable)

problem could be related to question 3734
Do you have the an env variable in your .bashrc file like the following?
CARDANO_NODE_SOCKET_PATH="/home/user/cardano/db/node.socket"

yes the CARDANO_NODE_SOCKET_PATH environment variable is setted correctly

Is the file readable by the user that run the cardano-node service?
Also did you check with other relays if you have the same error?


text:
Errors when building cardano-node as a dependency in my project
I have included cardano-prelude as a dependency in my project's cabal.project file: https://github.com/omefire/api-server/blob/main/cabal.project
However, when I try to build the project with cabal build, I always end up getting this error:
...
[ 7 of 14] Compiling Cardano.Prelude.GHC.Heap ( src/Cardano/Prelude/GHC/Heap.hs, dist/build/Cardano/Prelude/GHC/Heap.o, dist/build/Cardano/Prelude/GHC/Heap.dyn_o )
[ 8 of 14] Compiling Cardano.Prelude.HeapWords ( src/Cardano/Prelude/HeapWords.hs, dist/build/Cardano/Prelude/HeapWords.o, dist/build/Cardano/Prelude/HeapWords.dyn_o )
[ 9 of 14] Compiling Cardano.Prelude.Json.Parse ( src/Cardano/Prelude/Json/Parse.hs, dist/build/Cardano/Prelude/Json/Parse.o, dist/build/Cardano/Prelude/Json/Parse.dyn_o )
[10 of 14] Compiling Cardano.Prelude.Json.Canonical ( src/Cardano/Prelude/Json/Canonical.hs, dist/build/Cardano/Prelude/Json/Canonical.o, dist/build/Cardano/Prelude/Json/Canonical.dyn_o )

src/Cardano/Prelude/Json/Canonical.hs:110:14: error:
    • Could not deduce (Buildable e2)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Word64’
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:29: error:
    • Could not deduce (Protolude.Conv.StringConv e2 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:110:42: error:
    • Could not deduce (ConvertText Text e2)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:109:10-50
      The type variable ‘e2’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
110 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:113:14: error:
    • Could not deduce (Buildable e1)
        arising from a use of ‘parseJSString’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Integer’
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:29: error:
    • Could not deduce (Protolude.Conv.StringConv e1 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:113:42: error:
    • Could not deduce (ConvertText Text e1)
        arising from a use of ‘toS’
      from the context: ReportSchemaErrors m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:112:10-51
      The type variable ‘e1’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
113 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^

src/Cardano/Prelude/Json/Canonical.hs:116:14: error:
    • Could not deduce (Buildable e0)
        arising from a use of ‘parseJSString’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Buildable Void -- Defined in ‘Formatting.Buildable’
        instance Buildable IntPtr -- Defined in ‘Formatting.Buildable’
        instance Buildable WordPtr -- Defined in ‘Formatting.Buildable’
        ...plus 24 others
        ...plus 12 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the expression: parseJSString (readEither . toS)
      In an equation for ‘fromJSON’:
          fromJSON = parseJSString (readEither . toS)
      In the instance declaration for ‘FromJSON m Natural’
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:29: error:
    • Could not deduce (Protolude.Conv.StringConv e0 GHC.Base.String)
        arising from a use of ‘readEither’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance Protolude.Conv.StringConv ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv LB.ByteString GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        instance Protolude.Conv.StringConv Text GHC.Base.String
          -- Defined in ‘Protolude.Conv’
        ...plus one other
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘(.)’, namely ‘readEither’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                             ^^^^^^^^^^

src/Cardano/Prelude/Json/Canonical.hs:116:42: error:
    • Could not deduce (ConvertText Text e0)
        arising from a use of ‘toS’
      from the context: MonadError SchemaError m
        bound by the instance declaration
        at src/Cardano/Prelude/Json/Canonical.hs:115:10-55
      The type variable ‘e0’ is ambiguous
      These potential instances exist:
        instance [safe] ConvertText Text Text
          -- Defined in ‘Protolude.ConvertText’
        instance [safe] ConvertText Text GHC.Base.String
          -- Defined in ‘Protolude.ConvertText’
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the second argument of ‘(.)’, namely ‘toS’
      In the first argument of ‘parseJSString’, namely
        ‘(readEither . toS)’
      In the expression: parseJSString (readEither . toS)
    |
116 |   fromJSON = parseJSString (readEither . toS)
    |                                          ^^^
cabal: Failed to build cardano-prelude-0.1.0.0 (which is required by
exe:api-server-exe from api-server-0.1.0.0). See the build log
above for details.

I tried this on Mac and Linux and got the same result.
How do I get past this issue?

Not exactly sure what the problem is but your cabal.project file should contain the same index-state line as the one in cardano-node. That may help

Thanks @ErikdeCastroLopo, that worked! Also, I had to run this on Linux (Ubuntu) for it to work! Thank you!

Majority of the Cardano devs use Linux, with the second most common OS being Mac. I don't know of any that use Windows.

I was using Mac. The error mentioned in the question was occurring on a mac

As mentioned by @Erik De Castro Lopo in the comments, this issue was resolved by adding the same index-state line in my cabal.project file as that of cardano-node.


text:
How to view Daedalus' Stake Pool Rankings, without having Daedalus downloaded?
Is there a way to view Daedalus' stake pool rankings, without having Daedalus installed?
I had to uninstall Daedalus because my laptop ran out of room.  Note, other explorers like AdaPools and Eternl use their own ranking formula.

Daedalus wallet uses SMASH server to fetch data about Stake Pools.
IOG SMASH server can be found here https://smash.cardano-mainnet.iohk.io/api/v1
Documentation about SMASH server, and interesting queries, here
However I think the sorting algorithm is up to Daedalus itself and hardcoded in the software, so no way known to me, to retrieve it.


text:
What is block density?
What is block density? Pools currently before the Vasil upgrade are saying switch from 1.35.x back to 1.34.x to increase “block density”.

Bonus question, any idea why the current 1.35.x pre Vasil in testnet node seems to be dropping blocks, and reducing chain density?

Looks like it’s an issue checking minFee between different era versions: https://github.com/input-output-hk/cardano-node/issues/4228#issuecomment-1195757220

Each epoch is supposed to have about 21600 blocks per epoch, where an epoch is 5 days long. If every epoch had 21600 blocks, the density would be 100%. However blocks occasionally get skipped so the density will be less than 100%.
This is not the exact way that "chain density" is calculated (I forget the exact way it is calculated) but it should be enough to understand the concept.

Just building on top of answer from Erik, a simple way to look at it would be :
(number of blocks minted so far in current epoch) / (number of slots so far in current epoch)
In ideal scenario, the density should match the active slot co-efficient (0.05 on testnet and mainnet, i.e. on average - 5% of chances for a random slot to have a block minted).
Is there a risk to protocol if density is too low? While it's far from ideal / healthy, current consensus network should work fine as long as there is 1 block in stability window , viz : 3k/f (i.e., 32160/0.05, which corresponds to ~ 1.5 days on testnet/mainnet).


text:
Will Quantum Computing Make Mining More Efficient Then Staking?
We all hear about cracking codes with quantum computing and who encryption standard will have to change to protect blockchains, but what about quantum mining?
Will mining on quantum computers make the energy consumption of protocols like Bitcoin lessen? If so then to what extent? Will it stop being an advantage Cardano has over Bitcoin or not?

No, PoW mining is still far more energy intensive than PoS.
PoW is always an arms race. If someone came up with a new more efficient BTC mining ASIC (completely ignoring the quantum computing part of the question) that was widely available, the same amount of energy would be used by the BTC network because that is the amount of energy available. The BTC network hash rate would however increase.

Proof of Work is built to be inefficient, in the sense that the protocol increases the "difficulty"  of mining if technology get's better. Its security properties depend on it being difficult to mine.
If it were the case that quantum computing made mining much more efficient, than either Bitcoin would have to change the way "mining" works (making it quantum-resistant) or it would become unsafe and lose its value.


text:
Deploying smart-contract
I'm have really trouble finding material that teach how to deploy a contract. Does someone here has already successfully deployed a smart-contract to the cardano test/mainnet? I need to know the steps!

You can checkout my repository that has working code on the testnet.  It is well documented and I also have a video of running the plutus code on the testnet.
https://github.com/lley154/cardano-lottery
Cheers,
Lawrence

Until the Vasil Hardfork plutus scripts are attached to every transaction that spends from that contract. An example of how that can be done via the cardano-cli can be seen here
Once, Vasil HF has gone through you can actually store your plutus script on-chain and jsut use a script reference instead of attaching it to every tx.


text:
Are mangled/franken addresses detectable?
I've been reading and playing around with mangled/franken addresses the past day. I understand the concept and I created one myself, but I am wrapping my head around the question if there is a way to detect if a given address is such mangled/franken address?
Since staking addresses are often used as authentication information, mangled/franken addresses can be used to impersonate wallets and trick systems that haven't considered such addresses.

If the stake part of the address has not been registered, that should be detectable (eg it does not exist in the stake_registration table of db-sync).
However, if the stake address has been registered, but to a different wallet than the payment address, I cannot think of a way to detect this.

staking addresses are often used as authentication information

I think that'd be a faulty assumption to begin with. The Wallet layer is a lot more open to human interpretation, protocol only knows about different types of addresses.
Grouping by stake addresses is often used to account for the common scenario (a typical end user) , but it should never really be equated as a guarantee to reepresent individual wallet(s). There is nothing except the root public key itself for the HD-Wallet to identify addresses owned by specific wallet.
Use of other assumptions have to come with the corresponding risks for exception cases as above (besides, it's not always a good result - audits for accounting can become really messy with these).


text:
How is Number Of Confirmations derived for a transaction?
In the wallet I use a transaction gets a "number of confirmations" and is indicated as "low" (red), "medium"(yellow), or "high"(green) confidence based on that number.
I have access to db-sync and can examine all sorts of information about transactions, but am not seeing how "number of confirmations" is derived..?

Number of confirmations refers to how "deep" the block containing the transaction is in the chain, relative to the current tip. For example, if my transaction was included in block #10, then it will be "confirmed" 5 times once my local copy of the chain is at block #15.
In other words, number of confirmations is the difference between the current block height and the height of the block in which the transaction was initially submitted.

Thank you!
I still don't understand how being 100 blocks "old" makes a transaction any more immutable than it already was once it was a transaction on the most recently accepted block. Nonetheless, your answer makes perfect sense and allows me to understand how to include "Number of Confirmations" in my own code, so thank you.

For blockchains with probabilistic finality (i.e. Bitcoin or Cardano), the deeper a transaction is in the chain, the less likely that a rollback will result in a null/dropped transaction. (Read more about finality: https://medium.com/mechanism-labs/finality-in-blockchain-consensus-d1f83c120a9a )

The most recently added block might roll back, however the further away from the chain tip a block is the less likely a rollback. Rollbacks of more that 2160 blocks are strictly prohibited by the protocol.


text:
Is my db-sync far behind the latest block/slot?
Looking at the select statement in the screencap below - with the latest info also displayed from cardanoscan - I was expecting to see a direct correlation but my db-sync appears to be far behind cardanoscan? Am I querying the db incorrectly? Making an incorrect assumption or interpreting wrong, or has my db-sync simply fallen far behind?

Firstly, you should avoid using the id field in any query (even sorting) for any purpose other than joining tables. The id fields are auto-generated by
PostgreSQL and different instances can have different id fields for the same block. It would be better to sort on block_no (which increments by one for each new block) or time.
It looks like your instance is an epoch or so behind.

Thank you for responding, as well as the knowledge about record id's.

Only when I sort by time do I get the correct ordering now that I've tried, and in fact I see I am getting the latest block/slot after all..!


text:
What is your comfort level for Number Of Confirmations, and why?
As an example, in Eternl wallet, a new transaction is marked as follows:

red (0 to 9 confirmations)
yellow (10 to 19 confirmations)
green (20+ confirmations)

I have been watching blocks in db-sync, and have observed that 20 confirmations takes anywhere from 7 to 8 minutes.
In my service, I think I will be starting with a value of 20 for minimum confirmations, or block depth in my query for new transactions, but I also would like to keep it as low as possible to shave as many minutes off users seeing their new transaction reflected in my service, while still remaining confident in the level of finality I am accepting as valid.
So...I am not yet sure where the sweet spot between speed of acceptance and confidence of finality is, so I am hoping everyone will state their view on the matter, and importantly, why.
Thank you!
EDIT:
I have examined my node console and remarked the "Switch to new fork" is an event that occurs consistently, perhaps a number of confirmations that on average correlates to that is an objective measure of confidence? Here's what I observed:
2022-07-28 06:50
2022-07-28 07:14 => 24 mins
2022-07-28 07:29 => 15 mins
2022-07-28 07:37 =>   8 mins
2022-07-28 07:44 =>   7 mins
2022-07-28 08:12 => 28 mins
2022-07-28 08:22 => 10 mins
2022-07-28 08:34 => 12 mins
2022-07-28 09:11 => 37 mins
2022-07-28 09:31 => 20 mins
2022-07-28 09:33 =>   2 mins
2022-07-28 09:36 =>   3 mins
2022-07-28 09:45 =>   9 mins
2022-07-28 10:13 => 28 mins
2022-07-28 10:23 => 10 mins
===================
               Sum =>213 mins

                Avg=>14.2 mins

So, switches to new fork on average about every 15 mins which is a long time in terms of confirmations...if I were to say, select the number of confirmations that on average certainly pushes beyond the most recent "switch to new fork" than I'd guess about 40 to 50 confirmations, and though it would often be overkill, it would also almost always be enough to cause a delay that extended beyond whatever the next "switch to fork" was following a given new transaction being tracked.

I have not had to do this, but if I did, my level of comfort would depend on the amount in question. If it was US$20 I might want 2 confirmations whereas if it was US$20,000 I might want 20 confirmations.

have observed that 20 confirmations takes anywhere from 7 to 8 minutes.

Basically each block added to the chain adds a confirmation. The average block time interval is about 20 seconds and if you have the ocassional missed block it will be slightly higher than that.
20 blocks * 20 second block interval => 400 seconds => 6.667 minutes

Good point about "greater amount requires greater confidence".


text:
Cardano transaction builder library in Haskell
Is there a way besides cardano-cli that I can use to construct a transaction using Haskell?
Something like Lucid-cardano npm package, but in Haskell land?
Said library should allow me to construct a tx, its datums, redeemers, adding scripts, etc...

You can almost certainly do this using the cardano-api in the same cardano-node repository. The code in cardano-cli can act as a guide.

Thanks, will look into it. It does seem like it requires a running node?

Creating the transaction does not require a running node, but submitting the transactions to the network will require a node.

cardano-transactions seems like what I would have loved to have, but it's not being actively developed anymore:
let eitherTx = Tx.empty testnetMagic       & Tx.addInput input0       & Tx.addOutput output0       & Tx.addOutput output1       & Tx.lock       & Tx.signWith key0       & Tx.serialize

Thanks @Erik, I'll look into it. I was just kinda hopping for a more convenient interface to use (like lucid-cardano in the npm/js world).


text:
How can I calculate slot number?
I need help in calculating Slot Number from Current Epoch and Slot. Is there a formula to calculate that?

You can check the genesis file for timestamp network started on (mainnet/testnet started on Byron) and use epoch/Slot for Byron (where an epoch consisted of 21600 slots, 1 slot being 20s) and shelley (where epoch consists of 432000 slots, 1 slot being 1s) respectively - all of this is in genesis JSONs you refer your node to on startup. The important bit here is knowing when Byron transited to Shelley, for mainnet, the epoch was 208.
You can find sample of how gLiveView calculates it here. You can also use ogmios to fetch era info from node (or use dbsync to know which epoch did forks get applied in).

Unfortunately while there may be such a formula it would be rather complex and would be different for each network (eg mainnet, testnet etc).

For all of the Byron Era, one slot has been 20 seconds long. Since the Shelley Hardfork (Epoch 208), one slot has been 1 second long. Assuming 1 slot will continue to be 1 second long, we can derive an approximate formula using the Unix Epoch time standard.
Epoch 208 started at 07/29/2020 at 21:44:51 PM UTC, or 1596059091 in UNIX time, at an absolute slot number of 4492800 (according to Cardanoscan)
Therefore, we can approximate that the current slot is:
<CURRENT_UNIX_TIME> - 1596059091 + 4492800
or simply,
<CURRENT_UNIX_TIME> - 1591566291
Which is a reasonable estimate after a quick test...

Since cardano-cli version 8.2.0 there exists cardano-cli query slot-number which will calculate slot number from UTC time.
E.g a sample query (taken from the merge request):
cardano-cli -- query slot-number --mainnet --socket-path /path/to/socket '2023-04-24T09:12:42Z'

will give you slot 90761271.

a couple informations from the genses file are neede; particoularly you will need the POSIX timestap at which the chain was started ("system start") and the slot length in milliseconds
The formula in used in plu-ts is the following:
function POSIXToSlot( POSIX: number, sysStartPOSIX: number, slotLenMs: number ): number
{
    return Math.floor( (POSIX - sysStartPOSIX) / slotLenMs );
}

function slotToPOSIX( slotN: number, sysStartPOSIX: number, slotLenMs: number ): number
{
    return sysStartPOSIX + (slotLenMs * slotN);
}


text:
Can Mithril Aggregators change snapshot after signing?
Mithril is a mechanism for developing lightweight wallets by storing blockchain snapshots on Mithril Aggregator. We can authenticate these snapshots using Multi Signature. But after the snapshot is signed, it will be stored by Mithril Aggregator. How to ensure Mithril Aggregator does not modify the data of these snapshots?

We ensure that the Aggregator does not modify the data of the snapshots by verifying the signature. The Mithril team will soon release documentation where this type of information will be clearer.
But to answer your question, the snapshots will be signed by Mithril nodes, and distributed by the aggregators as you said. However, the role of the aggregator is only to serve as a distributor, and we don't need to trust that the data shared is correct. That's what the signature is for. A Mithril client downloads the certificate (which cannot be forged by the aggregator) and the snapshot. Then, it verifies that the snapshot is signed (and therefore validated) by the Mithril certificate. This guarantees that the snapshot received by the client is the one signed by the Mithril nodes, and has not been tampered by the Aggregator. If the signature validates, then the Mithril client can use that snapshot to spin the wallet/node.
[EDIT]: The Mithril project is finally public. You can find more information in the proof of concept documentation:
https://mithril.network/doc/


text:
How build a transaction to add ADA and change the datum of a previous transaction with assets and ADA locked in a script
I have locked ADA and assets into a script.
I want to use the last transaction output and the ADA of a wallet as inputs and I want to have an output with some extra ADA locked and the datum changed
const settings = {
  protocolParams: {
    linearFee: {
      minFeeA: "44",
      minFeeB: "155381",
    },
    minUtxo: "4310",
    poolDeposit: "500000000",
    keyDeposit: "2000000",
    maxValSize: 5000,
    maxTxSize: 16384,
    priceMem: 0.0577,
    priceStep: 0.0000721,
    coinsPerUtxoByte: "4310",
  }
};
    const initTransactionBuilder = () => {
        const { protocolParams } = settings;
        const txBuilder = TransactionBuilder.new(
        TransactionBuilderConfigBuilder.new()
        .fee_algo(LinearFee.new(BigNum.from_str(protocolParams.linearFee.minFeeA), BigNum.from_str(protocolParams.linearFee.minFeeB)))
        .pool_deposit(BigNum.from_str(protocolParams.poolDeposit))
        .key_deposit(BigNum.from_str(protocolParams.keyDeposit))
        .coins_per_utxo_byte(BigNum.from_str(protocolParams.coinsPerUtxoByte))
        .max_value_size(protocolParams.maxValSize)
        .max_tx_size(protocolParams.maxTxSize)
        .prefer_pure_change(true)
        .build()
        );
        return txBuilder
    };
    const buildRedeemAdaFromPlutusScript = async (walletApi,
        { transactionIdLocked, transactionIndxLocked, lovelaceLocked, manualFee, CollatUtxos, newDatumStr, datumStr }) => {
        const txBuilder = initTransactionBuilder();
        const ScriptAddress = Address.from_bech32(settings.smartContract.addressScriptBech32);
        const shelleyChangeAddress = Address.from_bech32(await walletApi.getChangeAddress());

        let multiAsset = MultiAsset.new();
        let assets = Assets.new()
        assets.insert(
        AssetName.new(Buffer.from(assetNameHex, "hex")),
        BigNum.from_str(assetAmountToSend.toString())
        );
        multiAsset.insert(
        ScriptHash.from_bytes(Buffer.from(assetPolicyIdHex, "hex")),
        assets
        );

        const outputVal = 2 * lovelaceLocked - Number(manualFee);
        const outputValStr = outputVal.toString();

        let txOutputScriptBuilder = TransactionOutputBuilder.new();
        txOutputScriptBuilder = txOutputScriptBuilder.with_address(ScriptAddress);
        const dataHash = hash_plutus_data(PlutusData.new_integer(BigInt.from_str(newDatumStr)));
        txOutputScriptBuilder = txOutputScriptBuilder.with_data_hash(dataHash)
        txOutputScriptBuilder = txOutputScriptBuilder.next();
        txOutputScriptBuilder = txOutputScriptBuilder.with_coin_and_asset(BigNum.from_str(outputValStr), multiAsset)
        const txOutputScript = txOutputScriptBuilder.build();
        txBuilder.add_output(txOutputScript)

        txBuilder.add_input(
        ScriptAddress,
        TransactionInput.new(
            TransactionHash.from_bytes(Buffer.from(transactionIdLocked, "hex")),
            transactionIndxLocked.toString()),
            Value.new_with_assets(BigNum.from_str(lovelaceLocked.toString()), multiAsset)
        );

        const { txOutputs: txUnspentOutputs } = await walletApi.getUtxos();
        txBuilder.add_inputs_from(txUnspentOutputs, 2)
        txBuilder.add_change_if_needed(shelleyChangeAddress)

        txBuilder.set_fee(BigNum.from_str(Number(manualFee).toString()));
        const txBody = txBuilder.build();

        const scripts = PlutusScripts.new();
        scripts.add(PlutusScript.from_bytes(Buffer.from(settings.smartContract.plutusScriptCborHex, "hex")));

        const collateral = CollatUtxos;
        const inputs = TransactionInputs.new();
        collateral.forEach((utxo) => {
            inputs.add(utxo.input());
        });

        const datum = PlutusData.new_integer(BigInt.from_str(datumStr));

        const redeemers = Redeemers.new();
        const redeemer = Redeemer.new(
        RedeemerTag.new_spend(),
        BigNum.from_str("0"),
        datum,
        ExUnits.new(
            BigNum.from_str("7000000"),
            BigNum.from_str("3000000000")
        )
        );
        redeemers.add(redeemer);
        const datums = PlutusList.new();
        datums.add(datum);

        const transactionWitnessSet = TransactionWitnessSet.new();
        transactionWitnessSet.set_plutus_scripts(scripts);
        transactionWitnessSet.set_plutus_data(datums);
        transactionWitnessSet.set_redeemers(redeemers);
        const cost_model_vals = [
        205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366,
        10475, 4, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000,
        100, 100, 100, 23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1,
        89141, 32, 497525, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4,
        2, 245000, 216773, 62, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000,
        52998, 1, 80436, 32, 43249, 32, 1000, 32, 80556, 1, 57667, 4, 1000, 10,
        197145, 156, 1, 197145, 156, 1, 204924, 473, 1, 208896, 511, 1, 52467, 32,
        64832, 32, 65493, 32, 22558, 32, 16563, 32, 76511, 32, 196500, 453240, 220, 0,
        1, 1, 69522, 11687, 0, 1, 60091, 32, 196500, 453240, 220, 0, 1, 1, 196500,
        453240, 220, 0, 1, 1, 806990, 30482, 4, 1927926, 82523, 4, 265318, 0, 4, 0,
        85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32, 31220, 32, 32696, 32,
        43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
        ];
        const costModel = CostModel.new();
        cost_model_vals.forEach((x, i) => costModel.set(i, Int.new_i32(x)));
        const costModels = Costmdls.new();
        costModels.insert(Language.new_plutus_v1(), costModel);
        const scriptDataHash = hash_script_data(redeemers, costModels, datums);
        txBody.set_script_data_hash(scriptDataHash);
        txBody.set_collateral(inputs);
        const baseAddress = BaseAddress.from_address(shelleyChangeAddress);
        const requiredSigners = Ed25519KeyHashes.new();
        requiredSigners.add(baseAddress.payment_cred().to_keyhash());
        txBody.set_required_signers(requiredSigners);
        const tx = Transaction.new(
        txBody,
        TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes())
        );
        let txVkeyWitnesses = await walletApi.api.signTx(Buffer.from(tx.to_bytes(), "utf8").toString("hex"), true);
        txVkeyWitnesses = TransactionWitnessSet.from_bytes(Buffer.from(txVkeyWitnesses, "hex"));
        transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());
        const signedTx = Transaction.new(
        tx.body(),
        transactionWitnessSet
        );
        const submittedTxHash = await walletApi.api.submitTx(Buffer.from(signedTx.to_bytes(), "utf8").toString("hex"));
        return { submittedTxHash };
    };

Error:
""transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO (Value 2258970370 (fromList [(PolicyID {policyID = ScriptHash \"9560a89a549f66bb02c4a04525e8e367283f566ec0e34e1a31cf3aa2\"},fromList [(4a616c61436f696e,999962)])])) (Value 2259870370 (fromList [(PolicyID {policyID = ScriptHash \"9560a89a549f66bb02c4a04525e8e367283f566ec0e34e1a31cf3aa2\"},fromList [(4a616c61436f696e,999962)])])))))])""

From the error message it looks like your input value is not equal your output value minus fees, so I suggest checking the Tx inputs.


text:
Ledger Nano S undetected when Redeem Yoroi Reward - Brave
I have a Yoroi account linked to a Ledger hw ( model s).
When I tried to redeem my rewards it asked to connect my ledger, which I did.
My ledger is on but Yoroi says that no device is detected...
I'm using the Brave browser so maybe I have to allow something.

Firstly, make sure that your Ledger working correctly via the Ledger app.
In Brave you may need to 'lower shields' ie disable the default security by clicking the lion icon next to the address bar, then disable security for the site/extension. Be careful here and double check your settings, just in case.
Double check Ledger connections via the Yoroi FAQ here: https://yoroi-wallet.com/#/faq/3
In Yoroi you can also check the log files for more information. Go to the menu Settings -> Support/Logs -> Download Logs


text:
How to hardcode smart contract address in minting policy in Plutus?
1st way I tried to do it was to get validator address using this function:
{-# INLINABLE scriptAddress #-}
-- | The address that should be used by a transaction output locked by the given validator script.
scriptAddress :: Validator -> Address
scriptAddress validator = Address (ScriptCredential (validatorHash validator)) Nothing

For example:
-- | The validator script of the game.
gameValidator :: ValidatorScript
gameValidator =
    ValidatorScript ($$(Ledger.compileScript [|| validateGuess ||]))

gameAddress :: Address
gameAddress = Ledger.scriptAddress gameValidator

Then use this gameAddress variable as parameter in minting policy, which compiles and works fine.
But real contract address never matches the address parameter, script fails on cardano-cli submit:
txOutputs :: [TxOut]
txOutputs = txInfoOutputs info

ownOutput :: TxOut
ownOutput = case [o | o <- txOutputs, gameAddress == txOutAddress o] of
[o] -> o
_ -> error ()

We always get an error here (I am sure that there is an output to the same smart contract).
This gameAddress has no awareness of mainnet/testnet, maybe that's the reason why it does not match? Maybe there is a way to fix this?
Also, is there a way to simply hardcode smart contract address into Plutus code? Like we can do with PubKeyHash?:
hardcodedPubKeyHash :: PubKeyHash
hardcodedPubKeyHash = "f1befc070bbc16ea613cfc0f0a5c0f856063f1ecbe640556136568f8"

If it does not match, it means your off-chain code is using a different address than what you expect on-chain.
An address is comprised of two parts, the payment and the staking part. You seem to be calculating the address of the payment part being the ValidatorHash of your game script and the staking part to be Nothing.
Maybe your off-chain code is creating the address slightly differently?
There is a function scriptOutputsAt in V1/V2 plutus (https://github.com/input-output-hk/plutus/blob/5cc518f1202930ad52b8ba838af32af084c0e754/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs#L251-L258) which you could also use. It explicitly only looks at the payment part and ignores the staking part.

good point. managed to make it working using scriptOutputsAt function. Nothing else worked, even extracting ValidatorHash from each output and comparing it to ValidatorHash parameter from contract (gameValidatorHash = validatorHash $ Validator $ mkGameScript). Thanks!

If it worked, you can accept the answer (I guess there is a button for that).

In Haskell "f1befc070bbc16ea613cfc0f0a5c0f856063f1ecbe640556136568f8" is a string (because its enclosed in double quotes), not a PubKeyHash.
I think all you need to add the constructor like this (it compiles, but not 100% sure it does the right thing):
hardcodedPubKeyHash :: PubKeyHash
hardcodedPubKeyHash = PubKeyHash "f1befc070bbc16ea613cfc0f0a5c0f856063f1ecbe640556136568f8"


text:
Is there training offered for those interested in being moderators?
Is there training offered for being a moderator? I would love to be one of them. I like learning and helping too.

What channel would you like to be a moderator of? Eg web forums, Telegram, user/tech support, discord, github, catalyst etc
With stackexchange you can start answering questions and helping out right away. As you gain more reputation points for helping out then more options/access becomes available to you.
A lot of information will need to be self-taught via official blogs, and community websites/channels.
I suggest that you start with the IOG technical discord server and find the area of interest to you and expand out from there.
IOG Technical Discord = https://discord.gg/SNvzGjAj
There are also IOG/IOHK blogs (https://iohk.io/en/blog/posts/page-1/) and email newletters for the different areas eg community@iohk.io sends out updates relating to stake pool operator interests.
Take a look at the IOG blogs and then you can pick an area of interest to sign up to and then approach them to get more involved.

Thanks. Am interested in plutus


text:
How would you implement Soulbound Tokens in Cardano?
A lot is going on at the moment in the Ethereum dev community with Soulbound Tokens: https://ethereum-magicians.org/t/eip-5114-soulbound-badges/9417
What would be the best approach for implementing non-transferable tokens in Cardano?
A soulbound token is a token that is bound to a wallet when it is minted, and cannot be transferred/moved after that. In Cardano, I understand this means it should be locked to a specific UTxO that has to be part of the wallet.
Is it possible to implement this in Cardano without the need of smart contracts?

Def: "Soulbound tokens (SBT) are non-transferable, publicly-verifiable digital tokens that can act as a type of CV for web3 users, showing an individual’s memberships, credentials, and affiliations." This is a pretty good write up on SBTs: https://www.axi.com/au/blog/education/blockchain/soulbound-tokens

Just thinking out loud here, this would probably be best implemented at the protocol level eg an extra flag to indicate if an asset/NFT is transferable or not. Plus methods to query/verify and burn. So a CIP would be needed to get some consideration and deep discussion https://cips.cardano.org/ - mind you Atala Prism and Digital IDs might offer the same functionality.

Thanks for your comment, mate. Yes, I'm thinking of proposing a CIP myself, that's why I'm trying to get some ideas from the community first, on how this can be addressed.

Atala Prism looks to address this use case: "Atala PRISM is a self-sovereign identity (SSI) platform and service suite for verifiable data and digital identity. Built on Cardano, it offers core infrastructure for issuing DIDs (Decentralized identifiers) and verifiable credentials, alongside tools and frameworks to help expand your ecosystem." https://www.atalaprism.io/ - They also have a useful services walk through showing the different interactions https://www.atalaprism.io/app/credentials

Even though Prism exists, having competition/alternative services is always better for the eco-system, and having core services at the protocol level offers more certainty and robustness. Good luck with the CIP.

Any native asset on cardano can be transferred according to the ledger rules.
To make something non-transferrable you would need to make it unspendable.

For "pay to pubkey" outputs, this would mean to throw away the key - I don't think this is what you want in this case.
The only alternative "pay to script" outputs are governed by the script (currently either a simple or plutus script). Making these unspendable is easy, think const False for plutus.

As you ask "without the need for smart contracts" I would say: No, scripts will be required to implement something like this.
But isn't Ethereum using smart contracts for this as well?
If scripts are okay, one could draft up a specification what an SBT is. For example (based on my limited familiarity with SBTs) something like:

A cardano native token / asset with quantity 1, which
was minted by a policy that ensures single mint & pay to some public key (two parameters: TxOutRef and PubKeyHash) creating an output, that
is governed by an unspendable script (identified by script hash), which
also contains a datum (inline or hash) pointing to the owner (PubKeyHash above).

Note that "from the outside" this would not be resolvable who some SBT belongs to, you would need the parameters of the minting script and anything needed for the datum pre-image to verify. For example the "seed" TxOutRef and the PubKeyHash of the "soul"


text:
cardano-serialization-lib ExUnits
I am new to Cardano and Plutus.
I was trying to build a transaction that redeems a UTxO from the alwayssucceeds contract on Cardano Testnet.
The Redeemer object constructor takes ExUnits as one of the parameters and I used values from Ex Budget part of output of the cabal run plutus-alwayssucceeds -- 42 alwayssucceeds.plutus , but when I try to submit the transaction I get an error that the machine terminated due to overspending the budget.
I was wondering where I could get the correct values for ExUnits, if not from cabal run? It might not be a big problem for the alwayssucceeds contract, but I will have to know the correct values for whatever contracts I will write for my own projects...
Here is how I create the Redeemer:
let redeemer = CardanoWasm.Redeemer.new(
                CardanoWasm.RedeemerTag.new_spend(),
                CardanoWasm.BigNum.from_str("0"),
                datum,
                CardanoWasm.ExUnits.new(
                    CardanoWasm.BigNum.from_str("1100"), //memory
                    CardanoWasm.BigNum.from_str("297830") //steps
                )
            );

And here is the error I get:
transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage
(ApplyTxError
    [UtxowFailure (UtxoFailure
        (FromAlonzoUtxoFail
            (UtxosFailure
            (ValidationTagMismatch
                (IsValid True)
                (FailedUnexpectedly
                     (PlutusFailure "\nThe 3 arg plutus script
                         (PlutusScript PlutusV1 ScriptHash \"67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656\") fails.\n
CekError An error has occurred:  User error:\n
The machine terminated part way through evaluation due to overspending the budget.\n
The budget when the machine terminated was:\n({ cpu: -47270\n| mem: -500\n})\n
Negative numbers indicate the overspent budget; note that this only indicatessthe budget that was needed for the next step, not to run the program to completion.\n
The protocol version is: ProtVer {pvMajor = 7, pvMinor = 0}\n
The data is: I 42\n
The redeemer is: I 42\n
The context is:\n
    Purpose: Spending
    (TxOutRef {txOutRefId = 202acb00198b4ff05420110addd32e7cabb39d67694152d46356cee2f9454455, txOutRefIdx = 0})\n
    TxInfo:\n  TxId: 950e298860961fab043e7a24e7199bfa07fe37b81874776786c99a4612d37c7a\n
    Inputs: [ 202acb00198b4ff05420110addd32e7cabb39d67694152d46356cee2f9454455!0 -> - Value (Map [(,Map [(\"\",3000000)])]) addressed to\n ScriptCredential: 67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656 (no staking credential) ]\n
    Outputs: [ - Value (Map [(,Map [(\"\",2821081)])]) addressed to\nPubKeyCredential: 64356374321e2e70dcce03e074e7c8beadfbc3ee0f27a22a9c8fc611 (StakingHash PubKeyCredential: a94f395e81e6b4405ed4bb6e7e8bce939d055b036b5de81b94235d9d) ]\n
    Fee: Value (Map [(,Map [(\"\",178919)])])\n
    Value minted: Value (Map [])\n
    DCerts: []\n
    Wdrl: []\n
    Valid range: (-\8734 , +\8734)\n
    Signatories: []\n
    Datums: [ ( 9e1199a988ba72ffd6e9c269cadb3b53b5f360ff99f112d9b2ee30c4d74ad88b\n          , 42 ) ]\n" "hgCYphoAAyNhGQMsAQEZA+gZAjsAARkD6BlecQQBGQPoGCAaAAHKdhko6wQZWdgYZBlZ2BhkGVnYGGQZWdgYZBlZ2BhkGVnYGGQYZBhkGVnYGGQZTFEYIBoAAqz6GCAZtVEEGgADYxUZAf8AARoAAVw1GCAaAAeXdRk29AQCGgAC/5QaAAbqeBjcAAEBGQPoGW/2BAIaAAO9CBoAA07FGD4BGgAQLg8ZMSoBGgADLoAZAaUBGgAC2ngZA+gZzwYBGgABOjQYIBmo8RggGQPoGCAaAAE6rAEZ4UMEGQPoChoAAwIZGJwBGgADAhkYnAEaAAMgfBkB2QEaAAMwABkB/wEZzPMYIBn9QBggGf/VGCAZWB4YIBlAsxggGgABKt8YIBoAAv+UGgAG6ngY3AABARoAAQ+SGS2nAAEZ6rsYIBoAAv+UGgAG6ngY3AABARoAAv+UGgAG6ngY3AABARoADFBOGXcSBBoAHWr2GgABQlsEGgAEDGYABAAaAAFPqxggGgADI2EZAywBARmg3hggGgADPXYYIBl59BggGX+4GCAZqV0YIBl99xggGZWqGCAaAJBjuRkD/QqCGQZAGgAFRAxOTQEAADMiIiAFEgASABGfGCoYKth5n9h5n5/YeZ/YeZ/YeZ9YICAqywAZi0/wVCARCt3TLnyrs51naUFS1GNWzuL5RURV/wD/2Hmf2Hmf2HqfWBxn8zFGYXpeYZNggds7IRfL9ZvSEjdI9YrJZ4ZW/9h6gP+hQKFAGgAtxsDYeZ9YIJ4RmamIunL/1unCacrbO1O182D/mfES2bLuMMTXStiL/////5/YeZ/YeZ/YeZ9YHGQ1Y3QyHi5w3M4D4HTnyL6t+8PuDyeiKpyPxhH/2Hmf2Hmf2HmfWBypTzlegea0QF7Uu25+i86TnQVbA2td6BuUI12d/////6FAoUAaACsL2dh6gP//oUChQBoAArrnoUChQACAgNh5n9h5n9h5gNh6gP/YeZ/Ye4DYeoD//4Cf2HmfWCCeEZmpiLpy/9bpwmnK2ztTtfNg/5nxEtmy7jDE10rYixgq///YeZ9YIJUOKYhglh+rBD56JOcZm/oH/je4GHR3Z4bJmkYS03x6///Yep/YeZ/YeZ9YICAqywAZi0/wVCARCt3TLnyrs51naUFS1GNWzuL5RURV/wD/////ggcA" :| []))))))])```

I have the same issue when using Nami wallet and cardano-serialization to send redeem data.
I can't increase mem and step too big because Nami set collateral for fixed 5 ADA. Please tell me if you know how to fix that

These two are the maximum computation resources you're declaring your contract needs. I believe the easiest way to get the "right" value, is to interact with your contract on testnet in various ways, and get a ballpark of those two values.
For these initial interactions, you can use cardano-cli transaction build which doesn't require them, and then either use cardanoscan.io to see the consumed resources, or even look inside the CBOR of your transaction file to find them (the latter doesn't require you to submit the transaction).
What you put for these two values doesn't affect the transaction fees much, they are just a pair of numbers in your transaction CBOR. So you'd probably be able to use a pair of larger numbers (maybe even an order of magnitude larger) to construct your transactions.

Thank you very much! The cardano-cli transaction build trick really helped!

How to trcik cardano-cli transaction build? can you explain more details? I am also beginner for cardano. thank you

I am using much higher ExUnits for my redeemer and it works just fine.
Redeemer.new(
    RedeemerTag.new_spend(),
    BigNum.from_str('0'),
    PlutusData.new_constr_plutus_data(
        ConstrPlutusData.new(
            BigNum.from_str('1'),
            datum
          )
        ),
    ExUnits.new(
      BigNum.from_str("7000000"),
      BigNum.from_str("3000000000")
    )
);

Source: dApp Wallet Connector Example

Yes, I have seen that example, but my question is how to get these correct values. Sure, I can find examples for the sample contracts online, but how can I get this budget for my own contracts?

Ah ok, sorry I misunderstood the question. The only resource I know is this one:
https://playground.plutus.iohkdev.io/doc/plutus/howtos/analysing-scripts.html


text:
Is it possible to change the minimum ada value for an UTxO?
If I want to send a token or NFT in Cardano, I need to include some ada with it. This is known as minimum-ada-value.
Is it possible to change this value for a specific NFT and make it so big that it is almost impossible to send the NFT?
I'm thinking of this solution as a way of implementing non-transferable tokens in Cardano.

The minAda requirement is given by the protocol parameters and is a core parameter that cannot be changed for individual UTxOs.
If you want to create non-transferable tokens on Cardano, please check out this thread, this was just answered recently :).
Non-transferrable Tokens


text:
How to view binarydata in cexplorer?
When running sql script to view data on Cexplorer database, many times,I see binary data.
for example, multi_asset.name, multi_asset.policy in the following query.

Is there any way to view these data in normal text?
Thanks very much.

These fields are not in general "normal text". They might be normal text (eg ASCII) or they could also be UTF-8 or UTF-16 or any other encoding.
The most sensible way to view them is as hexadecimal and that is what the psql command line does. Eg:
$ psql cexplorer
psql (14.5 (Debian 14.5-1), server 13.7 (Debian 13.7-0+deb11u1))
Type "help" for help.

cexplorer=# select * from multi_asset limit 1 ;
 id |                           policy                           |       name       |                 fingerprint
----+------------------------------------------------------------+------------------+----------------------------------------------
  1 | \x00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae | \x6e7574636f696e | asset12h3p5l3nd5y26lr22am7y7ga3vxghkhf57zkhd
(1 row)

So it you want something that is guaranteed to be "normal text" you should use the fingerprint field, which is Bech32 encoded.

Thank you very much. Is there anyway to do like this on PgAmin?

Sorry, no idea. I have never used PgAdmin.

Thanks you very much. It is very helpful to me.

in your case:
SELECT multi_asset.policy::text human_policy FROM ...

or
SELECT encode(multi_asset.name::bytea, 'escape'::text) human_name FROM ...

thanks a lot. For me, it is the easiest way.


text:
How to get all assets of a certain addresss using SQL on Cexplorer
It seems like a simple question, but I was struggling to find the answer.
I am trying to get information of Cardano blockchain from cexplorer database.
Given an address such as 'addr1w9742z4fewans7ry6cjp95pc4ecv7y54cx298lp5qfw7s9gv8ukrj'
How can I get all the assets currently belonging to this address.
(the assets are minted tokens, nfts, amount of ADA, etc)
Thank you very much.

For ADA balance, you can use the utxo_view table like this:
select * from utxo_view where
  address = 'addr1w9742z4fewans7ry6cjp95pc4ecv7y54cx298lp5qfw7s9gv8ukrj' ;

If you look at how utxo_view is defined, you can probably copy and tweak it so you are looking at the relevant multi_asset tables instead.

Thanks for your question. I understand that the utxo_view is for querying the number of ADA. But I still do not get how to get other assets. Could you please provide a rough idea of how to get other assets?

You will need to create a new SQL view (call it say ma_utxo_view) that uses the multi asset tables rather than the main tables.

I guess something like this, right?
from public.multi_asset, public.tx_out, public.ma_tx_out
where multi_asset.id = ma_tx_out.ident and tx_out.id =  ma_tx_out.tx_out_id and
tx_out.address ='addr1w9742z4fewans7ry6cjp95pc4ecv7y54cx298lp5qfw7s9gv8ukrj'```

That seems correct, but I would suggest that you create a view (ie something like the utxo_view) and submit that via GH so I can add that as to the default db-sync distribution.