text:
How long does it take to sync a node or a Daedalus wallet? What factors does it depend on?
How long does it take to sync (download the blockchain) to a Daedalus Wallet or node. What factors does this depend on (download bandwidth, size of blockchain, upload bandwidth of the source (node))?

It all depends on your hardware, mostly CPU and network connection (yours and your peers), but on most newer hardware you should be able to sync it within a day right now.

As you also asked for a wallet, also note that after your local full node fetched and verified all blocks from the network, your wallet software (Daedalus) may has to restore an existing wallet, and so walk through the whole UTXO history (all blocks)
The more wallets you restore/update the same time the longer it will take

Also can be factor that how many relay nodes the wallet connects to. Right now by default that is only one node - the IOHK server. and that can sometimes not enough since it can be overloaded because lot of wallets can connect to that server simultaneously.
This limitation will be solved by the p2p node discovery will be introduced later this year..
btw, here is a workaround how to define more relays for the wallet:
https://forum.cardano.org/t/workaround-to-fix-daedalus-connecting-to-network-and-syncing-issue/59780?u=laplasz

Note that IOHK is running several nodes and you are not connecting to only one.

@MarekMahut-StakeNuts the topology file of the wallet contains only 1 address, so the node will establish a connection only with that address.

That one addresses resolves to a lot of different nodes. Also, cardano-node topology specifies the valency of this address. In other words, it specifies to how many nodes it should connect to from the specified hostname.

the valency is 1 for the default hostname. Yes, it can be different IP, but only 1 connection will established.


text:
How can I download transaction history of any public address as CSV?
How can I download transaction history of any public address as CSV? Use case: For some 'lost' wallets (lost seed phrase) I need to get the transaction history for Tax Software. Cannot figure out a way to do this using the available blockchain explorers... but this should be relatively easy IMO.

The data you need is in a fully synced instance of cardano-db-sync. All you need is the correct SQL query.

I do not how you could do it as CSV, i guess you must adapt  the data you get from Blockfrost, you can use this endpoint
https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1transactions/get
:) The API usage is pretty straight foward using NodeJs.. but they have support for more languagues like Haskell or Python ... Any how i think there might arise complications from the fact that some wallet uses more than one address for your data analysis tool

This tool does exactly that (based on a set of staking addresses) using the blockfrost.io API, as a CSV or XLSX.
It also can graph the asset balance over time.
https://github.com/pixelsoup42/cardano_account_pandas_dumper

source: Stack Exchange

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

sort: votes


text:
how to get public key of nami wallet
wondering whats the simplest way to get the pkh for nami-wallet? Is it possible through the webapp?

I would be interested in getting the holdings of that pkh as a list after getting the pkh, but I think this is a user input type of deal.
I don't think you can get the pkh for a random wallet on nami without other information such as the wallet address (I mean how is it gonna know which address your requesting the pkh for?).
Also if your using smart contracts, I think whatever the solution is would work any address on the chain regardless of which wallet they are using.

maybe not the pkh or public key of any specific address, but an account-level public key should be an option

Hi @zhekson can you please clarify what you mean by account level pk and how this differs from the pk of an address?

Scroll down to the "HD Sequential wallets (à la BIP-44)" here

Thanks Ill take a look at it

The easiest way I can think of (so far) is:

Grab your bech32 address from the Nami wallet interface (e.g. addr_***)
Inspect that address with the cardano-address tool with this command:

echo <YOUR_ADDRESS_HERE addr_...> | cardano-address address inspect

You should be able to find the hex hash in the output under the property spending_key_hash

ALTERNATIVELY, there's another easy way where you dont need to download cardano-address. By using the cardano-address demo here Cardano Address Inspector.

Unfortunately they have disabled the hex output option, not sure why
But I realized that they do print the cardano-address output into the console... So if you open the browser inspect tool and hit Inspect again, you should be able to find the hex hash with the key spending_key_hash

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


text:
Stream/Query transaction price history of an asset
Is it possible to get the transaction incl. price history of an asset e.g. (SundaeSwap) using blockfrost or cardano-db-sync?
If yes, is it also possible to stream this value from block to block?

No, as this information is not directly on-chain.


text:
what info is in datum value and how can we extract it
In the case for spend purposes e.g.
Value: {"fields": [{"bytes": "10dc9481577ae0ac7a2b828bae9f2ba163b79ce73069d75fd609bc88"}, {"bytes": "a20a"}], "constructor": 0}

what kind of information is found in the first and second bytes field, and how does one extract this?


text:
Where to find the latest repo Ledger.Constraints?
Revisiting Plutus pioneer code, I see Ledger-related code e.g.
ScriptContext Plutus.V1.Ledger.Contexts or Interval Plutus.V1.Ledger.Interval. Is there a github repo equivalent for Ledger Constraints? Why are some code on github and some on haddock?

The repos are these:
https://github.com/input-output-hk/plutus
https://github.com/input-output-hk/plutus-apps
You can import Interval, Contexts, and Constraints like this:
import Ledger.Constraints
import Ledger.Contexts
import Ledger.Interval

In the cabal file you would add them like this:
build-depends: ...
             , plutus-ledger
             , plutus-ledger-constraints


text:
plutus starter course
So I am trying to start a plutus project from scratch, as we are always just editing the .hs source files in the plutus pioneering program homeworks, wondering what are the bare necessary files needed in a repo, and how to set these up? ie cabal.project, hie.yaml, .cabal file, etc.
So far I see this starter. Does anyone have any other resources / tutorials that works on this repo? Would it make sense to have a short lecture on this in the future?

I was looking for a template like this when starting a personal project. I'm sure others will appreciate this too.

I asked Lars the same question in the Q&A, his answer was that your best bet is to copy one of the Plutus Pioneer Program lectures (preferably the last one), remove the unnecessary modules and create your own ones.
So the steps would be:

Chose the lecture you prefer (e.g. week06)
Copy the hash tag of this lecture and build the Plutus repository, as you would doing a lecture's homework

$ git checkout 8a20664f00d8f396920385947903761a9a897fe0
$ nix build -f default.nix plutus.haskell.packages.plutus-core

Copy the chosen lecture directory to your environment

$ cp ./plutus-pioneer-program/code/week06/ ./my-environment/

Rename what you want, remove the unnecessary modules (remember to remove it in your cabal file as well) and add your own ones (add it to the cabal file)

Just bear in mind that you may want to keep this framework in tune with the Plutus code by updating the Plutus commit in project.cabal. There is still a lot of flux in the code as we are still pre-life. It might be best to compare the project.cabal with one from a later Pioneer lecture.

Agreed, I mentioned week06, because that was the last one from the second cohort when I posted the answer

Okay but this limits the use case since tag version is lecture-specific. But I guess as @vcwebco mentions this will constantly be changing - would be good to have site where plutus tag->use case is continuously updated. For now, I take cabal.project from plutus-starter as-is and update .cabal depending on whats missing when I run cabal build. Afaik these are the only two files needed to build from scratch.


text:
ERC20 / ERC721 vs Plutus smart contracts
I thought about curating some literature on ETH and Cardano interoperability and was wondering about ERC20/ERC721 and plutus smart contracts. If I understand it right, ERC20/ERC721 are contract standards that users copy-paste into their code that can later be user-defined. In contrast, Plutus has a native token that can only manipulated via minting policy script.
Is there such a wrapper to convert the ERC20/721 standards into a plutus minting policy script? Or does this not make sense? If not, why?

We already have similar contracts, which are re-used by other more complex contracts (like Uniswap).
Take a look at mintContract which is part of plutus-use-cases package.
Since smart contracts are using Haskell, we also get full namespaces, modules and package support handled for us by Haskell so re-using such contract means adding a correct package to your projects dependencies and importing it.
Note: during Plutus Pioneers course the function was called forgeContract.
I think there's also a ERC20 converter in the pipeline.

Indeed forgeContract has now been changed to mintContract since commit #3403.


text:
Cardano marketplace that allows selling a batch of NFTs
anyone aware of a cardano marketplace that allows us to mint NFTs in batches that will launch with smart contracts launch or at least close to the launch? So e.g. 1 policy ID, 10000 asset names that is available for sale for a week - something like this.
Cheers

You can publish multiple NFTs at once in the following marketplaces:

CNFT.io
Tokhun

authors: Николай Елисеев


text:
illegal symbol `forall` in type, RankNTypes
I am trying to build Future.hs from plutus-use-case from scratch. I take two files from plutus-starter: cabal.project as is, and plutus-starter.cabal that I have to edit according to the imports in Future.hs. I get however these errors when I run cabal build:
src/Plutus/Contracts/Future.hs:574:8: error:
    Illegal symbol `forall' in type
    Perhaps you intended to use RankNTypes or a similar language
    extension to enable explicit-forall syntax: forall <tvs>. <type>

I also had to add several other modules e.g. Plutus.Contracts.Currency and for every .hs file with forall, do I have to add {-# LANGUAGE RankNTypes #-}?

Yes, the LANGUAGE pragmas are required, best practice is probably following Plutus code examples and having separate pragmas per-file as needed.
It is also possible to allow some extensions globally via .cabal file by using default-extensions, e.g.:
library
 default-extensions:
   DataKinds
   RankNTypes

but this should be done with care and can bite later as some extensions are not compatible.
Also instead of adding files locally, try adding plutus-use-cases to the list of your dependencies, then you can import Plutus.Contracts.Currency.

I never thought of adding plutus-use-cases thats helpful!


text:
missing node.socket
so I synced towards Alonzo mainnet with cabal build and interrupted at 92% and somehow ~/cardano/db/node.socket is missing. And no matter how many times I restart the node with
cardano-node run \
--config /home/user/cardano/mainnet-config.json \
--database-path /home/user/cardano/db/ \
--socket-path /home/user/cardano/db/node.socket \
--host-addr 127.0.0.1 \
--port 3001 \
--topology /home/user/cardano/mainnet-topology.json

it gets stuck at
Listening on http://127.0.0.1:12798
[hud-PS63:cardano.node.networkMagic:Notice:5] [2021-09-16 02:17:41.27 UTC] NetworkMagic 764824073
[hud-PS63:cardano.node.basicInfo.protocol:Notice:5] [2021-09-16 02:17:41.27 UTC] Byron; Shelley
[hud-PS63:cardano.node.basicInfo.version:Notice:5] [2021-09-16 02:17:41.27 UTC] 1.29.0
[hud-PS63:cardano.node.basicInfo.commit:Notice:5] [2021-09-16 02:17:41.27 UTC] 48429531f0d3d71fadce9a5971bf56a6df396f2d
[hud-PS63:cardano.node.basicInfo.nodeStartTime:Notice:5] [2021-09-16 02:17:41.27 UTC] 2021-09-16 02:17:41.275947702 UTC
[hud-PS63:cardano.node.basicInfo.systemStartTime:Notice:5] [2021-09-16 02:17:41.27 UTC] 2017-09-23 21:44:51 UTC
[hud-PS63:cardano.node.basicInfo.slotLengthByron:Notice:5] [2021-09-16 02:17:41.27 UTC] 20s
[hud-PS63:cardano.node.basicInfo.epochLengthByron:Notice:5] [2021-09-16 02:17:41.27 UTC] 21600
[hud-PS63:cardano.node.basicInfo.slotLengthShelley:Notice:5] [2021-09-16 02:17:41.27 UTC] 1s
[hud-PS63:cardano.node.basicInfo.epochLengthShelley:Notice:5] [2021-09-16 02:17:41.27 UTC] 432000
[hud-PS63:cardano.node.basicInfo.slotsPerKESPeriodShelley:Notice:5] [2021-09-16 02:17:41.27 UTC] 129600
[hud-PS63:cardano.node.basicInfo.slotLengthAllegra:Notice:5] [2021-09-16 02:17:41.27 UTC] 1s
[hud-PS63:cardano.node.basicInfo.epochLengthAllegra:Notice:5] [2021-09-16 02:17:41.27 UTC] 432000
[hud-PS63:cardano.node.basicInfo.slotsPerKESPeriodAllegra:Notice:5] [2021-09-16 02:17:41.27 UTC] 129600
[hud-PS63:cardano.node.basicInfo.slotLengthMary:Notice:5] [2021-09-16 02:17:41.27 UTC] 1s
[hud-PS63:cardano.node.basicInfo.epochLengthMary:Notice:5] [2021-09-16 02:17:41.27 UTC] 432000
[hud-PS63:cardano.node.basicInfo.slotsPerKESPeriodMary:Notice:5] [2021-09-16 02:17:41.27 UTC] 129600
[hud-PS63:cardano.node.basicInfo.slotLengthAlonzo:Notice:5] [2021-09-16 02:17:41.27 UTC] 1s
[hud-PS63:cardano.node.basicInfo.epochLengthAlonzo:Notice:5] [2021-09-16 02:17:41.27 UTC] 432000
[hud-PS63:cardano.node.basicInfo.slotsPerKESPeriodAlonzo:Notice:5] [2021-09-16 02:17:41.27 UTC] 129600
[hud-PS63:cardano.node.addresses:Notice:5] [2021-09-16 02:17:41.27 UTC] [SocketInfo 0.0.0.0:3001]
[hud-PS63:cardano.node.diffusion-mode:Notice:5] [2021-09-16 02:17:41.27 UTC] InitiatorAndResponderDiffusionMode
[hud-PS63:cardano.node.dns-producers:Notice:5] [2021-09-16 02:17:41.27 UTC] [DnsSubscriptionTarget {dstDomain = "relays-new.cardano-mainnet.iohk.io", dstPort = 3001, dstValency = 2}]
[hud-PS63:cardano.node.ip-producers:Notice:5] [2021-09-16 02:17:41.27 UTC] IPSubscriptionTarget {ispIps = [], ispValency = 0}

Is there a log to check what happened during the interruption? where is this stored (following cabal build documentation)

Please check if there is enough disk space. Node.socket will be created only when the node is running

used about 117gb and 17 gb left. I reran, synced to >91% (database at 14 Gb), stopped the sync - checked andnode.socket= still in db folder, once I rerun cardano-node run ... node.socket= is gone.
is 17gb too little?

At this stage, it is normal that your node.socket does not yet exist because your launch has not passed the step IPSubscriptionTarget {ispIps = [], ispValency = 0}. It usually happens because your cardano-node has not been gracefully stopped.
If it continues from there after 30 min or so (assuming that you have a decent CPU with enough memory) it would be a sign of a hard shutdown. We sometimes have the impression that the program has frozen but it is because your cardano-node needs to scan and verify all the data again so it can take a while.
When you see a line like
Opened vol db

your node.socket will be here again.

Yes there has been some issues where my PC shuts down unexpectedly. But waiting for the node.socket to reappear just needs time!

Try exporting the CARDANO_NODE_SOCKET_PATH again. An exported variable will only remain alive while the user who issued the command is active in their session. You can add this also to a startup script in that user's space.


text:
nix-build alonzo mainnet
I've installed cardano-node via nix-build:
git clone https://github.com/input-output-hk/cardano-node
cd cardano-node
git checkout tags/1.29.0 -b 1_29_0
nix-build -A scripts.mainnet.node -o mainnet-node-local
nix-build -A cardano-cli -o cardano-cli-mainnet

But somehow I end up in the Byron era:
$CARDANO_CLI query tip --mainnet
{
    "epoch": 10,
    "hash": "237925228211660d367c77f6af0b50542ace82985339c55a48fed0ff201a1217",
    "slot": 222403,
    "block": 222371,
    "era": "Byron",
    "syncProgress": "3.55"
}

which script is the correct one for nix-build for alonzo mainnet past HFC event?

You're doing the right thing.
"syncProgress" refers to the percentage of the chain you've synced. Once you get to around 70% it will say "Shelley" and only the most recent epoch will say "Alonzo". This takes a while, unfortunately.


text:
terminology validation and verification
Is there a strictly defined term for validation and verification or are they interchangeable?
Are validations strictly used for transactions e.g. validate a transaction?
Is verification strictly used for on-chain e.g. verification-key-file ?

Being that this whole space is still very young, there is a serious lack of standards in many areas, including and especially semantics. Depending on context, validation and verification can have a few meanings:
Typically, when one is talking about a non-technical aspect of the ecosystem, the terms are interchangeable. For example, It'd make sense to say that I can verify that Alice sent ADA to Bob (provided I know their addresses). In this instance, saying "validate" instead of "verify" makes sense and is appropriate. In other words, the terms are interchangeable when we use them to describe things.
On the other hand, words are sometimes used as technical concepts that refer to very specific things, in which case they are not interchangeable.  For example, a validator script is a technical concept in Cardano's smart contract model; it refers to the part of a smart contract that is executed as on-chain code, used to verify that certain input(s) are valid according the smart contract's intended specification. (Notice how I just used "verify" in a non-technical, dictionary-like manner).
More generally speaking, the term validator is often also used to refer to entities that produce blocks, or participate in on-chain computation (this is non-specific to Cardano). In PoW such entities are often referred to as "miners" and in PoS they are referred to as validators. An SPO such as myself would be considered a validator.
TLDR: strict definitions are hard to come by in emerging and rapidly developing technologies. In this specific case, there is some overlap between interchangeable and non-interchangeable uses of those two words.


text:
cardano-node preprod testnet sync stuck in nix develop, possible headerError
Supposed to run testnet node in nix develop.
which cardano-node outputs /nix/store/y29rzxcr6vswgc5nhmind0cjbkqxi414-cardano-node-exe-cardano-node-1.35.3/bin/cardano-node
seems to be a HeaderError with this command cardano-node run --topology configs/testnet-topology.json --database-path db --socket-path node.socket --config configs/testnet-config.json
The configs I got is from here
This is the log of the node.
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:41.82 UTC] TracePromoteColdPeers 50 0 (fromList [3.72.231.105:30000])
[34m[hud-PS:cardano.node.ConnectionManager:Info:158][0m [2022-11-03 14:25:41.82 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 0})
[34m[hud-PS:cardano.node.ConnectionManager:Info:158][0m [2022-11-03 14:25:41.99 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 1})
[34m[hud-PS:cardano.node.ConnectionManager:Info:159][0m [2022-11-03 14:25:42.37 UTC] TrConnectionHandler (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}) (TrHandshakeSuccess NodeToNodeV_10 (NodeToNodeVersionData {networkMagic = NetworkMagic {unNetworkMagic = 1}, diffusionMode = InitiatorAndResponderDiffusionMode}))
[34m[hud-PS:cardano.node.ConnectionManager:Info:158][0m [2022-11-03 14:25:42.37 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 1, unidirectionalConns = 0, inboundConns = 0, outboundConns = 1})
[34m[hud-PS:cardano.node.PeerSelectionActions:Info:158][0m [2022-11-03 14:25:42.37 UTC] PeerStatusChanged (ColdToWarm (Just 192.168.1.129:42787) 3.72.231.105:30000)
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.37 UTC] TracePromoteColdDone 50 1 3.72.231.105:30000
[34m[hud-PS:cardano.node.PeerSelectionCounters:Info:56][0m [2022-11-03 14:25:42.37 UTC] PeerSelectionCounters {coldPeers = 0, warmPeers = 1, hotPeers = 0}
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.37 UTC] TracePromoteWarmPeers 2 0 (fromList [3.72.231.105:30000])
[34m[hud-PS:cardano.node.InboundGovernor:Info:60][0m [2022-11-03 14:25:42.37 UTC] TrInboundGovernorCounters (InboundGovernorCounters {coldPeersRemote = 0, idlePeersRemote = 1, warmPeersRemote = 0, hotPeersRemote = 0})
[34m[hud-PS:cardano.node.PeerSelectionActions:Info:164][0m [2022-11-03 14:25:42.37 UTC] PeerStatusChanged (WarmToHot (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}))
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.37 UTC] TracePromoteWarmDone 2 1 3.72.231.105:30000
[34m[hud-PS:cardano.node.PeerSelectionCounters:Info:56][0m [2022-11-03 14:25:42.37 UTC] PeerSelectionCounters {coldPeers = 0, warmPeers = 0, hotPeers = 1}
[34m[hud-PS:cardano.node.PeerSelectionActions:Info:162][0m [2022-11-03 14:25:42.94 UTC] PeerStatusChanged (HotToCold (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}))
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.94 UTC] TraceDemoteAsynchronous (fromList [(3.72.231.105:30000,PeerCold)])
[34m[hud-PS:cardano.node.PeerSelectionCounters:Info:56][0m [2022-11-03 14:25:42.94 UTC] PeerSelectionCounters {coldPeers = 1, warmPeers = 0, hotPeers = 0}
[34m[hud-PS:cardano.node.InboundGovernor:Info:60][0m [2022-11-03 14:25:42.94 UTC] TrMuxErrored (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}) (HeaderError (At (Block {blockPointSlot = SlotNo 86400, blockPointHash = c971bfb21d2732457f9febf79d9b02b20b9a3bef12c561a78b818bcb8b35a574})) (HeaderProtocolError (HardForkValidationErrFromEra S (Z (WrapValidationErr {unwrapValidationErr = ChainTransitionError [OverlayFailure (VRFKeyBadNonce (Nonce "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") (SlotNo 86400) (Nonce "90c8bae45d3cb34ef25d84171a74f6e8a4a8f4615fbe289d5a1b21eb6896ac0b") (CertifiedVRF {certifiedOutput = OutputVRF {getOutputVRFBytes = "n\240\190\146\147\245\163\a\ETX{`\183%.\174\153\187\EOT]X\165!\213\186|\141:\161))*\SOH*\147\145\238\255\248\132?5X\179Re\236C%\SOH\178F\136\162\224\162\EMd\252q\207i\194]\174"}, certifiedProof = CertPraosVRF "=C\193CW\205\131\176\249A\248\199\231\165s\252\&6\ESC\135\STX\191\238!\ESC\215\173\177\165\159\149v\254\ESC\209\RS?\163+Z\152.{$n\CAN\ENQ\139\t\159\DC4sb\201\193\138\204C\225\228\232\181\183\198`\234>\217\172[z~\192\254\181\156\207\182G)\EOT"})),OverlayFailure (OcertFailure (InvalidKesSignatureOCERT 1 0 1 "Verification failed"))]})))) (Tip (SlotNo 79922) 3785f8aee4d2369be761572b877358eeb9351404354b97ef965240bdbd602378 (BlockNo 43)) (Tip (SlotNo 11802321) 666c3386466185c49d725d6a1e4ff65e8b26933c4236126cb4182c794d224577 (BlockNo 231597)))
[34m[hud-PS:cardano.node.ConnectionManager:Info:159][0m [2022-11-03 14:25:42.94 UTC] TrConnectionHandler (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}) (TrError OutboundError (HeaderError (At (Block {blockPointSlot = SlotNo 86400, blockPointHash = c971bfb21d2732457f9febf79d9b02b20b9a3bef12c561a78b818bcb8b35a574})) (HeaderProtocolError (HardForkValidationErrFromEra S (Z (WrapValidationErr {unwrapValidationErr = ChainTransitionError [OverlayFailure (VRFKeyBadNonce (Nonce "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") (SlotNo 86400) (Nonce "90c8bae45d3cb34ef25d84171a74f6e8a4a8f4615fbe289d5a1b21eb6896ac0b") (CertifiedVRF {certifiedOutput = OutputVRF {getOutputVRFBytes = "n\240\190\146\147\245\163\a\ETX{`\183%.\174\153\187\EOT]X\165!\213\186|\141:\161))*\SOH*\147\145\238\255\248\132?5X\179Re\236C%\SOH\178F\136\162\224\162\EMd\252q\207i\194]\174"}, certifiedProof = CertPraosVRF "=C\193CW\205\131\176\249A\248\199\231\165s\252\&6\ESC\135\STX\191\238!\ESC\215\173\177\165\159\149v\254\ESC\209\RS?\163+Z\152.{$n\CAN\ENQ\139\t\159\DC4sb\201\193\138\204C\225\228\232\181\183\198`\234>\217\172[z~\192\254\181\156\207\182G)\EOT"})),OverlayFailure (OcertFailure (InvalidKesSignatureOCERT 1 0 1 "Verification failed"))]})))) (Tip (SlotNo 79922) 3785f8aee4d2369be761572b877358eeb9351404354b97ef965240bdbd602378 (BlockNo 43)) (Tip (SlotNo 11802321) 666c3386466185c49d725d6a1e4ff65e8b26933c4236126cb4182c794d224577 (BlockNo 231597))) ShutdownPeer)
[34m[hud-PS:cardano.node.ConnectionManager:Info:159][0m [2022-11-03 14:25:42.94 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 0})

and query-tip shows it is stuck at:
{
    "block": 43,
    "epoch": 3,
    "era": "Byron",
    "hash": "3785f8aee4d2369be761572b877358eeb9351404354b97ef965240bdbd602378",
    "slot": 79922,
    "syncProgress": "11.89"
}

How do I troubleshoot this?

Use config files from https://book.world.dev.cardano.org/environments.html for Pre-Production Testnet


text:
Logistics of Developing Contracts
We've done a lot of development on the Plutus Playground; in what ways will the logistics of developing and deploying contracts differ in Gougen?

All the techniques you have learned for development on the Playground (or using the EmulatorTrace-monad) will still be valuable and relevant for Goguen.
The only difference is that with Goguen, you will additionally write a UI for your contract(s).
But you still need to write on- and off-chain contracts and test them on the Playground or in the EmulatorTrace-monad.


text:
Test-Focused EvaluatorTrace Monad?
Is there infrastructure for writing unit/integration tests for our contracts, without running the full playground?  Is there a test-focused EvaluatorTrace monad, for example?

There are now test capabilities in the Plutus.Contract.Test module which uses the Tasty library.
This is explained more fully in the unit tests section of lecture 8 of iteration 1 of the Plutus Pioneer Program.
Some highlights:
checkPredicate :: String -> TracePredicate -> EmulatorTrace () -> TestTree

There are a number of functions for producing a TracePredicate. For example:
-- | Check that the funds in the wallet have changed by the given amount, exluding fees.
walletFundsChange :: Wallet -> Value -> TracePredicate

Which can then be combined into a test function:
tests :: TestTree
tests = checkPredicateOptions
   (defaultCheckOptions & emulatorConfig .~ emCfg)
"token sale trace"
   ( walletFundsChange (Wallet 1) (Ada.lovelaceValueOf   10_000_000  <> assetClassValue token (-60))
.&&. walletFundsChange (Wallet 2) (Ada.lovelaceValueOf (-20_000_000) <> assetClassValue token   20)
.&&. walletFundsChange (Wallet 3) (Ada.lovelaceValueOf (- 5_000_000) <> assetClassValue token    5)
   )
myTrace

Which can then be run like this:
Prelude Spec.Trace> import Test.Tasty
Prelude Test.Tasty Spec.Trace> defaultMain tests
token sale trace: OK (1.22s)

All 1 tests passed (1.22s)

Naturally, these tests can be configured to run as part of "cabal test".

You can use Plutus Playground to test your code and maybe in the near future we will have more options.


text:
Validator getting access to delegator?
Is it possible for a validator to get access to delegator information? For example, is it possible to lock a token to be redeemable only by someone who is delegating to a specific stake pool?
Additionally, where can we find documentation about translating a staking address to a receive address off-chain, if we wanted to do airdrops manually until the Gougen release?

It is possible to determine wallet addresses from the staking address. There is currently no way to lock a token to be redeemable only by someone who is delegating to a specific stake pool. I assume this will be possible once smart contracts are live.
The simplest way to find other wallet addresses associated with a stake address is to look the address up on Cardanoscan.
If you want some details on how these addresses are derived, checkout Andrew Westberg's video here.


text:
About Fees in the Plutus Playground
I had been reviewing sample codes that can be run in the Plutus Playground, particularly the Vesting.hs code in Cohort #3 Week #3 of PPP.  So while trying several cases in the simulation, I sometimes encounter errors related to fees, so therefore it generated my curiosity on the following questions about fees:

The 10 lovelaces fees charged during the "Give" operation (Vesting.hs), is this a standard fee when sending ada via smart contracts?  Or this setting is intended only for Plutus Playground?  If so, where is this setting defined for Plutus Playground?

I also noticed that the playground throws an error for any value less than 2,000,000 lovelaces that I try to send for simulation of Vesting.hs. So similar to question #1, is this setting a standard for Cardano smart contracts?  Was it set differently from the Mainnet Network?  (I understand that the minimum Ada value in Mainnet is 1,000,000 lovelaces)  If so, where is this setting for Plutus Playground defined?

In the "Grab" operation (Vesting.hs), I noticed that the fee charged to the beneficiary is considerably higher. (When I tried, it is roughly 4,500 lovelaces).  Again, what is the basis of this fee setting?  Where is it defined?

I executed "Give" several times and it made several UTxOs for the beneficiary.  After I performed the "Grab", it charged the beneficiary lovelaces apparently for each UTxO that was created, so it means it charged the beneficiary considerably higher fees.  Is this expected for a Smart Contract operation?  Will this be same expectations when executed in Mainnet?

The default Playground fees are very unrealistic. In reality it starts around 160000 lovelace for a simple tx https://testnets.cardano.org/en/testnets/cardano/tools/plutus-fee-estimator/


text:
Is there a metadata standard for native assets (talking about fungible tokens first) in Cardano?
I've already made preliminary research about the standard.  The below link seem to describe it very well:
https://docs.cardano.org/en/latest/native-tokens/using-the-token-registry/token-registry.html
However, I'd like to ask whether or not is it safe to follow the instructions in the above link when creating my own native assets in Cardano Mainnet? Has anyone have tried to create tokens according to this standard procedure?

As of now, there is no metadata standard/CIP defined for native tokens. But you can follow this CIP PR to know a bit of how the community is trying to define a standard for the same (your inputs are welcome).
Also, you can follow the metadata of some of the NFTs currently live to follow the schematics in case you are going to build a project.

cardanoKnitties
cardanoBits

A direct link to the markup file is easier to follow than the git conversation. Also worth noting the original Cardano forums discussion of the CIP

Thank you for providing information.  As I look on the links provided, the focus is really on NFTs.  I wish some other thread dicusses fungible token standards, as I can see a number of native assets floating around that aren't well defined (Ex.  token's icon/logo image not existing).  But it's good to see how standards for NFT are being discussed by a number of Cardano contributors at least.


text:
How to calculate fees for Plutus Smart Contract?
How can someone calculate fee for executing Plutus smart contract given that they know CPU and Memory Units required for executing Plutus Script?

You can now use fee estimator at https://testnets.cardano.org/en/testnets/cardano/tools/plutus-fee-estimator/

Doesn't really answer the question.  OP or somebody who finds this might be looking for an explanation of the formula rather than a tool to do the calculation.

The formula is a simple multiplication. MemoryUnits X MemoryUnitCost + CPUsteps X CPUstepCost. As for the costs, I honestly don't know the numbers.


text:
Are there any API's I can integrate with to accept Cardano as a merchant?
I run a small tourism startup and I'm looking for an API I can integrate with to accept Cardano on our website. Does anything like this exist? Sadly, neither Coinbase Commerce nor Bitpay are currently supporting Cardano.

To answer my own question, you can currently use https://nowpayments.io/,  https://adapay.finance/, or to roll your own solution https://blockfrost.io/.
There's also an ongoing petition to get Cardano added to BitPay.


text:
Errors while submitting txn from cardano-serialization-lib
I have a working transaction in cardano-cli, but I'm having trouble constructing the same one using the serialization-lib. Does anyone know what these errors mean?? I tried looking into the typescript definitions, but the documentation isn't great.
""transaction submit error ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [
UtxowFailure (NonOutputSupplimentaryDatums (fromList [SafeHash \"9cbcced629edb13ecef78c9c27adfe079a9acd77b62a6693eab0134920a595b9\"]) (fromList [])),
UtxowFailure (ExtraRedeemers [RdmrPtr Spend 1]),
UtxowFailure (WrappedShelleyEraFailure (MissingScriptWitnessesUTXOW (fromList [ScriptHash \"25da22dfd99bf874e59d74c304a1d28e921310327c3e4d6960123f2e\"]))),
UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (UtxosFailure (CollectErrors [NoWitness (ScriptHash \"25da22dfd99bf874e59d74c304a1d28e921310327c3e4d6960123f2e\")]))))])""

See on Github

Did you find a solution to this? I have the exact same issue

I'm experiencing the same problem.

Trying removing the first 6 bytes from your plutus hex :)

how you've been building out your transaction? Have you tried using TransactionBuilder?
It seems like you haven't signed your transaction before you tried to send it to the network.
Here's a link to the cardano-serialization-lib doc where they describe how to build transaction using TransactionBuilder.
Also, you can take a look in the spacebudz repo in the initTx method where the TransactionBuilder is used.
Here's a link to the method


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:
Update Daedalus Cardano CLI version?
I'm currently using the cardano-cli that comes with Daedalus, which according to cardano-cli --version is v1.30.1
Is there any way to update the CLI? I'm trying to access the --required-signer flag which I don't believe was released until the latest alpha version.

To answer my own question, you can build your own version of cardano-cli by cloning the cardano-node Github repo and running a nix-shell, then cabal build cardano-cli. Although I'm not sure how to access this cli outside of the nix-shell.

1.30.1 is the latest version of the cli.  If you're trying to add a required signer, you might want to look at the transaction sign operation on the cardano-cli.

Looks like you've worked through this issue.
For anyone else that finds themselves here:
You can download the binaries (Win/Lin/Mac) or make from source.
Details for each approach are on the github repo https://github.com/input-output-hk/cardano-node


text:
Price regulation of the ADA token
What is the economics behind the value of ADA in fiat currency? Assuming that bitcoin will dominate 100% of the "store-of-value" market, and taking speculation out of the equation, I don't understand where the intrinsic value of the token will be pegged to in the future. For example, if the price of ADA jumps from 1 USD to 10 USD, what are the immediate effects in the blockchain? Does anything happen that pressures the price back down to 1 USD?
It is my understanding that ADA will be useful to fuel smart contracts by collecting transaction fees. These fees are currently fixed by the network and there is no auction dynamics such as in bitcoin, where if you want your transaction to be included in the blockchain fast enough, you need to pay more. But in Cardano, this mechanism doesn't seem to be there.

This seems to be a question asking for opinions rather than facts.  Probably better asked on reddit than here. It needs to be re-worded to be a more factual question or perhaps nominated for removal.

I’m not sure I agree. I’m asking what mechanisms are there for price/value regulation. It was probably studied in research papers but I haven’t seen it. I was hoping someone with better knowledge could point me in the right direction. In other words, is the blockchain efficiency predicted to be independent of the market value of the ADA token? In other words, if the price goes down and stake pools decide to retire, that will pose a security risk for the blockchain and therefore apps like ATALA Prism. What would be the mechanism that would encourage stake pools to stay active?

You could ask this question about any other currency, including USD, EUR, CNY and BTC. What could you reasonably expect of ADA? Central bankers to control rates like for fiat currencies? Armies and diplomats to enforce agendas like in the case of fiat? Government departments to restrict how ADA can be traded? Who gets to decide what the price should be in a way that does not breed centralization or corruption? ADA is just ADA and people do whatever they want with their fiat, which is outside the system of Cardano. I think the short answer to the question is basically a  ¯\(ツ)/¯.

You may get fewer stake pools and greater centralization, but I think the key is not to manipulate the price but to increase and sustain the usefulness of the blockchain, i.e. build up the ecosystem of builders and users. If the blockchain is useful, the price will be sustained. I think if Cardano has to worry about the negative impact of a low price, then Cardano has failed in other aspects like being useful.

I'd like to mention that IOHK just published an article discussing this issue from the perspective of infrastructure maintenance: https://iohk.io/en/blog/posts/2021/06/10/stablefees-and-the-decentralized-reserve-system/

Leaving aside the fact that ADA is exactly as hard as bitcoin, that is, it's hard capped, just happens to be a lot more of them. In a single word: utility. As all business enterprises adoption creates demand for the currency to pay for services of the chain.


text:
Cabal repl is very slow
I've already setup the IOHK binary cache in /etc/nix/nix.conf, yet when I build PPP lecture #2 I have to build many modules.

whereas it seems Lars only has to process one.

Does anyone know why this might be happening?

That should happen only the first time, when you make the cabal repl because it's building all dependencies.
After that, every cabal repl should look like Lars screen.

Not sure how well it works yet, but the latest GHC release does improve on compilation time and memory footprint.
https://discourse.haskell.org/t/ghc-9-2-1-released/3527


text:
How to update lecture #2 code to work with newer versions of Plutus?
I've been trying to load solution #1 for week 2 of PPP into the public Plutus playground here: https://playground.plutus.iohkdev.io/
and I get several errors :/

I am absolutely perplexed. Does anyone know why newer versions of Plutus are having issues with this endpoint code?

I made a walk-through video for that: https://youtu.be/UbTOZWr1-yM
And a corresponding Github repo: https://github.com/manonthemat/GiftContract-109

OMG thank you! This is so much better than what I was looking for haha


text:
Is there any limit to the number of UTXO's sitting at a script address?
Just want to foresee if we'll run into any issues sending/consuming thousands, or tens of thousands of UTXO's at a script address.

Is there any limit to the number of UTXO's sitting at a script address?

There shouldn't be any practical limit.
UTxOs aren't stored in some memory at an address. The address determines who can spend a UTxO, not where it resides. And that address is included on the UTxO, not vice versa.
In other words, when you send UTxOs to an address there is no check on which/how many UTxOs are owned by that address. You are just adding a new UTxO to the blockchain that the intended recipient can identify as their own and spend.
Check out my answer here for more details on how UTxOs are associated with addresses.

Thank you! This is exactly the answer I was looking for :)

@Mitchell Turner Since the address is just a hashed string of the script attached to a UTXO, it doesn’t specify where the UTXO resides. So, what does it mean when you say “send UTXOs to an address” in the third paragraph? Does it mean that we create a new UTXO using the same hashed script AS the address attached to that new UTXO?

I mean when you create any transaction that has an output owned by the script address.
I'm using the term "send" loosely. Similar to when you "send" or transfer funds to another wallet. In reality you aren't "sending" it anywhere, you're just creating a new UTxO who's owner is the recipient of the value in the UTxO.
Sorry if that was confusing. I was intentionally mixing vernacular to draw parallels.

This sounds like a two part question:

Is there any limit to the number of UTXOs stored at a script address
Is there any limit to consuming UTXOs stored at a script address

For the first one, yes and no.  While you can theoretically store as many UTXOs as you like at a script address, there are some resource constraints you're likely to run into:

The size of a single transaction is currently limited to 16k and the max size of a single block is 64k.  And while these numbers are adjustable, this puts an upper limit on the rate of ingestion.
The same issue will apply when you wish to spend the UTXO as well.  16k is the limit for the entire transaction, inputs, outputs, witness, all of it.

For the second question, yes, there are a number of limits on consuming UTXOs:

Within the 16k transaction size limit, the smart contract (currently) needs to fit into that space, significantly reducing the amount of space available for UTXO
Odds are, you'll probably want to do some verifications as well on the UTXOs so cpu and memory execution limits may also play a factor
Like the 64k block size limit, there are also block limits for cpu and memory

I am failing to spend even 10 utxos from the script address because of CPU and memory limits, using AlwaysSucceeds validator. More info:
Transaction memory and cpu usage limits


text:
How to publish a smart contract on the blockchain?
Let's say I have a Plutus contract written up. How do I actually submit it to the blockchain and start interacting with it?

The plutus contract that you have written is in template haskell. Now to convert this to something that can be used on chain one needs to compiled it to plutus core.
From an educational point of view I'll explain how this is done with a concrete example. Take for example the lobster smart contract's used in naming the lobster [1]. Note that this project folder structure contains at least the following 3 files,

A .cabal file in ./
A main.hs residing in ./app/
A smart contract residing in ./src/Cardano/PlutusLobster/

Now what are those files? The .cabal file is a configuration file that tells the compiler how to build the general haskell program at hand. If you look in it you will see all the dependencies listed for building something to plutus core. Also in the end of this file there are three executable defines, that of the 3 yet to build contracts. Now in this file is also a reference to the smart contact in the ./src/... path. Lastly the .cabal file also references the main.hs files for each of those 3 to build contract. If we look into that main.hs file it is some general format that tells the compiler exactly how to compile the plutus script to plutus core (and the serialization of that).
So now you can test it out! Git clone this repo and type cabal run all to build all 3 contracts or cabal run "a name of a executable" as defined at the end of the .cabal file. This will result in 3 contracts in the /scripts/ directory. Note that building this has to be done with ghc version 8.10.4.
Hopes this helps.

Makes sense! Appreciate the detailed response. I totally missed the lobster challenge when it came out, I'll give it a go right now.

As Fermat said, you can follow the lobster example.
Another option is the Exercise 4 of Alonzo-testnet.
Exercise 4 - Solution
There you can find:

Compile hs file
Build script address
Build transactions to interact with the validator script
Sign transactions
Submit transactions

Got it, thank you very much!


text:
How to derive non-extended skey from mnemonic phrase?
See title. I've tried using https://github.com/input-output-hk/cardano-addresses to derive the skey, but it only gives an extended version that I'm unable to sign transactions with using the CLI.
Trying to figure out how to get the standard non-extended signing key.

Let's say your extended signing key is named payment.xkey, in the following format:
{
    "type": "PaymentExtendedSigningKeyShelley_ed25519_bip32",
    "description": "",
    "cborHex": "5880687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe02411ca42fca7e8e17821485144ba42a12a9814279caf665cb9026faaaf85dffeceb8f206b4eaec7ee07722deab4f17e8705afa7fce7d58b347e1e24ff4f031cdc8ce0c1e06e4934512cc678314402f6c04a7cb999d4efdb324f03a416dfcbda498f"
}

Run the following command:
cat payment.xkey | cardano-address key inspect
It will output a 64 byte chain code, and a 128 byte extended signing key. The first 64 bytes of this extended key is what you are looking for. You can manually create the non-extended signing key by copy-pasting these first 64 bytes (exactly half) of the "extended_key" section into an appropriately formatted normal signing-key file. For example, if I run the above command and I get the following:
{
    "chain_code": "e0c1e06e4934512cc678314402f6c04a7cb999d4efdb324f03a416dfcbda498f",
    "extended_key": "687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe02411ca42fca7e8e17821485144ba42a12a9814279caf665cb9026faaaf85dffeceb",
    "key_type": "private"
}

The string you're looking for would be: 687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe0241
Now, use cardano-cli to generate a random, normal signing key file:
cardano-cli address key-gen --signing-key-file payment.skey --verification-key-file payment.vkey
Now, discard the vkey (it is irrelevant), open the payment.skey in an editor, and delete everything in the cborHex field following the 5820, replacing it with the first 64 bytes of the xprv above. This is your non-extended signing key. Final result should look like:
{
    "type": "PaymentSigningKeyShelley_ed25519",
    "description": "Payment Signing Key",
    "cborHex": "5820687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe0241"
}

Repeat the same process for stake-keys, as well as for any other key indexes that are needed.

Thanks for this. However, what worked for me was to pass my root private key (the value starting with "root_") to cardano-address key inspect and not the extended key file you make reference to in payment.xkey.  In other words:
cat root.prv | cardano-address key inspect. This is the command that gave me the JSON with "chain_code", "extended_key" and "key_type".


text:
Is on-chain voting limited to just the Cardano treasury?
I have an idea for a native asset where txn fees are sent to a treasury and token holders can vote on how to spend those funds. Exactly like how Cardano currently works, but for a different purpose (ex. A Miami coin where token holders can vote on proposed projects to improve the city).
Is it possible to build something like this?

I think what you're describing is basically a smart contract.
How you design a smart contract is not limited by anything other than your technical ability, then by your own imagination. You could design a smart contract where any transaction that occurs incurs a small transaction fee and the fee is stored in a designated address or "treasury" address where the UTXO can only be spent by having a vote by holders of the token.
The voting functionality would need an off-chain validator function confirming the person voting indeed has some of the correct native asset, and how much they have. Next you would create functions to submit proposals, which again check that the person submitting a proposal holds that specific native token.
So essentially the smart contract would handle the logic of submitting, voting on, and determining which proposal wins and becomes the future of the dApp/protocol/whatever.
This is what makes blockchain so exciting, it's simply up to your imagination. Look into the Uniswap smart contract for a more in-depth look into creating a smart contract with the functionality you defined.

This was a perfect answer, thank you so much :) My only follow-up question - is it not possible to have the voting occur on-chain?

Well, uhh.. that's essentially what's happening here. You can only execute a smart contract through a UTXO. Nothing happens on Cardano on it's own, it must be triggered by a UTXO which of course means everytime you interact with a smart contract and executing a function that's part of that contract you are "on-chain".

The on chain voting features coming with the Voltaire rollout will allow users to use those voting systems for other things because they are part of the base protocol. So incorporating voting on chain with a plutus contract will be possible.
just not right now.


text:
How to verify a user owns an NFT?
Let's say I have the asset string representing an NFT. How can I verify that a user signed in with Nami wallet owns that NFT? Is there some sort of signature they can provide?

This depends a bit on your use case.
If you just want to look it up on the blockchain: You can query the node with cardano-cli query utxo --mainnet --address <address-to-check>. This gives you all UTXOs at the address and the value and NFTs contained in it.
If you want a smart contract to validate that the user has the NFT: The UTXO with the NFT would need to be part of the transaction and then sent back to the owner. Then some validator can check the context of the transaction if the NFT is included.

The blockchain stores the proof that a particular NFT belongs to a wallet. Whoever controls the wallet own the NFT. Wallet control is determined by access to its private key(signing key). If someone presents a text or number signed by wallet private key then he proves that he controls that wallet.
This is how websites are being connected to wallets.

Thank you! This makes sense to me.


text:
Do old UTXO's ever get pruned from the blockchain?
From what I've read, downloading a full Daedalus node is currently around 6-10GB. Do old UTXO's ever get pruned from the blockchain? If not, what's to stop the size of the blockchain from growing indefinitely to the point where it's impractical to store on consumer hardware?

No, it never gets pruned. One of the appealing features of blockchain is that the history stays there forever.
The size of the blockchain grows roughly linearly (ignoring the effect of adoption), whereas storage capacities follow Moore's Law and grow exponentially. So the expectation is that, yes, the blockchain will grow bigger and bigger, but that that is no problem, because hard drives get bigger (and cheaper) faster.

For the second part of your question (what's to stop the size of the blockchain from growing indefinitely to the point where it's impractical to store on consumer hardware?), there are concepts like sharding and side chains and .... You can watch Charles Hoskinson talking about this topic here.


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:
Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function
I am writing a minting policy that takes half the bytes of one of the eUTXOs being used during mint and encoded them as a base89 readable string then checks that the Asset being minted has as a postfix said string, I am doing this in an attempt to create true NFTs without having different policy ids for each NFT.
To do this I slice the BuiltinByteString with the hash of the eUTXO in half, and then convert it to an int to pass it to the following function:
{-# INLINABLE encodeBase #-}
encodeBase :: BuiltinByteString -> Integer -> BuiltinByteString
encodeBase charset value = encoded where
  base     = lengthOfByteString charset
  encoded  = expand (value `divMod` base) emptyByteString
  lookup n = indexByteString charset n
  expand (dividend, remainder) xs
    | (dividend >  0) = expand (dividend `divMod` base) result
    | (dividend == 0 && remainder >  0) = result
    | (dividend == 0 && remainder == 0) = xs
    where result = consByteString (lookup remainder) xs

charset is also a BuiltinByteString.
But when compiling I get the following error:
GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable GHC.Integer.Type.orInteger

I don't understand, I have been using integers without issue so far in the contracts I have written, what causes this error in this case specifically?
This is the whole script:
{-|
Module      : Horrocubes.MintingScript.
Description : Mint policy for NFTs.
License     : Apache-2.0
Maintainer  : angel.castillob@horrocubes.io
Stability   : experimental

This policy creates an NFT and uses an UTXO to make the NFT truly unique.

This minting policy was taken from https://github.com/input-output-hk/lobster-challenge
and sightly modified to the the token name as an outside parameter.

-}

-- LANGUAGE EXTENSIONS --------------------------------------------------------

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
 {-# LANGUAGE OverloadedStrings #-}

-- MODULE DEFINITION ----------------------------------------------------------

module Horrocubes.MintingScript
(
  mintScript,
  nftScriptShortBs
) where

-- IMPORTS --------------------------------------------------------------------

import           Cardano.Api.Shelley      (PlutusScript (..), PlutusScriptV1)
import           Codec.Serialise
import qualified Data.ByteString.Lazy     as LB
import qualified Data.ByteString.Short    as SBS
import           Ledger                   hiding (singleton)
import qualified Ledger.Typed.Scripts     as Scripts
import           Ledger.Value             as Value
import qualified PlutusTx
import           PlutusTx.Prelude         hiding (Semigroup (..), unless)
import qualified Data.ByteString.Char8    as C
import           PlutusTx.Builtins
import Data.Bits (shift, (.|.))

-- DEFINITIONS ----------------------------------------------------------------

{- HLINT ignore "Avoid lambda" -}

{-# INLINABLE utxoHash #-}
utxoHash:: TxOutRef -> BuiltinByteString
utxoHash utxo = getTxId $ txOutRefId utxo

{-# INLINABLE readInt #-}
readInt :: BuiltinByteString -> Integer
readInt bs =     (byte 0  `shift` 120)
             .|. (byte 1  `shift` 112)
             .|. (byte 2  `shift` 104)
             .|. (byte 3  `shift` 96)
             .|. (byte 4  `shift` 88)
             .|. (byte 5  `shift` 80)
             .|. (byte 6  `shift` 72)
             .|. (byte 7  `shift` 64)
             .|. (byte 8  `shift` 56)
             .|. (byte 9  `shift` 48)
             .|. (byte 10 `shift` 40)
             .|. (byte 11 `shift` 32)
             .|. (byte 12 `shift` 24)
             .|. (byte 13 `shift` 16)
             .|. (byte 14 `shift` 8)
             .|.  byte 15
        where byte n = indexByteString bs n

{-# INLINABLE encodeBase #-}
encodeBase :: BuiltinByteString -> Integer -> BuiltinByteString
encodeBase charset value = encoded where
  base     = lengthOfByteString charset
  encoded  = expand (value `divMod` base) emptyByteString
  lookup n = indexByteString charset n
  expand (dividend, rem) xs
    | (dividend >  0) = expand (dividend `divMod` base) result
    | (dividend == 0 && rem >  0) = result
    | (dividend == 0 && rem == 0) = xs
    where result = consByteString (lookup rem) xs

-- | Creates the minting script for the NFT.
{-# INLINABLE mkNFTPolicy #-}
mkNFTPolicy :: BuiltinByteString -> PubKeyHash -> BuiltinData -> ScriptContext -> Bool
mkNFTPolicy charset _ _ ctx = traceIfFalse "Invalid Posfix" checkMintedAmount
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    expectedPosfix :: BuiltinByteString
    expectedPosfix = encodeBase charset $ readInt $ sliceByteString 16 16 $ utxoHash getUTxO

    actuallPosfix :: TokenName -> BuiltinByteString
    actuallPosfix tn = sliceByteString 10 20 $ unTokenName tn

    getUTxO :: TxOutRef
    getUTxO = txInInfoOutRef $ ((txInfoInputs info) !! 0)

    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
        [(_, tn', amt)] -> (equalsByteString (actuallPosfix tn') expectedPosfix) && amt == 1
        _               -> False

-- | Compiles the policy.
nftPolicy :: BuiltinByteString -> PubKeyHash -> Scripts.MintingPolicy
nftPolicy charset pkh = mkMintingPolicyScript $
    $$(PlutusTx.compile [|| \charset' pkh' -> Scripts.wrapMintingPolicy $ mkNFTPolicy charset' pkh' ||])
    `PlutusTx.applyCode`
     PlutusTx.liftCode charset
    `PlutusTx.applyCode`
     PlutusTx.liftCode pkh

-- | Generates the plutus script.
nftPlutusScript :: BuiltinByteString -> PubKeyHash -> Script
nftPlutusScript charset pkh = unMintingPolicyScript $ nftPolicy charset pkh

-- | Generates the NFT validator.
nftValidator :: BuiltinByteString -> PubKeyHash  -> Validator
nftValidator charset pkh = Validator $  nftPlutusScript charset pkh

-- | Serializes the contract in CBOR format.
nftScriptAsCbor :: BuiltinByteString -> PubKeyHash -> LB.ByteString
nftScriptAsCbor charset pkh = serialise $ nftValidator charset pkh

-- | Serializes the contract in CBOR format.
nftScriptShortBs :: BuiltinByteString -> PubKeyHash -> SBS.ShortByteString
nftScriptShortBs charset pkh = SBS.toShort . LB.toStrict $ nftScriptAsCbor charset pkh

-- | Gets a serizlize plutus script from the given UTXO and token name.
mintScript :: BuiltinByteString -> PubKeyHash -> PlutusScript PlutusScriptV1
mintScript charset pkh = PlutusScriptSerialised . SBS.toShort . LB.toStrict $ nftScriptAsCbor charset pkh

It's because one of the used functions in your INLINABLE functions doesn't belong to Plutus. For example, if you do something like this inside your validator, you'll get a similar error:
numberList :: [Integer]
numberList = [1..5]

It's because .. is not recognized by Plutus.
So, make sure all functions used in your INLINABLE functions are imported from Plutus library.

I would guess that the use of Data.Bits-functions in your on-chain code is the problem.


text:
How to specify the new output datum value (not hash) using the CLI
I have written a script that basically keeps a counter and every time it is spent increases said counter, the way it guarantees that the counter was increased is by checking the current datum of the output and making sure the new datum is current datum + 1 (The script has some additional preconditions which are not important right now):
{-|
Module      : Horrocubes.Counter.
Description : Plutus script that keeps track of an internal counter.
License     : Apache-2.0
Maintainer  : angel.castillo@horrocubes.io
Stability   : experimental

This script keeps a counter and increases it everytime the eUTXO is spent.
-}

-- LANGUAGE EXTENSIONS --------------------------------------------------------

{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE DeriveAnyClass             #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE NoImplicitPrelude          #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TemplateHaskell            #-}
{-# LANGUAGE TypeApplications           #-}
{-# LANGUAGE TypeFamilies               #-}
{-# LANGUAGE TypeOperators              #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE LambdaCase                 #-}
{-# LANGUAGE NamedFieldPuns             #-}
{-# LANGUAGE ViewPatterns               #-}

-- MODULE DEFINITION ----------------------------------------------------------

module Horrocubes.Counter
(
  counterScript,
  counterScriptShortBs,
  CounterParameter(..)
) where

-- IMPORTS --------------------------------------------------------------------

import           Cardano.Api.Shelley      (PlutusScript (..), PlutusScriptV1)
import           Codec.Serialise
import qualified Data.ByteString.Lazy     as LBS
import qualified Data.ByteString.Short    as SBS
import           Ledger                   hiding (singleton)
import qualified Ledger.Typed.Scripts     as Scripts
import           Ledger.Value             as Value
import qualified PlutusTx
import           PlutusTx.Prelude         as P hiding (Semigroup (..), unless)
import           Data.Aeson               (FromJSON, ToJSON)
import           GHC.Generics             (Generic)
import qualified Ledger.Contexts          as Validation
import           Text.Show

-- DATA TYPES -----------------------------------------------------------------

-- | The parameters for the counter contract.
data CounterParameter = CounterParameter {
        ownerPkh    :: !PubKeyHash, -- ^ The transaction that spends this output must be signed by the private key
        identityNft :: !AssetClass  -- ^ The NFT that identifies the correct eUTXO.
    } deriving (Show, Generic, FromJSON, ToJSON)

PlutusTx.makeLift ''CounterParameter

-- | This Datum represents the state of the counter.
data CounterDatum = CounterDatum {
        counter :: !Integer     -- ^ The current counter value.
    }
    deriving Show

PlutusTx.unstableMakeIsData ''CounterDatum

-- | The Counter script type. Sets the Redeemer and Datum types for this script.
data Counter
instance Scripts.ValidatorTypes Counter where
    type instance DatumType Counter = CounterDatum
    type instance RedeemerType Counter = ()

-- DEFINITIONS ----------------------------------------------------------------

-- | Maybe gets the datum from the transatcion output.
{-# INLINABLE counterDatum #-}
counterDatum :: TxOut -> (DatumHash -> Maybe Datum) -> Maybe CounterDatum
counterDatum o f = do
    dh      <- txOutDatum o
    Datum d <- f dh
    PlutusTx.fromBuiltinData d

-- | Checks that the identity NFT is locked again in the contract.
{-# INLINABLE isIdentityNftRelocked #-}
isIdentityNftRelocked:: CounterParameter -> Value -> Bool
isIdentityNftRelocked params valueLockedByScript = assetClassValueOf valueLockedByScript (identityNft params) == 1

-- | Creates the validator script for the outputs on this contract.
{-# INLINABLE mkCounterValidator #-}
mkCounterValidator :: CounterParameter -> CounterDatum -> () -> ScriptContext -> Bool
mkCounterValidator parameters oldDatum _ ctx =
    let oldCounterValue        = counter oldDatum
        isRightNexCounterValue = (newDatumValue == (oldCounterValue + 1))
        isIdentityLocked       = isIdentityNftRelocked parameters valueLockedByScript
    in traceIfFalse "Wrong counter value"           isRightNexCounterValue &&
       traceIfFalse "Wrong balance"                 isIdentityLocked &&
       traceIfFalse "Missing signature"             isTransactionSignedByOwner
    where
        info :: TxInfo
        info = scriptContextTxInfo ctx

        ownOutput :: TxOut
        ownOutput = case getContinuingOutputs ctx of
            [o] -> o
            _   -> traceError "Expected exactly one output"

        newDatumValue :: Integer
        newDatumValue = case counterDatum ownOutput (`findDatum` info) of
            Nothing -> traceError "Counter output datum not found"
            Just datum  -> counter datum

        valueLockedByScript :: Value
        valueLockedByScript = Validation.valueLockedBy info (Validation.ownHash ctx)

        isTransactionSignedByOwner :: Bool
        isTransactionSignedByOwner = txSignedBy info (ownerPkh parameters)

-- | The script instance of the counter. It contains the mkCounterValidator function
--   compiled to a Plutus core validator script.
counterInstance :: CounterParameter -> Scripts.TypedValidator Counter
counterInstance counter = Scripts.mkTypedValidator @Counter
    ($$(PlutusTx.compile [|| mkCounterValidator ||]) `PlutusTx.applyCode` PlutusTx.liftCode counter) $$(PlutusTx.compile [|| wrap ||])
    where
        wrap = Scripts.wrapValidator @CounterDatum @()

-- | Gets the counter validator script that matches the given parameters.
counterValidator :: CounterParameter -> Validator
counterValidator params = Scripts.validatorScript . counterInstance $ params

-- | Generates the plutus script.
counterPlutusScript :: CounterParameter -> Script
counterPlutusScript params = unValidatorScript $ counterValidator params

-- | Serializes the contract in CBOR format.
counterScriptShortBs :: CounterParameter -> SBS.ShortByteString
counterScriptShortBs params = SBS.toShort . LBS.toStrict $ serialise $ counterPlutusScript params

-- | Gets a serizlized plutus script from the given parameters.
counterScript :: PubKeyHash -> AssetClass -> PlutusScript PlutusScriptV1
counterScript pkh ac = PlutusScriptSerialised $ counterScriptShortBs $ CounterParameter { ownerPkh = pkh,  identityNft = ac }

I already locked some funds in the script and I am trying to spent the eUTXO using the CLI and I am having a conceptual issue here, there is no way to specify the new output datum using the CLI, it seems I can only specify the datum hash of the new datum.
cardano-cli transaction build-raw --alonzo-era --fee 500000  --tx-in b2997baf426caa94762e4baeed051ac13bad7994f2f3a43f8c43299d2ba8f050#0 --tx-in b2997baf426caa94762e4baeed051ac13bad7994f2f3a43f8c43299d2ba8f050#1 --tx-in-script-file ./counter/out2.plutus --tx-in-execution-units "(491845099,1197950)" --tx-in-datum-value 0 --tx-in-redeemer-value 0 --tx-in-collateral b2997baf426caa94762e4baeed051ac13bad7994f2f3a43f8c43299d2ba8f050#0 --tx-out "addr_test1wqesjavxsh7g2q8lf92ptyt7rnrhh07ghnyjq65ra50uwwqsssy2q+2000000+1 a1c6cefca22b4527acdf17a1d44674b6d7cf17c3e7e35cbd1a57d8b5.Horrocube09997" --tx-out-datum-hash ee155ace9c40292074cb6aff8c9ccdd273c81648ff1149ef36bcea6ebb8a3e25 --protocol-params-file protocol.json --out-file tx-script2.build

Using the CLI to construct the transaction you need to:

Specify the actual datum value matching the datum hash in the current
eUTXO you want to spend. (--tx-in-datum-value)

Specify the new datum hash for the new eUTXO we are creating
(--tx-out-datum-hash)

However, the script needs both values in the validator as it verifies that the new datum value in the output is equal to the current datum value + 1 but it only has the current datum value and hash AND the new datum hash (not the value).
Using the plutus offchain code I can pass the new datum no problem:
-- | Tries to solve the puzzle at the given index.
solve ::  forall w s. HasBlockchainActions s => SolveParams -> Contract w s Text ()
solve solveParams = do
    let cube = CubeParameter {
        cubeId          = spCubeId solveParams,
        stateMachineNft = spStateMachineNft solveParams
    }
    pkh <- pubKeyHash <$> Contract.ownPubKey
    utxos <- utxoAt $ cubeAddress cube
    addressUtxos <- utxoAt $ pubKeyHashAddress pkh

    let constriants = Constraints.unspentOutputs utxos  <>
                      Constraints.unspentOutputs addressUtxos <>
                      Constraints.otherScript (Scripts.validatorScript (cubeInstance cube))  <>
                      Constraints.scriptInstanceLookups (cubeInstance cube) <>
                      Constraints.ownPubKeyHash pkh

    m <- findCubeOutput cube
    case m of
        Nothing -> logInfo @String "Cube output not found for solve parameters "
        Just (_, _, dat) -> do
            let datum = dat { currentPuzzleIndex = spPuzzleIndex solveParams + 1 }
                redeemmer = CubeRedeemer (spPuzzleIndex solveParams) (spAnswer solveParams)
                totalValue  = Prelude.foldMap (Tx.txOutValue . Tx.txOutTxOut) utxos
                orefs       = fst <$> Map.toList utxos
                payToSelf   = assetClassValue (cubeId cube) 1 -- We must pay to outselves the cube so we can prove ownership of the cube.
                payToScript = (buildValue cube datum (spPuzzleIndex solveParams) totalValue)
                tx = mconcat [Constraints.mustSpendScriptOutput oref (Redeemer (PlutusTx.toData redeemmer)) | oref <- orefs] <>
                              Constraints.mustPayToTheScript datum payToScript <>
                              Constraints.mustPayToPubKey pkh payToSelf
            ledgerTx <- submitTxConstraintsWith @Cube constriants tx
            void $ awaitTxConfirmed $ txId ledgerTx

In fact, using the Plutus code I only pass the new datum value to "submitTxConstraintsWith" which now that I think I also don't understand, where is the Plutus off chain code getting the current datum value from? since the output only store the datum hash? Anyways the Plutus API works. But I am trying to use the CLI to use the contract and I don't see a way to pass the actual datum value (not just the hash) to the script so the validator can run.

I already found the answer and will leave it here in case anyone ran into the same problem.
You need to update the node-cli version to the lastest version (currently)  1.31.0 and then you have the following options available:
 [--tx-out ADDRESS VALUE
              [ --tx-out-datum-hash HASH
              | --tx-out-datum-hash-file FILE
              | --tx-out-datum-hash-value JSON VALUE
              | --tx-out-datum-embed-file FILE
              | --tx-out-datum-embed-value JSON VALUE
              ]]

And now you can specify the value of the new datum instead of the hash:
i.e
transaction build --alonzo-era --testnet-magic 1097911063  --change-address $(cat counter/payment.addr) --tx-in-collateral dc5a8bff48a9db6436559945ceb7a3f311045596407021312c133b1db70d7419#0 --tx-in 7d65ca46aca44532d94da57ec6b7297efdda2e523626f90bbdc780f3767202f2#1 --tx-in-script-file ./counter/out2.plutus --tx-in-datum-value 0 --tx-in-redeemer-value [] --tx-out "addr_test1wpxzyxrdt06f08v5le8h6tgwww9ud7qh4p7w3q8mhndtedg9fdzg2+1000000" --tx-out-datum-embed-value 1 --protocol-params-file protocol.json --out-file tx-script2.build


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:
ogmios startup issue
I have a testnet running and now want to attach ogmios server to the cardano node socket, so as to probe the blocks. The ogmios agent is compiled separately and now when i want to attach it to the socket using:
ogmios
--host 0.0.0.0
--node-config $BASE_CONFIG
--node-socket $SOCKET
I am getting the following output:
config is ./../../src/tconfig/testnet-config.json
socket is ./../state-node-shelly-testnet/node.socket
{"severity":"Warning","timestamp":"2021-10-29T20:47:04.921466233Z","thread":"4","message":{"tag":"OgmiosMetrics","metrics":{"recommendation":"run with '+RTS -T'"}},"version":"v4.0.0-59-gc02eeb5c"}
{"severity":"Info","timestamp":"2021-10-29T20:47:04.922465452Z","thread":"4","message":{"tag":"OgmiosNetwork","networkParameters":{"networkMagic":1097911063,"systemStart":"2019-07-24T20:20:16Z","slotsPerEpoch":432000}},"version":"v4.0.0-59-gc02eeb5c"}
{"severity":"Notice","timestamp":"2021-10-29T20:47:04.926252351Z","thread":"6","message":{"tag":"OgmiosHealth","healthCheck":{"tag":"HealthShutdown","reason":"AsyncCancelled"}},"version":"v4.0.0-59-gc02eeb5c"}
ogmios: Network.Socket.bind: resource busy (Address already in use)

I understand that cardano-node is using the socket and hence that error comes. But how then should ogmios work ?

ok. Later found that even if one runs the ogmios within a docker it actually attaches to the parent cardano-node process socket ! Strange. So only when i killed the docker process, then the host socket was free !


text:
search for wallet address holding native tokens
One particular use case is as follows:

native token is issued and we would like to know the wallet addresses holding this native tokens.
And then use loyalty point based calculation to give rewards to the token holders as these tokens are both acting as governance and as value holding mechanism.

So the question is how would for a particular native token, minted on cardano create such a system. ALGO for example does this for their token. How can i query for a particular native token and get this information at any point in time ?

I would recommend db-sync, graphql or cardano-rosetta for this. The wallet is designed for tracking all addresses associated with one root key. From the perspective of someone wanting to give loyalty tokens to holders, all you care about is what addresses hold utxos containing your token. This has no bearing on if a holder has one address or multiple in a wallet holding the same native token.

If running db-sync is not a solution for you, try /api/v0/assets/{asset}/addresses endpoint at Blockfrost.io.


text:
time locking policy script native asset
I want to ensure a fixed supply of a native asset and this can be ensured by time locking of the policy id using the policy.script below:
    {
  "type": "all",
  "scripts":
  [
    {
      "type": "before",
      "slot": <insert slot here>
    },
    {
      "type": "sig",
      "keyHash": "insert keyHash here"
    }
  ]
}

The above format is created and run. Following error is shown
Syntax error in script: Error in $: "atLeast" script value not found

when the following command is run:
cardano-cli transaction policyid --script-file policy.script

Does anyone have a clue what is going wrong ? thanks.

Just make sure your keyHash is correctly generated.
cardano-cli address key-hash --payment-verification-key-file policy.vkey

I tried your script with correct values and it's working.

Found the error. I had put the slot as a string instead of integer.

Great, in you script supposedly it was an integer because I didn't see any quotes.


text:
Image size for logo for native tokens
I am uploading an image of just 7Kb and still not able to use that as a icon for the native token. Does anyone know why ? I am using the "token-metadata-creator"(https://github.com/input-output-hk/offchain-metadata-tools).

It would be useful to get more information about what error you are seeing.
But according to the CIP:
An icon to be used to represent the subject. Encoded as a PNG image, maximum size 64kb.


text:
How does one count time within a smart contract
Imagine there is a bidding smart contract and i have a maximum time limit set for it. How would i count time within this smart contract in cardano ? Can i get the slotIds and use that as proxy count of time or is there any other way to read time within cardano blockchain ?

You can use either slots or regular time, see https://playground.plutus.iohkdev.io/doc/haddock/plutus-contract/html/Plutus-Contract.html#g:2


text:
Dynamic number of participants in smart contracts
Sample use case: For a DAO smart contract, we would like to add members to a DAO over time. What is the best way to ensure that this can be done. Because in Marlowe the "PARTY" to the contract is defined at the beginning.
One solution can be to issue a certain number of role tokens in the contract. And over a period of time, to distribute these role tokens to DAO participants. But then the question, comes is how do we create multiple role tokens in marlowe contract, for a single "Party". In this case then we create a role called "DAO member" and issue say 1000 tokens for this role.
Any help appreciated ?

Your approach of pre-minting role tokens would work, but with a couple of limitations:

Each role token should probably have a unique name ("DAO Member 1", "DAO Member 2", etc.) so that participants can be separately identified in the Marlowe contract. Otherwise, it would be difficult to prevent the same token holder from voting multiple times.
There is a practical limit to how many roles a Marlowe contract can have. The history of choices made by the contract's roles is stored on-chain in the Plutus Datum of the contract's eUTxO. The Cardano network protocol limits how large a transaction can be, so that effectively limits the number of roles that could participate in a contract. The precise limit depends upon the length of the role-token names and other factors.
Contracts involving many roles tends to be very large. To fit such contracts on the Cardano blockchain, one needs to use a technique called Merkleization, which is supported by the Marlowe language and command-line tool. Using Merleization for a DAO might involve writing some moderately complex off-chain code to manage the Merkleized continuations of the contract.

Overall, Marlowe contracts aren't well suited for use as a DAO. It can work for some use cases for small DAO's, but not for arbitrarily large DAOs. For large DAOs, a Plutus solution or a hybrid Plutus+Marlowe solution would probably be better.

I've never used marlowe before, so I'm not sure the following solution can be implemented in marlowe, but this is certainly something possible.
in theory, you could store a list of "DAO members" on the smart contract's datum, however, practically this isn't possible due to the protocol's transaction size limit.
what you can do is implement a minting policy that mints your "DaoMember" coins (or NFTs) and then require that token to be present in the transaction that interacts with your DAO smart contract.
if the "DaoMember" token is present then the user has access to the member-level smart contract functionalities, if not we treat the user as a regular one with restricted access.
in all this the minting policy is open to mint/burns


text:
How to link fractional Fungible tokens to an NFT?
I have the following scenario. We will be minting NFT for assets and then would like to fractionalise them by minting fungible tokens.
I was wondering how to link together the NFT with the minted fungible tokens (say we issue 1000 tokens linked to an NFT) ? So that later when we want to correlated them, we can do this with confidence ? In other words currently one identifies the fungible tokens using information from token registry (and looking at policy id). But how would I know that this token is linked to an NFT (with a particular policy id).
One way could be to "manually include the original NFT policyid in the offchain token registry .." and then use that information to prove this connection.
Is there any other automated smarter ways to connect the fungible tokens to the NFT metadata ?
thanks.

You are probably lookin for CIP68.
Using this metadata standard, you will be able to lock your NFT within the contact that would hold reference NFT for your fungible tokens.
It is worth to also mention Fracada Il Primo by dcSpark.


text:
how to use the transaction created using. cardano cli to be signed by a wallet in frontend
If we create a transaction body in the backend using cardano-cli for example, and only for signing the transaction would like to get the frontend wallet to sign it, how is this done in the best possible way ?

Basically, there are two ways:

After getting the transaction in the frontend, load the CBOR to CSL (cardano-serialization-lib), and proceed from there.

The workflow would be: build the transaction with cardano-cli, sign it with some random wallet stored in backend, send the signed transaction CBOR to frontend, deserialize the CBOR to CSL Transaction object, remove the witness you signed with in backend, call any wallet extension (eternl, nami..) injected signTx() method and get current user witness, add it to the CSL Transaction object and submit it with submitTx() wallet method.
This worked fine for me with Alonzo era and simple transactions, but had some problems with complicated (inline datums, plutusV2 scripts, etc.) Babbage era transactions. You kind of need to dig deep into CSL to make it work. So I chose the second, easier approach.

Build the transaction using cardano-cli, send it to the frontend in order to retrieve a witness, return both transaction CBOR and witness to backend, assemble the transaction and submit it.

In depth steps:

cardano-cli transaction build-raw --babbage-era --cddl-format ...

build instead of build-raw also works. Do not forget to add --cddl-format flag, in order for frontend sign() method to understand the format. Also you do not need to sign the transaction, only build it.

Send built transaction CBOR to frontend

encodedTxVkeyWitnesses = await window.signTx(cbor, true)

Call signTx() wallet method with received CBOR as a parameter. You will get the encdoded witness, which is basically a proof that user signed the transaction. The resulting hex string will look like this: a10081825820cccfe2be401c85342497f6e1e4a241629790b0fb7f2af5f18441779d11f25b1f5840c38a93d63faac9335ecc2f24ead7ca2d46a6637f354ee707bb06eb8192af2fa6a676fb72f8772cd1c42b491ec6dfc798c76b61c55dc4eecab362e71ffab26305

await handleSubmit(cbor, encodedTxVkeyWitnesses)

Call your backend from frontend, and pass the very same transaction CBOR you received from backend and recently acquired witness CBOR.

$witnessCbor = substr($encodedTxVkeyWitnesses, strpos($encodedTxVkeyWitnesses,'825820'), (strlen($encodedTxVkeyWitnesses) - strpos($encodedTxVkeyWitnesses,'825820')));

Note: example is in PHP. signTx() method returns a bit different witness structure than required by cardano-cli. You basically need to strip first 6 chars from the string. They represent data structure, in this case some nested arrays and stuff. You can look at structure differences here, by comparing both stripped and not stripped hex witness CBOR strings: https://cbor.nemo157.com/
6.
transactionCborFile = '
        {
            "type": "Unwitnessed Tx BabbageEra",
            "description": "Ledger Cddl Format",
            "cborHex": "<transaction CBOR here>"
        }
    ';
    $witnessCborFile = '
        {
            "type": "TxWitness BabbageEra",
            "description": "Key Witness ShelleyEra",
            "cborHex": "<stripped witness CBOR here>"
        }
    ';

Create two files as described above containing transaction and witness CBOR, as cardano-cli assemble command require files as parameters.

cardano-cli transaction assemble --tx-body-file <transaction_cbor_file_path> --witness-file <witness_cbor_file_path> --out-file tx.assembled

Use cardano-cli assemble command to combine both transaction and witness CBOR in order to receive a signed transaction. At this point, transaction is signed and is ready to be submitted.

cardano-cli transaction submit $MAGIC --tx-file tx.assembled

That's it!

I cannot thank you enough I have spent 2 days trying to solve this problem using every permutation I could think of and then I stumbled upon this post after being at my wits end. Thankyou!

I have a different type of example that might be helpful to anyone looking for ways to sign (and build) transactions using both a browser wallet and a server side private key.   Code is here https://github.com/lley154/helios-examples/tree/main/nft-multisig
And video https://youtu.be/CSd9ev_XH5w


text:
Mint NFT and FT tokens in same transaction
Is it possible to mint NFT and FT using same policyID and in the same transaction ?

Yes, you can do this.
The policy doesn't prevent this. The policy is used as a mechanism to prove that the tokens are really issued by the correct entity. E.g. I can't create a second HOSKY token with a different policy and pretend it's the real thing.
You can mint multiple different tokens in one transaction. The only difference between an NFT and an FT is that there should only be 1 of each NFT while there can be more than 1 of any particular FT.
As an example, let's look at the mint transaction of the berry NFTs, 50 NFTs were minted in one transaction. You could simply change the metadata and mint multiple of one of the tokens and you have your FT along with some NFTs: https://cexplorer.io/tx/10d3d8ffd9faf14ebfa57e999a9c448972f21ccbae0bcf9f3cd0ab1240870a6e


text:
How to get around a "withdrawal address format is wrong" error?
I would like to transfer some ADA from a binanceus.com account to a Coinbase Pro account.
To do this, I get a receive address from the Coinbase Pro web site, which I copy-paste as-is to the appropriate blank in the binanceus.com site's funds transfer form.  After I initiate the transfer, it fails immediately with an error of the form:

addr1vyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The withdrawal address format is wrong. Please check the withdrawal address length and character content and try again

(Though I have redacted with X's most of the receive address in the listing above, I have preserved the original number of characters, namely 58.)
I have attempted this multiple times, with new receive addresses from the Coinbase Pro site, with pretty much the same results.  (FWIW, all these other addresses have had the same length as the one shown above, and they all have begun with the addr prefix.)
I submitted a ticket to binanceus.com's customer support several days ago, but have received no answer (other than an automatic "we're really busy" one).

Qs: Is there some alternative format I could use for such an address?  If so, are there tools I could use to safely convert a specific address to this alternative format?  Alternatively, where can I find a description of the algorithm to convert from one format to another, so that I can implement the conversion myself?

It may be that your copy/paste is carrying across more characters than you expect. It may contain a trailing whitespace or non-visible character (e.g. cr or newline).
On Windows, I eliminate this possibility by pasting to notepad and then copying from notepad to the destination.
Try with a small transaction first to verify the process and correct destination address.

well I directly copied the Bitcoin address from Ledger Live and Sparrow Wallet apps and still this error


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

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

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


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

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

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

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

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