text:
Does ADA have a policyId and a assetName?
If all assets have a policyId and an assetName, what is the policyId and assetName of ADA?
I'm assuming the assetName is ADA, but seeing as how ADA is the principal asset of Cardano, what is the policyId?

Yes, all assets should have a policyId.
In case of ADA:

policyId (adaSymbol) is an emptyByteString = ""
assetName (adaToken) is an emptyByteString = ""


text:
How to fetch assets siting on an adress using cardano serialization library and Nami wallet?
Hello I am building a daap and i wanted to save blockFrost requests so I wonder if it is posible to fetch all assets using the nami wallet? I was trying with the window.cardano.get balance() , after using cardano serialization lib  with Value.from_bytes() I get the ada total using Value.from_bytes().coin().to_str()  but for all the other methods defined on Value.from_bytes() i can not find any that allows me to get .to_str() ... so even if i think that the total assets is in the original Value, I can not read it. Any help?

You could try this out. Basically assets are under value.multiassets() and is a double map from policy ID => assetName => quantity. You can iterate over this map with 2 for loops:
const value = CSL.Value.from_bytes(...) // your value
const lovelace = value.coin().to_str();
if (value.multiasset()) {
const multiAssets = value.multiasset().keys();
for (let j = 0; j < multiAssets.len(); j++) {
  const policy = multiAssets.get(j);
  const policyAssets = value.multiasset().get(policy);
  const assetNames = policyAssets.keys();
  for (let k = 0; k < assetNames.len(); k++) {
    const assetPolicy = Buffer.from(policy.to_bytes()).toString("hex"); // hex encoded policy
    const assetName = Buffer.from(
      assetNames.get(k).name(),
      "hex"
    ).toString(); // utf8 encoded asset name
    const quantity = policyAssets.get(assetNames.get(k)).to_str(); // asset's quantity

    // your code here

  }
}

Can I use Buffer in the browser or is this code only running on a Server (NodeJS)?

source: Stack Exchange

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

sort: votes


text:
Missed slot leader checks
The “missed slot leader checks” on my stakepool are at 0.98% or 14,527. Is this cause for concern? I have tried applying the solutions found in the following links, but nothing seems to make a difference, links →

https://forum.cardano.org/t/too-many-missed-slots-happens-help-me/75942/44
http://www.htgsd.com/cryptocurrency/ada-cardano-stakepool/missed-slot-leader-checks-missed-blocks-with-stakepool-cardano-node-ada/
https://forum.cardano.org/t/solving-the-cardano-node-huge-memory-usage-done/67032/37
https://forum.cardano.org/t/no-more-missed-slots-during-epoch-after-changing-one-setting/67924/20

My BP is running on a Contabo VM (VPS M), 6 cores, 16GB RAM, 400GB SSD hard drive and 400 Mbit/s, hosted in Germany. My 2 nodes are running on two VMs, with specifications
4 vCPU cores, 8GB RAM with a 10GB swap setup, 200GB SSD hard drive and 200 Mbit/s. My stake pool was prepared following the CoinCashew tutorial.
Does anyone know what I am doing wrong? Thanks so much, Simon

What does your current mainnet config file look like? Specifically wondering about the tracemempool settings for relays and BP.

I have read all those links too and tried many different things.  I still get some missed slots.
The things I have found:
-I0 (Default garbage collector with idle garbage collection off):
With this set I don't get missed slots at all for many hours and then eventually the garbage collector has to run and copy a lot of memory and then I get many missed slots all at once.
-I0.3 -Iw600 (Default garbage collector with regular collector sweeps with minimum 10mins between sweeps when processor idle > 0.3 secs)
This results in few missed slots which occur when the garbage collector runs.  However, because it is done more regularly the amount of memory copying is less and it takes less time so there are less missed slots each time.  But for my setup there were still a couple of missed slots every 10 mins when the GC ran.
--nonmoving-gc
I still get occasional missed slots.
Memory use seems to gradually increase over time and the node eventually uses all available RAM 16G and starts using swap.  After running 20hrs rts_gc_peak_megabytes_allocated is 24G which seems excessive.  Node appears to be running OK with almost no missed slots (4 in 20hrs).
If you run a small pool with limited processor power/speed then one option is to do the following:
Work out when your allocated slots are by running cncli-leaderlog ahead of time.  Then plan to restart your block producer cardano-node service 20 minutes before you are due to produce your block.  This way you can be sure your memory is fresh and garbage collection won't be necessary for a while just at the time when you are due to produce your block.
Overall, throwing faster hardware at the problem is an easy fix.  Faster processor means memory copying is quicker and garbage collection takes less time so missed slots are eliminated.
Update 2021-12-21:
After lots of testing I have concluded that the only RTS option which stops my node from missing slot leader checks is --nonmoving-gc.  However the problem with this setting is that memory is never released back to the OS with GHC version 8.10.7.  Unfortunately we need to wait until the cardano-node is able to be compiled using GHC version later than 9.2.x
What I currently use is:
+RTS -N --nonmoving-gc -RTS

As I understand things, the other settings compiled in (set by IOG in the source code) are also enabled.  These include: "-I0 -A16m".  You can check what your binary has with:
cardano-node +RTS --info

The output for my version currently is:

("Flag -with-rtsopts", "-T -I0 -A16m -N2 --disable-delayed-os-memory-return")

Then I restart cardano-node every few days at a convenient time between block production.
Or check your memory usage periodically with:
free

And restart cardano-node when you get close to exhausting your RAM, or after this but before too much swap is used.
If you just let cardano-node keep running using the nonmoving-gc then eventually all the RAM and swap is used and the OS kills the process using its out of memory reaper.  I believe this is because GHC version 8.10.7 doesn't return the collected memory to the OS.
Addition 2021-12-21:
OK now I am not sure about the last bit.  Memory is eventually returned to the OS when using nonmoving-gc.  Here are some outputs of 'free' while running continuously with:
'+RTS -C0 -N -I0 --nonmoving-gc -RTS'
Tue 21 Dec 2021 10:04:57
               total        used        free      shared  buff/cache   available
Mem:        16393504    15851756      161420          20      380328      262232
Swap:       17039352    13271360     3767992

Tue 21 Dec 2021 22:02:44
               total        used        free      shared  buff/cache   available
Mem:        16393504    15325260      648972          20      419272      786832
Swap:       17039352    11186532     5852820

Note that 12hrs has elapsed and RAM and Swap usage has reduced a little.

Thanks so much for your reply and for all the research

Indeed, adding cardano-node +RTS -N -H3G -qg -qb --nonmoving-gc -RTS run ..... to the startBlockProducingNode.sh file seems to have solved the issue. I've now been running for close to 24 hours with zero missed slot leader checks. Thanks once again, Simon

The concern I have is that memory usage seems to progressively increase.  After running 24hrs with "-N -H3G -qg -qb --nonmoving-gc" I have no missed slot leader checks but command "free" shows RAM used 15G, swap used 5G and metric rts_gc_peak_megabytes_allocated is 20G.  So I am concerned about the garbage collection / memory allocation.  I don't think it should be this high.

Yes, I'm seeing similar stats on my BP

Your relays are under the recommended memory specifications that is current 12GB of RAM for cardano-node. This might or might not be the root cause.

Thanks so much for your reply

I am sorry to tell you this, but from what I saw (other people complaining about the same thing), the Block Producers hosted at Contabo have a lot of missed slot leader checks. This is most likely because of the over-provisioned cpu cores. Missed slot leader checks are happening when the CPU is busy doing other tasks and does not have enough time to check each slot (each second) if it should mint a block or not.
Also from my experience on my own block producer on mainnet (because on testnet I do not have any missed slots, even on epochs transitions), using any other RTS option than -N will not improve this metric. Using all the CPU cores is the only option that really helps here.
Most of the missed slot leader checks happen when the cardano-node service is doing a snapshot of the ledger on the disk. This happens once every hour (if I'm not mistaking) by default. You can change this behavior by adding the "SnapshotInterval" setting in your mainnet-config.json file and setting a larger value. for example:
  "SnapshotInterval": 86400,

for one snapshot every 24 hours. This will reduce a lot the missed slot leader checks. The downside is probably a longer start time of the service, but from my observation and calculations, it is a matter of a few extra seconds, probably under 10 seconds, so it is negligible. I am using this in my config, exactly as above, and I only have 2 missed slot leader checks every 24 hours. Before adding it, I had 2 every hour, so it is obvious what made the difference. But my BP has 8 CPU Cores and 24 GB RAM, on Contabo you will still probably have some missed slot leader checks, but this should decrease. If it does not decrease a lot, you might want to find a new hosting for your Block Producer, if you thing it might cause you missed blocks.

I am running on bare metal.  With "+RTS -N -RTS" I get a few missed slots.  These seem to be caused when the haskell garbage collector runs and maybe also, as you say, when snapshots happen.  However, with "+RTS -N --nonmoving-gc -RTS" I get no missed slots except at epoch transition.  Though using the nonmoving-gc increases memory usage and I need to restart the node occasionally.

Yes, running on a bare metal is different than running on a VM, especially at the above hosting company.
Correct, --nonmoving-gc should increase memory usage and should help on a machine with lots of RAM.
You should restart the node ocasionally anyway, from my experience on testnet, after a few weeks of running the nodes without restart, the blocks are ghosted. I am now restarting all the nodes after 2 weeks or sooner.

Interested about the ghosted blocks you see on testnet:  What causes the ghosted blocks?  Do you think your node is not keeping up with mempool transactions thereby creating a block with transactions already executed so other nodes reject the block???

No, the node was keeping up with the blocks and transactions in mempool (I assume), but the blocks were not being propagated quickly to the network (I assume). Some of them were being propagated, but most of them not. I did not investigate further.
Restarting the relay fixed the issue, and since then I am always restarting the nodes from time to time, as I wrote, and it never happened again.

You miss slot leader check when CPU is busy with something else. Remember slot is 1 sec so each sec (slot) the BP needs to check if its leader. Now you always know when you forge the block before epoch but that is not the case for the node. It has to check because there could be slot battles.
So is your Contabo VM having dedicated CPU? the check has to finish within that sec else the slot is missed.
Is this a problem? if you are not forging block then not that much. But in general its always best to not have too many missed slot except during the epoch end which is a known problem.
Also note that if you are using GHC options which trigger garbage collection etc then sometimes and more regularly you will miss slots. restart and Watch for 24 hours and see when the first slots are missed and how regular they are.
There is no good number for missed slots but main thing is you should not miss the slot when you are forging block

Thanks so much for your reply

RAM 16GB may not be sufficient when the network is busy. If +RTS ... -RTS doesn't help, you can try setting "TraceMempool": false in the mainnet-config.json file. This will give you some extra free space in RAM.

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


text:
How to fix Duplicate instance declaration error in byron-spec-ledger package?
I'm trying to add cardano-wallet-core as a dependency to my Haskell project, so I can use the servant client. But I get this error when cabal builds the byron-spec-ledger package:
[ 6 of 16] Compiling Byron.Spec.Ledger.Update ( src/Byron/Spec/Ledger/Update.hs, dist/build/Byron/Spec/Ledger/Update.o, dist/build/Byron/Spec/Ledger/Update.dyn_o )

src/Byron/Spec/Ledger/Update.hs:236:10: error:
    Duplicate instance declarations:
      instance Hashable a => Hashable (Set a)
        -- Defined at src/Byron/Spec/Ledger/Update.hs:236:10
      instance Hashable v => Hashable (Set v)
        -- Defined in `hashable-1.3.4.1:Data.Hashable.Class'
    |
236 | instance Hashable a => Hashable (Set a) where
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build byron-spec-ledger-0.1.0.0 (which is required by

My cabal.project looks like this: https://pastebin.com/swdJWBAK
Using GHC 8.10.4.

Thank you, this worked for me as well.

The issue was that in hashable-1.3.4.0, the instance was added, and it was also defined in the byron-spec-ledger package.
Adding this constraint to my cabal.project file solved the issue:
constraints:
    hashable < 1.3.4.0


text:
EKG metrics interpretation and documentation
Searched docs.cardano.org, github, forum.cardano.org and the rest of the internet for some type of documentation that describes each of the items in the EKG metrics, but couldn't find anything.  I understand about half the metrics, but there are some new ones with version 1.31.0 of whose meaning I don't know. Would definitely like to know what these mean
cardano_node_metrics_blockfetchclient_lateblocks
cardano_node_metrics_blockfetchclient_blockdelay_s
cardano_node_metrics_blockfetchclient_blockdelay_cdfOne
cardano_node_metrics_blockfetchclient_blockdelay_cdfFive

Wow, I would really like to see that documentation!

Since the current network settings define one slot per second and each block that reaches a node was created for a specific slot, the local node can determine how "on time" the block arrived.
Let's first define a common understanding of the block distribution process before we get into the meaning of these new metrics:
Each block-generating node, when elected as a leader for a slot, has a time budget of one second to validate the accumulated transactions and scripts, generate the block, and broadcast it.
This is usually done via its relays, which also validate the block, adopt it, and then re-offer it to its peers for download.
After 2 to possibly several hops, the block will reach the block creator destined as leader for one of the upcoming slots. This can already be the next second, but on average it happens every 20 seconds according to current parameters.
Each node in this delivery chain will try to complete its part of the work as quickly as possible. Larger blocks with multiple transactions mean more work and therefore longer validation and transmission times. In addition, there are certain phases in each epoch where each node performs additional tasks in the background, such as the epoch switch itself and the reward calculation which currently starts 48 hours after each epoch switch and is then performed in smaller sub-steps for about 18-22 hours. This background work currently also has a noticeable influence on the processing and distribution times of the blocks, as can be seen in the following example graphics.
All these new metrics are derived from the first time a new block for a given slot reached the node.
_blockdelay_s
is the delay between for which slot the last block received was produced and when it actually reached the local node (without the additional time required to validate it localy). This value will get updated the next time a new block for a new slot reaches the local node.
_lateblocks
counting blocks that arrived more than 5s after they where supposed to have been forged. Ideally the block should arrive within the same slot = second. Larger values mean a certain risk for the block producer to not see the very last produced block in time, and build their own block based on the second last produced block, which means the following producer and whole chain may have to solve a fork. So this metric idealy should always remain at 0. A relative high growth compared to other nodes means this node has some issues to get the blocks in time.
_blockdelay_cdfOne  _blockdelay_cdfThree  _blockdelay_cdfFive
These three metrics are averages based on the blocks received in the last 6 hours. So they also have a corresponding creeping progression.
Shown are how many blocks arrived within one, three and five seconds. Ideally, all blocks should arrive within one second = slot. You can see in the following graphics that this is largely the case, but especially in the reward calculation window it drops very clearly, because of the background activities mentioned above.
The three-second value is less affected by this. And once again significantly more blocks reach the node within 5 seconds. For the security specification of the Ouroboros Praos protocol, this 5-second value is the important and critical one. It is important that the vast majority of all blocks (95%) have reached every other block creator in the global network within 3 or max 5 seconds.
Some example graphs
The first graph shows _blockdelay_cdfOne for 3 different nodes, together with the processed block sizes (pink) in a timerange of 20 days = 5 epochs.
85-95% of all blocks arrive within one second.

The drop 48h after each epoch switch because of the reward calculation load is clearly visible, lowering the receive-within-1sec-rate to 5-15%
Also visible the relation of large-block phases delaying the block propagation and lowering the 1sec-rate.
The following graph shows _blockdelay_cdfThree and _blockdelay_cdfFive for the same 20-day time range:

We see only a slight effect on the 3-second and almost no effect on the 5-second metric.
The following graph zooms in to a couple of minutes, and shows the direct relation of individual block sizes (pink), and the resulting _blockdelay_s

Last but not least the new node metrics also show cardano_node_metrics_forks_int
We see a slowly but steadily growing number of forks. A natural and expected thing in Ouroboros proability base decentralised slot leader election. But we also see the growth rate increasing in the reward-calculation window, which means this is caused by extended propagation delays and certain blocks produced without having received the very last block in time.

Update 2022-01-11
Since pools started upgrading to node version 1.33, the previously described 48h window for the reward calculation becomes re-scheduled to cover almost the whole epoch. This will result in less impact on the 48h window.
The following graphs shows this together with a second effect we currently see reducing the CDF1 ratio: more large blocks.
At the moment of this writing, ~ 64% of all nodes was updated to v 1.33

Note: Starting with node version 1.33.x, the behavior in the 48-hour window will improve significantly because the reward calculation is implemented differently.

A huge "thank you" for the detailed explanation.   8 hours after restarting the bp node with version 1.33.0, the numbers aren't the greatest cardano_node_metrics_blockfetchclient_blockdelay_cdfThree 0.9925925925925926
cardano_node_metrics_blockfetchclient_blockdelay_cdfOne 0.275
cardano_node_metrics_blockfetchclient_lateblocks 4
cardano_node_metrics_blockfetchclient_blockdelay_cdfFive 0.9972222222222222
cardano_node_metrics_blockfetchclient_blockdelay_s 1.75081688

Fantastic answer.

@OmahaCardanoPool I just updated the answer, to explain the newly introduced behaviour and effect of node version 1.33
At the timestamp of your comment, my nodes had CDF1 ratios between 0.3 and 0.6
so your 0.275 is not a real bad value for that specific moment.

@Markus-CLIO1  Since the Feb 7 restart of the BP node, there have been 101 late blocks.  Reason to be concerned?   cardano_node_metrics_blockfetchclient_lateblocks 101

This sounds like a normal value.


text:
Plutus starter cabal build issue
Running the instructions at https://github.com/input-output-hk/plutus-starter#readme
After opening the container in VSCode, and attempting to run the following in the terminal.
[devcontainer]$ cabal build
Killed
[devcontainer]$ cabal update
Killed

Container is hosted on an M1 Macbook Air with 4GB allocated to docker.
Admittedly, I am new to Haskell and Cardano, so it's not yet apparent to me if this may be a resources issue or something in the plutus starter project.

Have exact same issue on M1 Pro.

I believe there are some compatibility problems with M1s and Docker. It might be worth trying to run Cabal through nix-shell instead.

Continuing to work through nix-shell on an M1 system, but I'll accept this answer if I get it going.

Yesterday i found out that if you do a cabal build with limited amount of cpus cabal build --jobs=1 you get quite far but after building for like 2 hours ... it gets killed after all ... seems to be a docker issue with ressource management i think!


text:
What are the differences between policyId & currencySymbol and assetName & tokenName?
In the Plutus docs, there are references to currencySymbol and tokenName. In the cardano docs there are references to policyId and assetName. Are policyId and currencySymbol the same thing? Are tokenName and assetName the same thing? If they are the same, when is one used instead of the other?

They represent the same from my understanding too. There are a few terms that are associated with the "Tokens" in Cardano. They are

 1. Currency Symbol - Hexadecimal Number - PolicyId
 2. Token Name      - Text               - AssetName

The currency symbol is kept in hexadecimal form since it is actually the signed hash of minting policy.
The policy generated from the mining policy is the current Symbol of the Native Asset. For ADA both Currency Symbol and Token Name are "". I guess the difference has accommodated the manner in which it is being used. "CurrencySymbol" and "TokenName" are primarily used in Plutus Documentation and "PolicyId" and "assetName" are used in Native Token minting through cardano-cli.

Yes, I think thats also true. There is also a type called AssetClass, which is the combination of the CurrencySymbol and A TokenName. The AssetClass can also hold a Value, which is basically an Int. Source: https://marlowe-playground-staging.plutus.aws.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Value.html#g:3

Be careful, I don't what do you mean by Text but if you are referring to the Haskell type Text, it has nothing to do with Tokens. It is used in Haskell outside of Plutus


text:
Can you go from pkh -> address using the CLI?
Let's say I have a public key hash, is it possible to get the address corresponding to that hash using the CLI?

An address is made of of 3 components: Network + Payment Credentials/ Validator Credentials + Optional Staking Credentials (can be StakeValidator Hash or StakingKeys).

No, as that would sort of defeat the purpose of having a key hash in the first place (Hashing is, by definition, a one-way operation). Also, addresses can be built using different combinations of payment and staking keys, so a single key hash can be indicative of a key with ownership over multiple addresses.

In the question it is assumed that we have an pubkeyhash. If we look at the defenition of an address it consists of a credential and maybe a stakingcredential. The former is in the case of a normal shelley address given by a pubkeyHash. If it is a script, then its the validator hash. So it is definitly possible to construct an address from a pubkeyhash. What is not possible is deriving the pubkey from the pubkeyhash (as you state). See https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger-Address.html#t:Address

You might want to investigate cardano-serialization-lib or cardano-addresses for this.
echo addr1gqtnpvdhqrtpd4g424fcaq7k0ufuzyadt7djygf8qdyzevuph3wczvf2dwyx5u | ./cardano-address address inspect

{
"stake_reference": "by pointer",
"spending_key_hash_bech32": "addr_vkh1zuctrdcq6ctd29242w8g84nlz0q38t2lnv3zzfcrfqktx0c9tzp",
"pointer": {
    "slot_num": 24157,
    "output_index": 42,
    "transaction_index": 177
},
"address_style": "Shelley",
"spending_key_hash": "1730b1b700d616d51555538e83d67f13c113ad5f9b22212703482cb3",
"network_tag": 0 }

But that is a movement in an opposite direction, getting a pkh from address.


text:
How to create cardano address using cardano-wallet API and hd wallet derivation path
Developing a wallet service for cardano using cardano-walletapi.
Having hard time aligning my existing HD wallet knowledge w/ cardano-wallet.
Need to create an address for an account [index 33] using HD derivation path.
etc. m / purpose' / coin_type' / account' / change / address_index
such as m/1852/1815/11H/1/1/33 where account is 11, change is 1 and address_index is 33
using cardano-wallet API
How can I do that?

cardano-wallets purpose is to allow easily manage your funds without getting too deep into certain complexity of deciding how to derive keys and addresses.
to solve it for you there is a cardano-addresses project that gives you much greater control over the key derivation paths.

medium blog on cardano-wallet answers my question.
I've downloaded the latest release from https://github.com/input-output-hk/cardano-wallet/releases
Following command creates an address public and private key files address.prv and address.pub

cat $KEYS/root.prv
| cardano-wallet key child 1852H/1815H/123H/0/0
| tee $KEYS/address.prv
| cardano-wallet key public --with-chain-code > $KEYS/address.pub

1852H/1815H/123H/0/0 is derivation path purpose, coin_type, account_index, role, address_index
1825 is purpose cardano network
1815 is Ada Lovelace's birth year and ADA coin's code
123H is account index
0 is role. 0 is for change, 1 is for staking etc...
H means hardened
Following command generates a payment address. from address's public key.

cat $KEYS/address.pub | cardano-address address payment
--network-tag 1 > $KEYS/address.pay


text:
How can I pinpoint a specific UTxO using ContractModel
I'm trying to create a contract where a TxOutRef is supplied to it which tells it a specific UTxO to use in the contract. This seemed fine until I started working with ContractModel. I can't find any way to pass on information about UTxOs that I create. nextState allows me to update the state, but I can't get any contract related info there. perform lets me get info from the contracts, but doesn't let me update the state.

Hopefully I'm understanding your question correctly. I'm hearing two things here:
How do I include a specific UTxO in a transaction required by a script?
Here is an example of off-chain code including an arbitrary UTxO to create "one shot", single issued currency.
In this case it doesn't matter which UTxO it is, as long as the TxOutRef (txOutRef) referenced in the OneShotCurrency (thisCurrency) is spent with the minting transaction:
    let theCurrency = mkCurrency txOutRef amounts
        ...
        mintTx      = Constraints.mustSpendPubKeyOutput txOutRef
                        <> Constraints.mustMintValue (mintedValue theCurrency)

How do I to choose a specific UTxO "that I created?"
One way is how the oracle is grabbed from the ContractHandle in the Oracle example. The Oracle value is stored in the ContractHandle monad as a Last and can be grabbed inside the runtime context with the getOracle function.
The logic for actually finding the UTxO is the the findOracle function here.
An alternative approach is in the Uniswap example. An NFT is created with Currency.mintContract and then immediately used as the NFT (c) for the Factory Datum here:
tx   = mustPayToTheScript (Factory []) $ unitValue c

This approach avoids managing the UTxO directly.


text:
How Do I include MP3/Mp4s into my smart contract?
How Do I include MP3/Mp4 capabilities in my smart contract?
Im interested in minting songs and short videos as CNFTs but I do not see any information online what so ever about how this can be done.  There are CNFT projects such as music box who seem to have accomplished this in a short format. Can anyone give me some guidance?

You would never include the actual mp3/mp4 in your smart contract. That's a lot of space (probably more than could ever fit on the chain) and unnecessary.
Instead, you could create a hash of the clip and attach that hash as metadata of an NFT--thus showing unique ownership. That's how NFTs for images/pictures work typically.
How you store the mp3/mp4 is up to you. You could host it on a website, or consider IPFS (InterPlanetary File System) for a bit more safety.

Thank you. I have been using pinata.cloud for an IPFS but it has trouble rendering even a small file. Do you have any IPFS's you'd recommend?

https://ipfs.io/ or you can use the Blockfrost API: https://docs.blockfrost.io/#tag/IPFS-Add

So generally the media is stored somewhere else and you just link the NFT to it with a URL. If you didn't do this, the blockchain would grow astronomically.


text:
Can you stake stablecoins such as Djed?
Can or will you be able to stake Cardano stablecoins in stake pools for rewards, such as Djed?

Let's first ask ourselves,  what does staking really mean?
The purpose of the staking mechanism currently implemented in Ouroboros is primarily to incentivize honest real-time consensus on the Cardano Settlement Layer (CSL). However, the CSL is merely the first layer of a much larger ecosystem that facilitates  the communication of globally interconnected DApps, also known as the Cardano Computational Layer, or CCL.
The CSL is the backbone and heartbeat of the system, optimizing for security and correctness over throughput, and was thus built first in a highly formal and concerted effort by for-profit companies. And so the protocol and staking rules are imbued with a level of rigidness that is necessary for a global base-layer.
The CCL can and will be a collection of diverse Hydra channels with unique consensus and ledger mechanisms. At first it will be a Cambrian explosion of  channels/operators, all experimenting and competing with each other to establish network standards. Over time it evolves into a more stable and self-governing entity, eventually settling into some global equilibrium.
All of this is to say that the current implementation of staking on the CSL will be tinkered, built upon, and deployed in a vast array of ways both inside and outside the CCL. Sundaeswap's recent ISPO and World Mobile's Earth Nodes are examples of this, but are still only scratching the surface.
In principle, anything can be "staked" as long as the underlying incentive scheme is sound/sustainable.

No.
In theory you could add stability to a PoS blockchain but staking tokens other than the core native token, but the underlying network has no concept of how valuable a token is. It can’t tell the difference between Djed and any old token you minted a billion of yourself.
In Cardano, PoS only works because ADA is valuable to someone. If the price went to zero, then the consensus mechanism would fail as well.

There are talks about allowing fees to be paid with non-ADA tokens though. See Babel Fees: https://iohk.io/en/blog/posts/2021/02/25/babel-fees/


text:
Problem when running cardano node on aws
i have troubles running the cardano node on aws.
After downloading the node config files and running the node, i get this failure:
AesonException "Error in $: parsing PartialNodeConfiguration failed, expected Object, but encountered String"
cardano-node: Aeson exception:
Error in $: parsing PartialNodeConfiguration failed, expected Object, but encountered String
Could someone help me how to solve that?
Thanks!

Few questions: Are you following a tutorial? Is this for testnet or mainnet? Did you change the config files any after you downloaded them? I believe there is an issue in one of your config files's syntax.

Additional to Anton questions, what is the command you're using to run the node?

I am following the official tutorial. I am running the mainnet. Here are the files:
curl -O -J http://hydra.iohk.io/build/8111119/download/1/mainnet-topology.json
curl -O -J http://hydra.iohk.io/build/8111119/download/1/mainnet-shelley-genesis.json
curl -O -J http://hydra.iohk.io/build/8111119/download/1/mainnet-config.json
curl -O -J http://hydra.iohk.io/build/8111119/download/1/mainnet-byron-genesis.json
curl -O -J http://hydra.iohk.io/build/8111119/download/1/mainnet-alonzo-genesis.json

Here is the command to run the node:
cardano-node run
--topology /home/ec2-user/cardano/mainnet-topology.json
--database-path /home/ec2-user/cardano/db
--socket-path /home/ec2-user/cardano/db/node.socket
--host-addr 127.0.0.1
--port 3001
--config /home/ec2-user/cardano/mainnet-config.json

I have also tried to download the same files as the tutorial but i become als the same failure:curl -O -J http://hydra.iohk.io/build/7370192/download/1/mainnet-config.json
curl -O -J http://hydra.iohk.io/build/7370192/download/1/mainnet-byron-genesis.json
curl -O -J http://hydra.iohk.io/build/7370192/download/1/mainnet-shelley-genesis.json
curl -O -J http://hydra.iohk.io/build/7370192/download/1/mainnet-alonzo-genesis.json
curl -O -J http://hydra.iohk.io/build/7370192/download/1/mainnet-topology.json

And as another information, i have successfully run the node locally on my mac machine with these configuration Files. But i have a trouble just on the aws ec2 linux instance!

Yes, i got the solution. When downloading the files directly using curl or wget command, i go the parsing error.
So i created the files manually using the touch command and inserted the content of the configuration with copy paste using vim linux command. It looks strange but it works like this.
Also i have done the same thing on my mac machine.


text:
How to obtain PubKeyHash from Address ShelleyAddr
Is there a way to do this programmatically? I have an
Address ShelleyAddr
obtained from
deserialiseFromBech32 AsShelleyAddress
and need its
Plutus.V1.Ledger.Crypto.PubKeyHash

There is now the function shelleyPayAddrToPlutusPubKHash in cardano-api which returns Maybe PubKeyHash because in the case of a script credential there is no corresponding public key hash.

I cannot find shelleyPayAddrToPlutusPubKHash. How exactly do I import it?

In cabal.project, what tag hash do I use for source-repository-package   type: git   location: https://github.com/input-output-hk/cardano-node.git ?

This compiles with a recent version of cardano-node and plutus:
import Plutus.V1.Ledger.Api (PubKeyHash)
import Cardano.Ledger.Alonzo.TxInfo (transKeyHash)
import Cardano.Api (ShelleyAddr)
import Cardano.Api.Shelley (Address (ShelleyAddress))
import Cardano.Ledger.Shelley.API (Credential (KeyHashObj, ScriptHashObj))

addrToPkh :: Address ShelleyAddr -> PubKeyHash
addrToPkh (ShelleyAddress net (ScriptHashObj sh) sr) = transKeyHash sh
addrToPkh (ShelleyAddress net (KeyHashObj kh) sr) = transKeyHash kh

Is there such a thing as an AlonzoAddr (via deserialiseFromBech32 AsAlonzoAddress)? I am only using ShellyAddr because that's what I found in the API.

cabal build is giving me: unknown package: cardano-ledger-shelley. Not sure what to do.

@Kwaggy: AlonzoAddr is fine and to make it compile you need to add cardano-ledger-shelley to your code's .cabal file in the build-depends section and maybe ensure you are having the https://github.com/input-output-hk/cardano-ledger-specs as a source-repository-package in cabal.project (depends a bit on your workflow).

@Sebastian Nagel: Where do I find AlonzoAddr?

@insitu: For recent version of cardano-node, I downloaded pre-compiled executable from https://docs.cardano.org/getting-started/installing-the-cardano-node and parked the unzipped in my root dir. How do I teach cabal about it, such that .cabal file is happy with having cardano-ledger-shelley in its build-depends section?

@Kwaggy: There is no AlonzoAddr as far as I know. You might expect one as you read ShelleyAddr, but in fact the "alonzo era is a shelley era", so ShelleyAddr is just fine.
To get the cardano-ledger-shelley you do not need the pre-compiled executable, but need to adapt the cabal.project file, e.g. like this https://github.com/input-output-hk/hydra-poc/blob/master/cabal.project#L85-L112 -> cardano-ledger-shelley is in the eras/shelley/impl directory of the ledger specs repo. You can also ask in the #ask-hydra channel on the IOG Discord for more help: https://discord.gg/y5kfwHtm

@SebastianNagel: I am running into cabal build error: Failed to build plutus-chain-index-0.1.0.0., and cabal clean does not help.

@SebastianNagel: Please see https://gist.github.com/paul-outlaw/130764aa1da5cb2c93c5be3c550a19e6

@Kwaggy Sorry, I do not really understand your question: Cabal dependencies require source code, either from a package or from a git repository. BTW, I have commented your gist, seems like your SHA1 are not correctly set which would explain the compilation error you see.


text:
Is It possible to stake an nft on chain
Is there a way I can use smart contracts to stake nfts and back them with ada tokens. Similar to staking ada except also holding the nft in like a gallery or something.

No, this is because there is no way to know how much Ada the NFT is worth as far as the staking protocol is concerned.
Ada staking works with a 1 Ada = 1 Vote in deciding who mints the next block, so having 1 NFT = XXX Ada would be impossible to know without an Oracle of some kind.

"Staking NFT's backed by ADA tokens" is almost tautological. You can already think of your key pairs as non-fungible assets that are created and get "assigned" ADA (and other assets) when said ADA is deposited into the associated address.
However, the above is only true for main chain consensus. There is no reason that some other blockchain (or perhaps sidechain???) with a shelley-like consensus mechanism can't have different staking rules that include staking NFT's. In fact, I'd bet future developments in E-governance will result in some kind of proof-of-authority mechanism facilitated by NFTs.


text:
Risks of having a figurehead
What risks are there for Cardano when there's such a prominent figurehead for the protocol? How much power does Charles have over the system? Has the community/protocol decided how it would behave in the event of Charles' death or capture by malicious agents?
An extreme scenario I'm imagining (which I hope will never happen) is that Charles is captured and tortured until the community adopts changes to the protocol which would not have otherwise been adopted. Is this possible? If so, is there a plan for this scenario?

Wild as your examples are, lets indulge them.
Charles himself has explicitly stated multiple times that Cardano is way beyond him at this point. If something terrible were to happen to him, it may shake the price of ADA a bit, but it wouldn't come close to killing Cardano.
In a similar statement ~2 years ago or so, Charles also mentioned that to take out the current Cardano mainchain there would have to be targeted assassinations all over the world the likes of which we'd never seen before. And even then, the code is still out there and open source. That's the main reason it won't die. That even if all the core developers, SPOs, IOG, CF, Emurgo, and Charles himself all went under,
"Someone else will take the code, fork it, build it, and release it" - Charles Hoskinson

yeah, that's what I remember hearing on his podcasts/AMAs too but I figured I'd ask just in case I misremembered or misunderstood.


text:
How to generate the address of a plutus script using Cardano Serialization Lib?
I am sending some smart contracts using the Cardano Serialization Lib and the nami wallet for signing, everything works fine, but I am not able to get the script address of a Plutus Script. I have managed it out  using cardano-cli command 'address build'. But I think there most be some equivalent in Cardano Serialization Lib, is it posible? I tried with the method Address.from_bytes() using the hex-decoded CBOR from the plutus script but it says it is not the right kind of CBOR.

Here is a javascript snippet that uses the cardano-serialization-lib to go from CBORHex to addr_test...
const {
  ScriptHash,
  NetworkInfo,
  EnterpriseAddress,
  StakeCredential
} = require("@emurgo/cardano-serialization-lib-nodejs")

...

const addrFromHash = (hash) => {
  const scripthash = ScriptHash.from_bytes(Buffer.from(hash,"hex"));
  const cred = StakeCredential.from_scripthash(scripthash);
  const networkId = NetworkInfo.testnet().network_id();
  const baseAddr = EnterpriseAddress.new(networkId, cred);
  const addr = baseAddr.to_address();
  const addrBech32 = addr.to_bech32();
  return addrBech32;
}

Plutus-Core script bytes are wrapped twice in a CBOR bytearray.
Use the following steps to calculate the script address:

unwrap one layer of CBOR
prepend a byte representing the PlutusScript version: 0x01 for PlutusScriptV1, 0x02 for PlutusScriptV2
calculate the 28-byte (224-bit) blake2b digest to get the payment part of the address
form the full script address using CIP19 (so for script addresses without a staking part simply prepend 0x70 to the digest)
encode the script address bytes using bech32 ("addr_test" prefix for testnet, "addr" prefix for mainnet)

The pseudo code of these steps would look as follows:
encodeBech32("addr_test", prepend(hashBlake2b224(prepend(unwrapCborBytes(hexToBytes(cborHex)), 0x01)), 0x70))

As an example consider the commonly used AlwaysSucceeds script. It has the following hexadecimal representation: "4e4d01000033222220051200120011".

Unwrapping one layer of CBOR bytearray would give: "4d01000033222220051200120011".
Prepend 0x01: "014d01000033222220051200120011"
Blake2b 28-byte digest: "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"
Prepend 0x70: "7067f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"
Bech32 encoding of testnet address: "addr_test1wpnlxv2xv9a9ucvnvzqakwepzl9ltx7jzgm53av2e9ncv4sysemm8"

Don't ask me why Plutus-Core scripts are wrapped twice in CBOR, and then unwrapped once to calculate the address. Some smart guys somewhere must have a good reason.
If you'd like to do these calculations in Javascript without some complicated Rust/Haskell dependencies check out the Helios Lang library. The library is UNLICENSEd so you can copy the relevant functionality as you please.

Script addresses are basically just addresses that uses the key hash instead of payment key hash, see the CIP19: Cardano Addresses.
However, the cardano-serialization-lib does not support fee estimation for these, but Alessandro from Nami has a patch for that.


text:
Retrieve only digit from TokenName and use onchain
How can I make the following function to retrieve only digit portion from the TokenName and use it on chain?
For example I want to retrieve the number 123 from "AAA123" (TokenName)
{-# INLINABLE getIdFromTokenName #-}
getIdFromTokenName :: TokenName -> Integer
getIdFromTokenName tn = ...

and I have the check function for state machine, as follows:
{-# INLINABLE check #-}
check :: Game -> GameDatum -> GameRedeemer -> ScriptContext -> Bool
check g _ (Buy tn) _ = ix > 0 && gMaxItems g >= ix
                            where
                                ix = getIdFromTokenName tn

given the request on way would be the following:
getIdFromTokenName :: TokenName -> Integer
getIdFromTokenName tn = getIdFromStr 0 $ (BS8.unpack . unTokenName) tn -- BS8.unpack :: ByteString -> String
  where
    getIdFromStr :: Integer -> String -> Integer
    getIdFromStr accumulatedNum strName =
      case strName of
        (char: restStr) ->
          case maybeIntegerFormChar char of
            Nothing  -> getIdFromStr accumulatedNum restStr
            Just int -> getIdFromStr (10 * accumulatedNum + int) restStr
        _               -> accumulatedNum

    maybeIntegerFormChar :: Char -> Maybe Integer
    maybeIntegerFormChar ch =
      case ch of
        '0' -> Just 0
        '1' -> Just 1
        '2' -> Just 2
        '3' -> Just 3
        '4' -> Just 4
        '5' -> Just 5
        '6' -> Just 6
        '7' -> Just 7
        '8' -> Just 8
        '9' -> Just 9
        _   -> Nothing

this should satisfy the codition of getting out 123 from "AAA123" but note that "AAA123BB45" will result in 12345

I like the addition of maybe, but would like to add that his might increase the script size. Another option to still be on the safe side is to first check the policy id and then use the unsafe getIdFromStr function. If the minting of the names is federated the occurrence of the edge case is not a problem.

Token name is a Bytestring therefore it has to handle like that. I am learning and my attempt at extracting the integer value is like this:-
import Data.Char ( ord )
import Data.ByteString.Char8 (ByteString, unpack,pack)

getIdFromTokenName :: ByteString -> Integer
getIdFromTokenName tn = numbers (reverse (unpack tn)) 0 1

numbers :: String->Integer->Integer -> Integer
numbers [] x y = x
numbers (l:ls) x y = if ord l >= 48 && ord l <= 57
    then numbers ls ((toInteger (ord l) - 48)* y + x) (y*10)
    else numbers ls x y

I used pack unpacked from the module imported above in ghci it was working like this
*Main> getIdFromTokenName (pack "NUM123")
123

This is not a safe function to extract numbers and is also not the best method I feel. It's not checked in the Plutus setting also.


text:
How to create a project of many NFTs in one shot?
I have a collection of pictures, which I would like to list as NFTs on a popular NFT marketplace. I followed the official tutorial on Cardano developers website, however, the example shows the creation of just one NFT.
Does a repository, or some other source exist, which could guide me through the process of creation of multiple NFTs in one shot? I've seen one answer to my question but it seems to be not very convenient way when the number of NFTs to be minted is high (i.e. 100, 1000, 10000).
Best regards

The CIP25: NFT Metadata Standard allows you to specify multiple asset names, but keep in mind, you need to include the metadata in the transaction itself so you will never be able to list a high amount of this metadata, certainly not over a 100.
If you do not use the onchain metadata, but rather store your NFT metadata off-chain in the Cardano Foundation registry, you might be able to mint much more tokens in one shot.

Thanks for the info! Out of curiosity, how does it relate to storing metadata on IPFS system like Pinata or Blockfrost? Do I have to store it in the registry or can I use third party service like the ones mentioned?

At the moment, both off-chain and on-chain metadata are not stored on IPFS, just the "content" of the NFT.


text:
Most efficient way to monitor a wallet for transactions
I'd like to monitor the blockchain and react to when ada is deposited to my wallet. I'm curious about the most efficient way of going about this. For example, if I use the cardano-wallet api it has the route /wallets/{walletId}/transactions which I assume I could poll. Of course, this would require polling behavior, which is not as efficient as event-based architecture (ie. using a listener or callback).
Can anyone describe the current state of the art for watching a particular wallet for new transactions?

Does this answer your question? How can you listen to all incoming transactions of a wallet address?

Kind of. I'm more interested in a discussion on what the most efficient way to do it would be.

If you think about watching a local wallet, created on cardano-wallet, I do not think there is more efficient way than just pooling it in an interval.
If it is a wallet that does not use enterprise or mangled addresses, you can watch the chain from cardano-db-sync stack or a remote API provider such as blockfrost.io.
If using Blockfrost.io, I recommend using the websocket-link where you can create a WebSocket subscription.
In any of these implementation, make sure you account for possible roll-backs of the blockchain.

Does the chain roll-back?

Yes, several times a day.

Very interesting. Would you mind linking to any sort of writeup or documentation suggesting how to account for that?

It is a bit late for this, but if you have a cardano-db-sync and want to receive notifications you can use this solution.
It requires you to provide when deploying the schema the address to monitor and the number of blocks after which your application considers a transaction settled. The solution will take care of rollbacks and only notify through the PostgreSQL channel if the transaction passed the block's depth threshold.
If you just need to monitor chain rollback events you can use this one. which follows a similar approach of notifying using PostgreSQL channels.


text:
Does `AssetId` and `AssetClass` mean the same?
In the Plutus library, AssetId is defined in module Cardano.Api.Value as
data AssetId = AdaAssetId | AssetId !PolicyId !AssetName
while AssetClass is defined in module Plutus.V1.Ledger.Value as
newtype AssetClass = AssetClass { unAssetClass :: (CurrencySymbol, TokenName) }
, as of the time of writing this question.
Does AssetId and AssetClass have any difference in its meaning. What is the purpose of having two definitions?

Basically, they're the same:

AssetId: Actually, it's not part of Plutus Library. It's part of cardano-node and used mainly in native tokens, for example, when you run the following command, it displays your native tokens:
cardano-cli query utxo --address <address> --testnet-magic 1097911063

AssetClass: this is part of Plutus Library and you can use it in your plutus scripts.

The reason to have two definitions, it's because they're used in different tools.


text:
Shelley related: Wrong genesis file - cardano-node 1.31.0 - linux-x86_64 - ghc-8.10
i have a problem when running cardano-node 1.31.0 mainnet on an ec2 linux pn aws
I become the following error:
Shelley related: Wrong genesis file: the actual hash is "dec31b6d760b1ee8dc82d66eaa92fd492891f17db2565b666c43490a6cde72ab", but the expected genesis hash given in the node configuration file is "1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81"
I have tried the config files from the latest recommended build 8111119 and from the build mentioned in the official tutorial 7370192 but it doesn't work.
http://hydra.iohk.io/build/8111119/download/1/..
http://hydra.iohk.io/build/7370192/download/1/..
Which cardano node version is recommended to run on the mainnet on linux actually? And which config files should be run with it to be compatible?
Thanks a lot

Is it related to this question? https://cardano.stackexchange.com/questions/4567/problem-when-running-cardano-node-on-aws If not, can you please update your question including the command you are using.

The main config (mainnet-config or testnet-config) file contains the hash of the related genesis files:
  "AlonzoGenesisFile": "mainnet-alonzo-genesis.json",
  "AlonzoGenesisHash": "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874",
...
  "ByronGenesisFile": "mainnet-byron-genesis.json",
  "ByronGenesisHash": "5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb",
...
  "ShelleyGenesisFile": "mainnet-shelley-genesis.json",
  "ShelleyGenesisHash": "1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81",

This is to ensure that all the configurations are in sync.
It might have happenned that you either edited the shelley-genesis or that one is coming from a different batch of config files, and you've just updated the main one without updating the genesis files.
You could try downloading all config files from the same hydra build so that the hashes are correct, or edit the config file accordingly to contain your genesis file hashes, or delete that line ShelleyGenesisHash if you want to skip the hash checks (not recommended)

You have to make sure that your mainnet-shelley-genesis.json is exactly the one you downloaded from there. Adding even a single newline at the end of the file will change the hash. Opening it in an editor might do this, even if you do not change it yourself.

I know this is late but I hope someone will find this helpful in the future. After hours of troubleshooting I found out that using the command line and using wget or curl on the url http://hydra.iohk.io/build/7370192/download/1/
inside the directory your working with will download the config and genesis files with the correct hash. Hope this helps, Cheers.
eg:
wget https://hydra.iohk.io/build/13695229/download/1/testnet-config.json
wget https://hydra.iohk.io/build/13695229/download/1/testnet-byron-genesis.json
wget https://hydra.iohk.io/build/13695229/download/1/testnet-shelley-genesis.json
etc..


text:
Can I use my ADA at any time while they are staked into a pool or are they frozen?
Can I send my ADA to another wallet instantly or use them instantly for whatever reason I like while they are delegated(staked) into a pool in Yoroi Wallet or does it take time to undelegate them first etc? I don't mind losing rewards or the fee. I am just asking about the time needed.
Thank you in advance

Yes, there is no lock on your funds while they are delegated, therefore you are free to do with your Ada as you please. There is also no timing consideration either. One note with that, any rewards that you have earned will need to be withdrawn to be able to transfer/use them. Yoroi let's you do this with a click of a button.

Thank you very much for your response.
I have one more question. What does the "costs 2.50% +340" for example, mean?

That is how much of the total rewards the pool operator gets per epoch if the pool creates a block. So if a pool creates 1 block, the total rewards would be around 600ada. The pool gets 340 ada and then 2.5% of the remainder. This is to reward them for participating in running the network. If the pool made 3 blocks it would be about 1800 ads total rewards, the pool gets 340 ada and 2.5% of what is left. Everything else goes to the delegators. Hope that helps!

Yep it helped a lot. Thank you very much!!

One final question about Sundaeswap. Do you believe that it is better to stake your ADA in one of the winning pools in order to get SS rewards or keep them ready to swap directly when the SS launches? Does the pool rewards going to be the same proportionally with the amount that you will be able to swap at the lowest price or how this is going to work? Why should I stake my ADA for a few amount of SS rewards instead of trading them instantly for more SS?

I actually applied to be a SS pool (didn't win), but as of today, the details on this are unknown. I think it will really depend on what your goals are. If you stake with a SS pool, you get to keep your Ada and earn rewards.

Sorry to hear that Pal and thanks for your reply. Let's see what will happen.


text:
How to restore into Daedalus a wallet created with cardano-cli
I have created a wallet key pair using cardano-cli address key-gen.
Is there any way to restore this wallet on Yoroi or Daedalus visual interface?

The only way those wallets allow for importing wallets is via the mnemonic key phrase.
As far as I remember cardano-cli address key-gen does generate the keys right away.
So no, there's no way to import the keys generated in cardano cli into Daedalus or Yoroi.


text:
Strongest arguments against self-referentiality in PoS
I recently came across an argument of self-referentiality in PoS and I'm wondering what's the strongest counter-point to this idea?
In essence, the idea is that in PoS you

Similarly reduced, proof-of-stake systems work like this:

The list of valid transactions determines who has coin.
complexity
People with coin decide which transactions are valid.

Is PoS actually self-referential as described here? If so, is this some critical flaw in the idea? Maybe PoS in general is self-referential like this but Ouroboros isn't?

I think the issues with this argument are actually pretty simple. He is wrong for the case of Cardano because people with coin get tickets to the lottery to decide who gets to create the next block. Therefore Cardano is not self-referential. He also is assuming a UTXO or eUTXO model for "The list of valid transactions determines who has a coin." Some blockchains use PoS and an account based accounting method, which makes the first point untrue.
For the second point, all blockchains are relatively complex when you get into the details. With that said, my anecdotal experience shows that it is easier to explain proof of stake than proof of work to someone with no blockchain knowledge.
If there was a proof of stake coin using eUTXO/UTXO and the protocol was as simple as 'People with coin decide which transactions are valid' then I would say yes it is self-referential. However, a protocol of that nature has even bigger concerns than that, which is why one doesn't exist. (Please correct me if one does exist)
I hope this is helpful!

The bolded statement doesn't solve the self-referentiality in my mind - even though you get tickets, only ticketholders get to decide which transactions get included.
I also don't think the account vs utxo models make a difference in whether or not this self referentiality exists.

I came across this argument as well and thought it looks a bit constructed. In a PoW system, the people with processing power decide which transactions are correct. In a PoS system, it is those with wealth. Both come from outside of the system. The self referential nature described exists only at the beginning, when the PoS system is started. As soon as a coin distribution to unrelated parties took place, the system is no longer self referential if that distribution reflects external factors (like the financial ability to purchase the coins or to operate a stake pool).

Yeah I agree, I think there's an argument to be made for self referentiality in PoW as well - the miners get rewards which can be used to buy more processing power (which is essentially stake in PoS) which is then used to decide which transactions are included in the next block.
I'm not sure that I follow your argument of distribution after genesis breaking self referentiality. It's still coin holders who decide which transactions get included, regardless of distribution.

PoS and PoW both distribute coins according to rules enforced by independent actors. My point was that the distribution of coins in PoS does not (only) come from the system. It comes from an external logic: coins sold for real money or distributed according to some other logic of the real world. If the coin distribution would follow only some internal logic of the system than it would be self referential. I know my point is a bit vague. I have here a strong intuition that it goes into the right direction but I’m not able to completely articulate it.


text:
The cardano-wallet docker compose always connects to testnet?
I'm running the docker compose from iohk for cardano-wallet (https://github.com/input-output-hk/cardano-wallet/blob/master/docker-compose.yml).
I execute the compose using the following command:
NETWORK=mainnet docker-compose up

Now when I hit the api to check the status, it tells I'm in the byron era:
Request
curl http://localhost:8090/v2/network/information

Response
{"node_era":"byron","node_tip":{"height":{"quantity":67669,"unit":"block"},"time":"2017-10-09T13:50:11Z","epoch_number":3,"absolute_slot_number":67696,"slot_number":2896},"sync_progress":{"status":"syncing","progress":{"quantity":1.03,"unit":"percent"}}}%

Shouldn't I be in the current era? I assume I am connected to testnet since it is still on byron. I haven't modified the docker compose and see no other way to specify mainnet.

This probably means that your Cardano node is not done syncing and it is just in the Byron era of the blockchain history.
You can see the current height (read: the number of blocks in the chain) being just 67669. When you look at the explorer, that is just block from 2017/10/09 13:50:11 UTC.
Give it time and make sure it is completly synced and on the tip with the rest of the blockchain.
Also, to clarify, the testnet is also on Alonzo era.


text:
Getting Validator Hash
I'm checking the Value locked by certain ValidatorHash of another script that I deployed. Does anyone know how to get Ledger.Address or ValidatorHash from Plutus or cardano-cli? I know the "address" that is a string that starts with "addr_test1..." but how do I turn that into the above Plutus types?
Sort of like this question but for ValidatorHash. I know that you can use cardano-cli transaction policyid for monetary policies, is there an equivalent for ValidatorHash?
Thanks!

So you want to go from address (addr_test1...) to Ledger.Address or ValidatorHash?

Just tested on testnet, cardano-cli transaction policyid --script-file ... works.
Just make sure in your Haskell code to include something like the following to turn it into an address:
testnetDumpValidatorHash :: ValidatorHash
testnetDumpValidatorHash = "10101010110101010101010101010101010101010101010101123456"

testnetDumpAddress :: Ledger.Address
testnetDumpAddress = scriptHashAddress testnetDumpValidatorHash


text:
cardano-serialization-lib-nodejs documentation
Just realised the power of the cardano-serialization-lib-nodejs as it has all the functionality of cardano-cli, wallet etc. Even has some plutus based functions.
But as for any good things the bad side is the detailed documentation of all the hundreds of functions present in this library. Can anyone suggest how someone new to this library can get started with basic stuff like creating transaction, minting NFT etc. Just common stuff we achieve using cardano-cli now a days ?ca

The documentation is very limiting, but if you're confident with JavaScript or TypeScript then there are a few very good resources out there. I've personally learnt by just reading the Nami wallet source code. There are good examples on how to build transactions, and sign transactions. The API flow document is basically my bible these days too, there are some good comments and the type descriptions make it pretty easy to understand.
Another decent example can be found here for building transactions using the Nami API, but the same applies for if you're using your own created keys or the keys created by Nami wallet itself. When it comes to minting assets though it's not as straight forward, since minting with the cardano-serialization-lib isn't available in stable yet, you need a 10.0 beta version to use it. We're in the process of open-sourcing our SDK wrapper around CSL that makes wallet creation, minting tokens, and sending payments much easier but it's still being tested. Hopefully will be released in the next week or two!

thanks Thomas. Will dive into the resources you have pointed out.

There is some (a bit outdated) examples here as part of the repo, but It may help you to get started.

I had the same question and so written a demo with the cardano-serialization-lib here: https://github.com/dynamicstrategies/cardano-wallet-connector
The lib is very powerful and at this point it has replaced me he off chain plutus that i might have needed to write and replaced with reacJS + this lib


text:
How can a single Cardano Wallet have many addresses?
I'm new to Cardano and would like to know about this blockchain. I'm from Ethereum and I use Metamask as my "wallet" for it. I usually have one address only for one Metamask wallet. I'm curious to know how a Cardano wallet (say Yoroi) achieve multiple addresses when it's a single wallet only (I can make multiple wallets in Yoroi, yes, but a single wallet can generate multiple addresses, and I'm curious how that works; I'm also wondering if it's really possible in the first place and Metamask just doesn't do it).
Maybe I have misunderstood wallet addresses to receiving addresses, so any clarifications would be helpful.

Your “wallet” is really just a private key that only you know. You can use that key to deterministically generate many addresses, each address with a unique index. But no one can derive those addresses for you without knowing your private key.
This is similar to something like SSH, where you have a private/public key pair, but you can have public key 1, public key 2, public key 3, etc.
When you add your private key to Yoroi, the wallet app can regenerated all your addresses for you and check each of them for UTxOs. If it checks the first (let's say) 50, and they all have UTxOs owned by them, the wallet app will keep generating more until it doesn’t find any more funds (in theory you could use your private key outside the wallet app and generate an address for index 1000000+, and if you have funds sent to that address they might not show up on Yoroi, but you would still own them). This total at all of your addresses is your total balance.
Generating addresses like this is great for privacy, since it’s hard for people other than you to determine which addresses are associated with each other. But not entirely impossible with off-chain data.
Bitcoin works in a similar way.

Wallet addresses are public keys mathematically derived from private keys and encoded to a special format. The ability of a wallet to generate multiple addresses is determined by the implementation of a method known as Hierarchy for Deterministic Wallets (HD), originally introduced in BIP-32 for Bitcoin.
When using such a wallet, a root private key is created and, from it, multiple child public keys can be derived.  The public keys are linked to that private key which means that funds received in these addresses can be spent using that single private key. In Cardano, Yoroi is a HD wallet.
You can get some more technical details on how addresses are created in Cardano: Here and Here


text:
Does anyone else have trouble syncing to the PAB end to end testnet?
Plutus PAB Testnode
git checkout v2021-11-05
Following the instructions on the readme file leads me to a testnet node that is stuck due to a corrupt block error.
[relay2:cardano.node.ChainDB:Error:34] [2021-11-18 03:05:39.99 UTC] Invalid block 2fbd8c97cb0643a879564f6fe42c4710486b636c1876a0c454ae8ea202c87d26 at slot 41763999: ExtValidationErrorLedger (HardForkLedgerErrorFromEra S (S (S (S (Z (WrapLedgerErr {unwrapLedgerErr = BBodyError (BlockTransitionError [ShelleyInAlonzoPredFail (LedgersFailure (LedgerFailure (UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (UtxosFailure (ValidationTagMismatch (IsValid True) (FailedUnexpectedly [PlutusFailure "\nThe 2 arg plutus script (PlutusScript PlutusV1 ScriptHash \"8fd8fe8fce219f0ac0f71aa5afd3c98d4ff8c0ccea1c5882852b7914\") fails.\nCekError An error has occurred:  User error:\nThe budget was overspent. Final negative state: ({ cpu: -35982 | mem: 0 })\nThe redeemer is: List []\nThe context is:\nPurpose: Minting 8fd8fe8fce219f0ac0f71aa5afd3c98d4ff8c0ccea1c5882852b7914\nTxInfo:\n  TxId: ecee1d36dc6f4df7e731deba70e14aa51fade20b01aca8089667fc76ba388ba9\n  Inputs: [ c8f1f0677ee4652498bea5eeb5ecbdce9870e065200b6d00333ee6801a315e46!0 -> - Value (Map [(,Map [(\"\",5000000)])]) addressed to\n                                                                                PubKeyCredential: ef41e0822f758a0fb7507561047f233d4de9a7003e3ce5d551147ced (StakingHash PubKeyCredential: 43ca32d42d6ef66305c91466c15aa65893acb373865c0a75a33f7e2d) ]\n  Outputs: [ - Value (Map [(,Map [(\"\",2581996)])]) addressed to\n               PubKeyCredential: ef41e0822f758a0fb7507561047f233d4de9a7003e3ce5d551147ced (StakingHash PubKeyCredential: 43ca32d42d6ef66305c91466c15aa65893acb373865c0a75a33f7e2d)\n           , - Value (Map [(,Map [(\"\",2000000)]),(8fd8fe8fce219f0ac0f71aa5afd3c98d4ff8c0ccea1c5882852b7914,Map [(\"abc\",1)])]) addressed to\n               ScriptCredential: 8fd8fe8fce219f0ac0f71aa5afd3c98d4ff8c0ccea1c5882852b7914 (no staking credential) ]\n  Fee: Value (Map [(,Map [(\"\",418004)])])\n  Value minted: Value (Map [(8fd8fe8fce219f0ac0f71aa5afd3c98d4ff8c0ccea1c5882852b7914,Map [(\"abc\",1)])])\n  DCerts: []\n  Wdrl: []\n  Valid range: (-\8734 , +\8734)\n  Signatories: []\n  Datums: []\n" "[encoded data, 5592 characters]"]))))))))])}))))))
[relay2:cardano.node.ChainDB:Info:34] [2021-11-18 03:05:39.99 UTC] Valid candidate c7cd93c41b710ae068c793c441a857d540770cceabf20f57ef7f0e01af2819d6 at slot 41763935

I sync the testnet then it almost gets done before being stuck.
Has anyone seen this type of error?
There was point when I could sync the entire chain then something created an invalid block.

Mine is also stuck at 87%

This happened to me.
I solved it by cleaning up the databases and restarting the process.

I completely deleted the db and resynced and continued to get this issue. I will try again and see what happens.


text:
What is supply.locked in the blockfrost API /network endpoint?
I have been working on a data analytics on Cardano using blockfrost. I am fairly familiar with Cardano tokenomics, but I have been wondering about the supply.locked data in the /network endpoint. Here is the description in the github

locked property to /network endpoint, representing total supply locked by scripts

Does this represent the value locked in Cardano by smart contracts + timelocked contracts (aka. scripts)?

Yes, that is correct, it is the amount of ADA locked by contracts.
On docs.blockfrost.io:

Thank you! I still cannot upvote. So this is the best I can do. Hopefully, I should have something for the community soon.


text:
How to retrieve the datum added with the option –tx-out-datum-embed-file from the tx witness data
I have been thinking recently about the way we are predominately creating NFTs on Cardano, right now the trend is to add the NFT attributes to the transaction metadata, however, I think this is not really that good if we want to do more interesting things with the tokens. As long as we keep adding the NFT attributes to the transaction metadata we will never have decentralized minting (creating new NFTs from smart contracts, e.g breeding mechanism etc), as we can not enforce any kind of restrictions on the transaction metadata from the scripts. The users always have all the freedom to add anything to the metadata. Also, we cant read the information stored there from the contracts, making it impossible to use for example to implement business logic on the chain.
I have the following idea, but I am not sure if it could work:
Objectives:

Stay away from an account base model and if possible keep the NFT as a native token.

Have the metadata accessible from the contracts (token metadata must
be inside an eUTXO).

Possible solution:
At minting time we create two tokens, for example:
“fffffffffffffffffffff.Monster00001” and “fffffffffffffffffffff.Monster00001_state” (they could be in the same policy or different policies).
Token “Monster00001” could still be freely traded as a native token, however token Monster00001_state will be trapped in an eUTXO which holds the token metadata or dynamic state (depending on the use case).
To retrieve the metadata for token fffffffffffffffffffff.Monster00001 we just need to find the eUTXO which contains fffffffffffffffffffff.Monster00001_state and read its datum (from off-chain code to for example display the NFT in a website), but here is where I am stuck.
I know that by using –tx-out-datum-embed-file we can embed the datum data on the transaction (as opposed to the datum hash). However, is this information persisted on the blockchain? (I am guessing it is as it is needed in some scripts validators), and if so, how can we retrieve this data?.

Another option would be to mint only one token “fffffffffffffffffffff.hhhhhhhhhhh” where hhhhhhhhh is hash of the metadata and send it to the buyer. Then on chain you can hash metadata and check with token name (hhhhhhh). If they are equal, you are sure user supplied the correct metadata. This would requere extra on chain computation (hashing) but would avoid storing extra utxos in a smart contract, where each utxo has to have min 1 ada. If there are many nft's that can accumulate a lot

you cant access the transaction metadata from smart-contracts, so you won't be able to make this check on-chain

you can't access transaction metadata dirrectly but you can always send metadata (and any other data) to smart contract from off-chain code via redeemer. Then in on-chain code you check if hash redeemer == nft.tokenName and if it's true you are sure metadata retrieved via redeemer belongs to a specific nft.

I know that by using –tx-out-datum-embed-file we can embed the datum
data on the transaction (as opposed to the datum hash). However, is
this information persisted on the blockchain? (I am guessing it is as
it is needed in some scripts validators), and if so, how can we
retrieve this data?.

Yes, this information is persisted, you can retrieve it using db-sync or blockfrost. For db-sync see this answer. If you want to use blockfrost, however, you will need to first get the datum-hash, which you can get from the UTxOs with https://cardano-testnet.blockfrost.io/api/v0/addresses/{address}/utxos (take a look here). Then, you'll use that datum-hash to get the actual datum with this request https://cardano-testnet.blockfrost.io/api/v0/scripts/datum/{datum_hash} (also take a look here)

Thanks, this is the correct answer. The answer you just referenced was posted by me :)

Oh didn't even noticed it lol

Was looking for an answer to your question my self

Your approach won't work, because in order to read the onchain data in a datum file, you have to consume given UTXO.
CIP 25 - NFT Metadata Standard has been created before smart contracts and is intended for minting outside of the them.
I'm not sure if it is a good idea to mix these two approaches. If you are a NFT author, it's up to you to choose what you want to do.
If minting native tokens with a script locking, you basically lock yourself out of burning the given token (we might have a solution for it in the future, but it is not possible right now) and it is all you have - a dummy token with metadata.
On the other hand, if you want to enable cool decentralized features to your NFT, you might want to mint it using a smart contract that will enable you, to add different proprieties to it (such as burning and re-minting).
Over time, there will be probably an update to CIP25 to account for smart contract based tokens.

To consume the eUTXO to read the metadata onchain, is not an issue, the token will be placed in a new eUTXO after we access the data (and we can enforce this).

I am trying to figure out how to read this metadata >offchain<. Losing the ability to burn the state token is not important to me atm, most NFTs right now cant do this anyways after the policy expires. And we could allow to burn the native token used as handle.

My idea is to have access to the token metadata from the minting policy and other validator scripts, you will be required to spend the eUTXOs with the state tokens, of course, to get access to the datum, and will be required by the script to place them on the contract again while conserving the metadata.

Can you explain what you mean by "in order to read the onchain data in a datum file, you have to consume given UTXO"? Where does the datum file come from if you can only get it at spend time?

You can only access the datum data from the smart-contract when you spent the output, it must be provided as a witness by the spending transaction. What I want to do is to get the datum data off-chain by querying the blockchain so I can display and use the data offchain as well. It must be possible because blockfrost api does it somehow


text:
Best practice for handling rollbacks
We are creating a payment processor. The business wants to send users a product when they receive a payment. This is easy enough using the cardano-wallet api. However, we were made aware of the existence of rollbacks on the chain. In the event of a rollback, what is the best practice for handling a change?
For example we may have detected a payment for 30 ADA. A rollback occurs, and that payment is removed from the chain history. How do we detect that this happened? How can we have confidence that a payment will not be rolled back before sending the customer the product?

In a perfect network setup rollbacks should not be happening. It is also down to your business decision of managing risks -- deep rollbacks are very rare but possibile nonetheless.
Shallow rollbacks (depth 1-3) do happen on occasion, perhaps once or twice a day. This happens because of the way the Praos protocol is selecting the block leaders and this relates to slot battles. Those are local rollbacks, most of the time happening to the cluster of nodes, not the whole network. This is considered to be a healty operation of the network.
Deeper rollbacks are happening less often (rare) and might be a sign of malevolent actor in the network.
Block is stable when it is securityParam (currently 2160) blocks deep. So to be 100% sure you might wish to wait for that number of confirmations.
refer to CIP-9 for details on securityParam
you might check the current value in cardano-node repo


text:
How to get a full command list of the Cardano-cli
I'm trying to fix something (the cardanocli-js) that broke with this last update (1.31.0) but i don't know how to see the correct way that, in 1.31.0 version, the Cli make transactions (or find how much cost the fee). I didn't find the list of commands and their correct use..
I know that using help i can somewhat get it. But there is a more explanatory version somewhere?
thank you.

The only one I know is this:

Cardano Node CLI Reference
[EDIT] Create Simple Transaction (although it's a bit outdated) this one explains very well how to create a transaction and calculate fees.

Related to fee, first you need to build the transaction then you can use this command:
cardano-cli transaction calculate-min-fee \
  --tx-body-file transaction.raw \
  --tx-in-count 1 \
  --tx-out-count 1 \
  --witness-count 2 \
  --testnet-magic 1097911063 \
  --protocol-params-file protocol-params.json

Where:

--tx-body-file FILE      Input filepath of the JSON TxBody.

--tx-in-count NATURAL    The number of transaction inputs.

--tx-out-count NATURAL   The number of transaction outputs.

--witness-count NATURAL  The number of Shelley key witnesses.

There is a good explanation to calculate fees


text:
Questioning Plutus API design decision
In Lecture 10 from the Plutus Pioneer Programm there is a replica of the Uniswap Smart Contract built on top of Plutus. It is actually part of the standard Plutus use cases Plutus Uniswap
To have a better user experience and to get to know it better i wanted to build a GUI around it. If you are interested you can find it in this github repo
Now to my question.
What is the reason behind the design decision for the Status endpoint of the Plutus PAB Rest API.
In order to read the funds we have first to call the funds Endpoint which returns nothing and secondly you have to call the status endpoint.

This is the Frontend Code from Lars where he reads the funds

This makes it very difficult if you want to have concurrent calls one for the funds and one for the pools
Why is there not a dedicated status endpoint for funds and pools?

This got me wondering too. I posted a question but never got any answer: https://cardano.stackexchange.com/questions/4908/user-interaction-with-smart-contracts  It seems, the Plutus team is not active on this forum.

I just registered for the third cohort of the ppp. There i will ask this Question in the Q&A session. As soon as i know more i will post it here.

Great, I'm looking forward. I am not participating in the cohort, but I would have a lot of questions.

the link to frontend code is broken, can you please update?

Thank you @LexTRX it is updated now

The only way to read a state of the smart contract is using a contract instance status endpoint (api/contract/instance/$INSTANCE_ID/status). Other endpoints can only trigger a change of the state but they cannot return it so it's always a two step process.

This does not really answer my question.
I do already know how to read the different states. My question was why it is designed like this.
It even contradicts completely the functional approach of Haskell Language.


text:
How long does it take for a transaction to reach a given depth? (How long to reach depth N?)
I realize that the time it takes to reach specific depths is not precisely calculable. Nonetheless, there must be a rule of thumb for roughly how long each block takes to process. For example, if we want to estimate how long it will take for a transaction to reach a depth of 20, what formula should we use?

Given the time of one slot is defined by slot_length being one second right now.
And the chain parameter active_slots_coefficient, which gives us the proportion of slots in which blocks should be issued, it is set to 0.05.
This means, that we can expect one block in average in 1 / 0.05 = 20 seconds.
However, you must account for mempool and pending transactions too.

Average block time is 20 seconds, so...
Average-time-to-depth-N = N x 20 seconds


text:
Minting Native Assests - Error Building the Raw Transaction: $output variable
I'm following this doc on how to mint native assets with Cardano and have received an error that I can't get around. The problem is with the $output variable in the $tx-out parameter of the cardano-cli transaction buildraw command. I don't see where this variable is assigned in the documentation. Any thoughts or ideas on how I'm missing the variable?
option --tx-out:
unexpected "+"
expecting white space or multi-asset value expression

You are right it is missing the documentation, but basically, it is the your UTXO output amount.
You can calculate it by finding out the amount of lovelaces on the UTXO you are spending in your tx-in minus the fees.

Makes sense. I'll assign the output variable accordingly. Thank you very much!

I see the formula further in the documentation, in a "Note" section:

the output in Lovelace (ada) (output = input amount — fee).


text:
What are input endorsers and how do they make Cardano more scalable?
Charles Hoskinson talked about input endorsers in a recent livestream and said they could improve the throughput of the base ledger by a factor of 20 to 40. What are input endorsers and how do they work? How do they achieve scalability? Where can I learn more?

Here's an explanation of input endorsers by IOHK researcher Peter Gaži.

The core idea of input endorsers is to separate transaction selection from block production. The Ouroboros protocol - just like it randomly selects block producers according to their staked Ada - would additionally randomly select input endorsers also according to the same staked Ada. Input endorsers would select transactions from the mempool and propagate these transactions through the network. All nodes could then process these endorsed transactions before the block producers bundle previously endorsed transactions into blocks.
According to the Ouroboros paper:

Input-endorsers create a second layer of transaction endorsing prior to block inclusion. [..] Note that input-endorsers are assigned to slots in the same way that slot leaders are, and inputs included in blocks are only acceptable if they are endorsed by an eligible input-endorser.

also

Note that blocks and endorsed inputs are diffused independently with each block containing from 0 up to d endorsed inputs.

To understand how this makes Cardano more scalable you need to understand what the current scalability bottlenecks are. Currently, a node will produce a block and then propagate it through the network. The next block producer will then hopefully create the next block on top of this previous block. There needs to be enough time in between the blocks to allow the new block to be created and propagated through the whole network. Otherwise you get more forks in the blockchain since some block producers would start producing their block before they received the previous block. More forks are a security risk since it allows an attacker with less than 50% of the stake to more easily create a longer chain. This leads to a situation where nodes spend most of their time just waiting for blocks to propagate.
Input endorsers solve this bottleneck. Since input endorsers cannot create forks (endorsed transactions are not yet ordered) they can be run at an increased rate without risking the security of the chain and since blocks contain only endorsed (and therefore already processed) transactions you can easily put more transactions into each block without increasing the time it takes to produce a block.
Here's a short video explanation of input endorsers from the Cardano Summit 2021 by IOHK researcher Peter Gaži.
The concept of input endorsers seems to share a lot of similarities to a paper called Prism: Scaling Bitcoin by 10,000x. There's a video presentation on Prism that I found helpful in understanding the scalability aspect of input endorsers.

Here is a link to the original Ouroboros paper from 2016:
https://eprint.iacr.org/2016/889.pdf
If you scroll to section 8.1, input endorsers (IE) are discussed and generalized in close proximity to block producers (BP). Both are stakeholder entities in that the power to go about their tasks is constrained by the amount of stake delegated to them.
We are familiar what this means in the case of BPs - block production capacity (limited by stake threshold) and chain verification (unlimited).
However, during periods of surging transaction volumes, BPs may be unable to keep up with network demand and continuous sequences of blocks may be completely full. This is where IEs come in. They are able to aggregate transactions and keep track of all submitted transactions, even those that haven't been included on chain yet. After the surge has settled, an IE would be able to check if some of the transactions it has processed have not made it on-chain, and if so, they'd be able to submit those transactions late, up to a certain late-time (assuming the UTXOs haven't yet been spent in an already on-chain tx).
I like to think of IE's almost like backup mempools with special privelages. The details of how many and how late endorsed transactions may be submitted on-chain will be a future protocol parameter, and will be constrained by a stake-threshold; much in the same way that an individual BPs power is constrained.
Hope this helps!

Input endorsers are originally discussed in the Ouroboros paper and could be potentially be used to create specific high-throughput layer 1 Ouroboros variants.
To get the idea, check out this part of the paper:

Input endorsers, stakeholder delegates, anonymous communication. In
the final stage of our design, we augment the protocol with two new
roles for the entities that are maintaining the ledger and consider
the benefits of anonymous communication. Input-endorsers create a
second layer of transaction endorsing prior to block inclusion. This
mechanism enables the protocol to withstand deviations such as selfish
mining and enables us to show that honest behaviour is an approximate
Nash equilibrium under reasonable assumptions regarding the costs of
running the protocol. Note that input-endorsers are assigned to slots
in the same way that slot leaders are, and inputs included in blocks
are only acceptable if they are endorsed by an eligible
input-endorser. Second, the delegation feature allows stakeholders to
transfer committee participation to selected delegates that assume the
responsibility of the stakeholders in running the protocol (including
participation to the MPC and issuance of blocks).

I don't understand how this leads to more throughput. If the system can process 40 times more transactions per second, doesn't that lead to 40 times bigger state growth and therefore 40 times bigger storage requirements? How do input endorsers address this?

They do not address it, the input endorsers won't help with the growing storage requirement at all. They will just help by validating the inputs that are later minted by the slot leader, therefore offloading a lot of validating tasks to a different party in the system, allow the system to increase the trasanctional throughput by few factors.

Are we saying input endorsers do computation on behalf of Slot Leaders?  Right now doing that seems to have no value as computational requirements are small.  Also what benefit would this scheme provide a user, their transaction would still not be confirmed.


text:
Do script addresses have a staking part? Is it possible to stake from smart contracts on Cardano?
I heard somewhere that staking from smart contracts may be possible on Cardano, and I wonder if that is because there is a staking part to script addresses on Cardano?
CIP 19 discusses wallet addresses on Cardano, but it is not clear to me how or if this information relates to script addresses also.

Yes, it can, if you look in the CIP19, it has the header of 0001.....
This address contains both the script has, as well as the stake key hash.

Do you know if there is any way to add constraints for delegation into the Plutus script or tx?

So a smart contract lending platform or decentralized exchange could either delegate to its own chosen stakepools and then pass on the staking rewards to liquidity providers, OR the dapp could somehow create mangled addresses so liquidity providers get to choose who they want to delegate to while the funds are at the script address? The first option sounds easier to implement but the second gives more freedom, am I understanding this correctly?


text:
NFT royalties Cardano
I am attempting to create a NFT with % royalties when NFT is re-sold.
My idea would be the following :

The symbolic owner of the NFT is defined in the datum of the script e.g. datum = { owner : [ownerwallet] , ... }
The following end points are available in the smart contract :

A) purchase : if someone want to purchase the NFT (i.e. rename the owner par of the datum) B) define_selling_price : to define at which selling price the purchase operation will work  C) define_who_can_purchase: to ensure that if you want to sell it to someone, nobody else can purchase it (i.e. allowed purchased wallet)

To ensure that the royalties are paid, the validation script verifies that there are only two resulting UTXO of the "purchase" endpoint, the first UTXO contains x% of ADA to hardwritten address (i.e. royalty ) , the second UTXO is copy of the exact same script (for future selling)

Could that be done in the described way above ?
What is the exhaustive list of the parameters available for a smart validator to work?
Thank you in advance

Should one of the answers be marked as accepted?

Yes, it can be done. Just create a smart validator that makes sure, that when the UTXO containing the asset is spend to a new address, it also requires an additional input for the royalty address.
I believe you are correct in your second question.

sorry I just rewrote my question with more details ^^

You can wrap a native asset into a tailored smart contract, but I think this only makes sense if you also provide the platform to interact with these smart contracts. It is not a sell-and-forget transaction where the buyer can do whatever he wants including using DEXs to trade his asset.


text:
Errror cardano-cli build-raw: AssetName deserisalisation failed expecting hexadecimal digit
I am trying to figure out what's wrong but I do not see it, is my command really wrong? do I need to encode the token name with something? Get a different cardano-cli executable?
transaction build-raw --tx-in c4d3606f4f9a3688d13aa1afbd114cd0e78cc04dc2c0952557db0fb4260d2560#0 --tx-out addr_test1qqrsm4vj985epelhc8qpv8jahaqpjll7ed67647dk47ku4x5x8xk48yntkwhc2s20manmqartkchrp2qxgfwdaezsq5qu9urvd+2000000+"1 b75d4e90a96db2468d4c3d45d65b1f846307b1fc25acdb5489851481.CSCT" --tx-out addr_test1vpl22c6vml7p7n5vv4n2mjf6sfw9kcse5c7jjk3uxc9dllcvvvj8q+2830000 --mint="1 b75d4e90a96db2468d4c3d45d65b1f846307b1fc25acdb5489851481.CSCT" --mint-script-file newtesttokenpolicy.script --invalid-hereafter 42970622 --fee 170000 --out-file c4d3606f4f9a3688d13aa1afbd114cd0e78cc04dc2c0952557db0fb4260d2560.mint.raw
This builds tx with cli from mainnet Daedalus on Windows, but fails on my Ubuntu testnet with the latest cardano-node build. I have this error:
option --tx-out:  unexpected "S" expecting hexadecimal digit AssetName deserisalisation failed

That's because since cardano-node v1.31, you should pass the asset name as base16-encoded.
You can use this command:
echo -n "myassetname" | xxd -ps


text:
Cannot recover Daedalus wallet after deleting on account of wallet not syncing
I sent ADA to Daedalus wallet. When opening the wallet, it took from 6:30 pm yesterday until around 4 am this morning to sync. I then deleted the wallet (since I have my recovery seed) and downloaded the update to see if anything happens. The sync took about 20 minutes but when I tried to recover the old wallet with my recovery seed, I got an error message. This happened on 4 occasions since this afternoon.
Also- I use Trezor model T as well but got an error message when trying to use that recovery process.  I used CAKE WALLET to exchange Bitcoin to ADA and sent it to Daedalus, originally. I do have the trade ID. Can anyone help or direct me to the proper resource?

I'm not sure I can help, but surely you should describe the error messages you received

Enter your Daedalus-generated seed into Yoroi mobile wallet. It's a light wallet (a.k.a. SPV) so, there's no need to wait while it will be synced with the blockchain. Yoroi supports 15- and 24-word seeds.

Yes, I did. However, the ADA I exchanged is not there. The address is correct and it’s confirmed on the blockchain but it’s not in my balance. I don’t know what to do about this. The changenow support desk said I’d have to notify Daedalus support…..however I don’t know where to go.

If you are 100% sure you wrote your mnemonic phrase down correctly, you should be able to restore it on any wallet. Try to use it on:
Yoroi, Adalite
If you can access the wallet from these services, the problem is definitely your Daedalus installation. You should proceed to reinstall it again, making sure to clean all existing data


text:
Get a list of top asset hodlers for a specific asset
I'm using the Blockfrost API to get a list of the top holders of an asset. ie. The people with the highest quantity of this asset in their wallet.
I'm using Blockfrost's API, and the specific call I'm using is : https://cardano-mainnet.blockfrost.io/api/v0/assets/{asset}/addresses
This returns a list of addresses and the quantity held by each address:
[
  {
    "address": "addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz",
    "quantity": "1"
  },
  {
    "address": "addr1qyhr4exrgavdcn3qhfcc9f939fzsch2re5ry9cwvcdyh4x4re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qdpvhza",
    "quantity": "100000"
  },
  {
    "address": "addr1q8zup8m9ue3p98kxlxl9q8rnyan8hw3ul282tsl9s326dfj088lvedv4zckcj24arcpasr0gua4c5gq4zw2rpcpjk2lq8cmd9l",
    "quantity": "18605647"
  }
]

So... I thought - just sort the list descending and display the top 10, right?
Well that works and it gives me the list of the top 10, but here's the catch...
If anybody uses a different receiving address to purchase the same asset from the same wallet, each receiving address is listed and returned separately by the API. In other words, if anyone buys the same asset (any amount) from the same wallet multiple times, using different receiving addresses, the purchases are not added together and represented as the total holdings for that wallet.
So my top 10 are not really the top 10...! (Just the top 10 biggest purchases...)
Is there any way to get the top 10 holders of a particular asset using the Blockfrost API or any other method?

There is one catch: the blockchain has no idea what your wallet is, it only sees different address. There is not a guaranteed way to achieve this.
You might want to group these by their stake key, so after listing all the addresses you need to sum these sharing the same stake key.
That being said, just because the address contains a specific stake key, it does not mean that it is the same wallet. This is what we call mengled addresses.


text:
Sync Daedalus with a local testnet node
I have set up a Cardano development environment and build a node which is fully synced to the testnet network.
How can I make my Daedalus wallet use/point to that local testnet node instead of synching again to the online/main testnet?

To anyone who may need a similar setup, I got this working after many trials. From my local cardano node, I copied the contents of the db directory into the chain directory of the Daedalus wallet.
I then updated the configuration file topology.yaml to use localhost in the addr parameter.
It works and I can receive tAda from the  testnet faucet.

Daedalus is a full node itself, this mean that he doesn't connect to an external node to sync the blockchain.
As the official website says:
"Daedalus is a full node wallet. This means that unlike light wallets (e.g.Yoroi, Adalite etc.) Daedalus downloads a full copy of the Cardano blockchain and independently validates every transaction in its history."
Here I found a Reddit Link where a similar question was made.

Well true, Daedalus is a full node, but on a fresh install ,it needs to connect to the Cardano network to sync to the latest blocks. What I was trying is to get it to use my local node which has already synced.