text:
How does ledger generate the public keys?
How does the ledger HW wallet generate the public keys it exports to multi-account wallets like Nami/Typhon?
Based on this post by them, it sounds like it might be:

Parent private key is derived from master seed
Many child private keys are generated from the parent private key
The public keys are then generated - one for each child private key

The reason I'm asking is I want to know if I share my Account#0 with someone, do they have a way of knowing my Account#1...n? I looked at the BIP32 standard and it sounds like the answer is no but wanted to check because an additional twist for cardano is the staking address is embedded in the public addresses.
A practical case for this being important is if you do a transaction with someone using Account#0, you don't want them to know your other accounts.

Before activating the accounts feature, I wanted to be sure I can still access my funds even if the wallets using this feature will all disappear (adalite.io, ccvault.io and typhonwallet.io). So I tested it myself with cardano-hw-cli and my ledger device.
The default account starts from the derivation path:

1852H/1815H/0H/0/0 for the payment keys, and the last "0" increments for each ne wkey
1852H/1815H/0H/2/0 for the staking key.
The #1 account starts with:
1852H/1815H/1H/0/0 for the payment keys
1852H/1815H/1H/2/0 for the staking key
And so on: 1852H/1815H/2H/ for the account #2, 3H for the account #3...

I generated a few payment keys and the staking key for the first 5 accounts, then I generated the addresses from them, and compared them with the addresses displayed in the web wallets, and they matched.
Regarding you actual curiosity, I don't think there is any possible way for someone to make a connection between your different accounts. Your payment addresses from one account will be generated from a payment public key and the staking public key, so of course they will be identified by blockchain explorer as being from the same wallet. But I don't see how the different accounts could be linked together.


text:
How to run a Cardano relay instead of a full node?
I want to start a relay node not run the full cardano node.
There doesn't seem to be any tutorials for starting a relay node.
Anyone know how can i just a lightweight relay node so that I can run cardano-cli queries ?
Please note i only have 8 GB memory in docker so I can't afford to run a full node using docker or AWS/Google because they will cost a lot.
Thanks

A relay is a full node. I thibk what you're asking is how can I have a light wallet like experience with cardano-cli and the answer to that is you can't; however you can use something like blockfrost API to get the same type of information cardano-cli can provide.

Oh i see :(, thanks for that, it's because i always run out of resources when trying to build a full node on docker.

As the other answer says there is no real difference, a cardano-node is just configured to become a relay, its the same thing underneath.
If you build cardano-node from source, then you can control the number of threads used to compile with the standard -j flag, -j8 being 8 cores, more cores = more RAM needed.  https://github.com/input-output-hk/cardano-node/blob/master/doc/getting-started/install.md/
Still, actually running cardano-node on 8GB might be a bit too small, RAM optimizations are coming.

source: Stack Exchange

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

sort: votes


text:
Can I manually install cardano-graphql using local data?
I'm running a relay node and have dbsync pushing data into postgresql.
To build the graphql data, do I have to use the weekly restore snapshot as described in the github page for cardano-graphql or can I cut that corner and use my local data somehow?
Does the docker instance run it's own cardano node or just the graphql API?
As a related side question - will my postgresql database be redundant when I have graphql up and running? My use case is extracting transaction metadata.
Thanks!

Welcome to Cardano SE! As a new user be sure to take the [Tour].

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.

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


text:
Cardano Balance While Staking
I am currently staking Cardano in Daedalus 4.6.0. When I started staking, my balance shows up as ***. Can someone please explain why? Thanks

You must have the "discreet" feature turned on - it is the little eyeball towards the top right of Daedalus, just to the left of the notification bell.
To view your balance, simply click the crossed out eyeball, it will uncross and you'll see your balance.

Thanks, that worked!


text:
Transaction fee
Doesn't the transaction cost increase with the increase of Cardano price?  Is there a way to keep the transaction cost constant while raising the price of the Cardano token?

The answers are yes, and yes, respectively.
Cardano is unique in the L1 space in that it has been designed from the start to scale with the number of unique participating nodes, rather than with the hardware capabilities of the whole constituency. For this to work, a separation of the settlement and computation layers is necessary. Until very recently, most of the developmental efforts were geared towards the backbone of the system: the Cardano Settlement Layer (CSL). In the coming months and years, much more focus will be placed on developing the Cardano Compute Layer(s), or CCL. Since the CSL is the backbone upon which  all of the compute layers will rely on, it is designed to be as rigid and stable as possible, almost like a constitution. And since ADA is it's native currency with similarly rigid/fixed qualities, TX fees on the CSL will likely continue to be denominated in ADA for the foreseeable future. The CCLs however, will be a lot more flexible in their capabilities and their governance, including in their ability to accept payments in assets other than ADA.
The purpose of transaction fees (aside from preventing malicious chain bloat) is to compensate node operators for processing data. Since there currently isn't much to "process" except for basic block production/validation on the CSL, operators have no choice but to all play the same game. However, this will not be the case forever, and there will be many games the operators can play on the CCLs (i.e. oracle pools, babel fees, DEX scooping, e.t.c.). As Cardano continues to mature, node operators (currently just SPO's) will become more specialized, and the network will become a lot more distributed as a result (here's a great video by Charles explaining this). In practice, this means that all validator nodes are in competition with each other; all offering the same kinds of services, though in slightly different ways. Likewise, they will be able to specify how much and in what asset they would like to be paid.
In summary, as Cardano evolves, more and more of its total throughput will rely on the market-derived effort of all its constituent nodes, such that each node will have a greater say on what services it offers, and how to be compensated for said services. Therefore, nodes on the CCL will be able to specify that they wish to be paid in, for example, a USD-pegged stablecoin (or any other crypto-asset).


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

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

        let CollatUtxos = [];

        try {

            let collateral = [];

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

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

    }

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


text:
How to check whether my two pubkeyHash is different or not using Haskell?
I'm using this script to check but this doesn't works for me
import    Prelude  hiding (Eq)

mkPolicy :: PubKeyHash -> PubKeyHash -> TokenName -> BuiltinData -> ScriptContext -> Bool
mkPolicy owner1 owner2 name _redeemer ctx = checkOwnerHashDifferent

    checkOwnerHashDifferent :: Bool
    checkOwnerHashDifferent =  Eq owner1 owner2

can someone help me to resolve this?

Eq is a type class and hence will not work as you have used it above.
Assuming that PubKeyHash has an Eq typeclass instance you just need:
    checkOwnerHashDifferent :: Bool
    checkOwnerHashDifferent =  owner1 == owner2


text:
How to create a Cardano private network
I need help with a project proposal, but I think this topic could be interesting for many developers and architects.
Does somebody know how to start to build a private Cardano network or where I can find some tutorials?
The idea would be to build a sidechain as layer two, which utilizes the token of the mainnet as the native coin.
Does the idea have sense? Is it possible? Any suggestion?
Many thanks,
Valerio

For what use do you need it? I think you have two options, either utilize hydra which facilitates isomorfic state channels. Or you could setup a side chain just like cardano.

Alternatively/additionally, check out the Making a Shelley Blockchain from Scratch repo.

The easiest way to create a cardano private network (IMHO) is to clone the cardano-node git hub, start up nix shell, and from there you can start a local cluster.   Works well for me I have a used it many times.
git clone https://github.com/input-output-hk/cardano-node.git
Once nix is completed, you will see the following and type start-cluster
Commands:
    * nix flake lock --update-input <iohkNix|haskellNix> - update nix build input
    * cardano-cli - used for key generation and other operations tasks
    * wb - cluster workbench
    * start-cluster - start a local development cluster
    * stop-cluster - stop a local development cluster
    * restart-cluster - restart the last cluster run (in 'run/current')
                        (WARNING: logs & node DB will be wiped clean)

I also included some tips on how to transfer ada from the gensis address etc. if that would be helpful.  You can go to the tips and tricks section of my readme on The Open Source Cardano Lottery project I created.  https://github.com/lley154/cardano-lottery


text:
How to mint mint NFT with StateMachine
I would like to mint an NFT in a particular state of the state machine
Does anyone know where I can find some examples?

There's a very complete example on how to mint NFTs here.
You can try to add this in the transition part of this state machine.


text:
get wallet skey/vkey from mnemonic
I am trying to get the skey, vkey and address of the first payment address in a wallet I created in cardano-wallet. I need them because I would like to make transactions with cardano-cli on the same wallet. I am working on the testnet.
With cardano-wallet I created the wallet using
cardano-wallet wallet create from-recovery-phrase "test"

I entered my mnemonic phrase, let the second factor empty and set a passphrase.
Everything seems fine and I can have a list of addresses
   {
        "derivation_path": [
            "1852H",
            "1815H",
            "0H",
            "0",
            "0"
        ],
        "id": "addr_test1qzwk908vw9lkpvuth4ch9xlmqxk593xtg7060ve775ja300ur5hrj7gda3wde08v8wx9k8dnf0n9ng0hh4ktmr3hjhts7yurnm",
        "state": "used"
    },
...

So the first address is addr_test1qzwk908vw9lkpvuth4ch9xlmqxk593xtg7060ve775ja300ur5hrj7gda3wde08v8wx9k8dnf0n9ng0hh4ktmr3hjhts7yurnm
I thought I could find the same address by doing:
cardano-wallet key from-recovery-phrase Shelley < phrase.prv > test.xsk
cat test.xsk | cardano-wallet key child 1852H/1815H/0H/0/0 > test.prv
cat test.prv | cardano-wallet key public --with-chain-code > test.pub
cat test.pub | cardano-address address payment --network-tag testnet > test.addr

But I got this address:
addr_test1vzwk908vw9lkpvuth4ch9xlmqxk593xtg7060ve775ja30gg6szrd
I tried with cardano-address I got the same address.
I also try this with cardano-cli:
cardano-cli key convert-cardano-address-key --shelley-payment-key --signing-key-file test.prv --out-file test.skey
cardano-cli key verification-key --signing-key-file keys/test1.skey --verification-key-file test.vkey
cardano-cli address build --payment-verification-key-file test.vkey --out-file test.addr --testnet-magic 1097911063

And I also got addr_test1vzwk908vw9lkpvuth4ch9xlmqxk593xtg7060ve775ja30gg6szrd
When I tried to make a transaction from my wallet to this address, it's seems to be a valid derivative address because all utxo appears when I am checking with
cardano-wallet wallet utxo-snapshot

But I don't understand why I don't have the same address with the same derivative path.
I also checked with yoroi and nami wallet and addr_test1qzwk908vw9lkpvuth4ch9xlmqxk593xtg7060ve775ja300ur5hrj7gda3wde08v8wx9k8dnf0n9ng0hh4ktmr3hjhts7yurnm is the usual address for them
Can someone tell me what I am missing ?
Thank you

You are missing the stake key.
You obtain the stake key pair like this:
cat rootkey.prv | cardano-address key child 1852H/1815H/0H/2/0 > stake.prv
cardano-cli key convert-cardano-address-key --signing-key-file stake.prv --shelley-stake-key --out-file stake.skey
cardano-cli key verification-key --signing-key-file stake.skey --verification-key-file Ext_ShelleyStake.vkey
cardano-cli key non-extended-key --extended-verification-key-file Ext_ShelleyStake.vkey --verification-key-file stake.vkey

And then you can build your address with the stake included (from the keys obtained with the cardano-cli version you posted):
cardano-cli address build --payment-verification-key-file test.vkey --stake-verification-key-file stake.vkey --out-file test.addr --testnet-magic 1097911063

And you use the same stake key pair for all addresses derived from the master key.

thank you, that's exactly what I was missing !


text:
Building a bridge to Hedera Hashgraph HBAR
Hello Cardano community,
Does Cardano have a bridge to Hedera Hashgraph HBAR?  If not, how do I build one?  I need to be able to transfer NFTs and exchange cryptos directly avoiding intermediate cryptos routes.
Thank you,
Will W.

There is no such bridge to my knowledge.


text:
NFT Minting without Metadata
I hope all is well and everyone had a great holiday season. I am having an issue minting NFT's from the CLI they appear to be minting without metadata, even though I am referring to the fully populated metadata.json file used. All variables are correct ($variables are correct) Can anyone toss me a bone at what I'm doing wrong? The NFT does actually mint, just minus all metadata and thus no picture or details about the NFT.
My Minting Command =
cardano-cli transaction build \
--mainnet \
--alonzo-era \
--tx-in $txhash#$txix \
--tx-out $nftwallet+$output+"$tokenamount $policyid.$tokenname" \
--change-address $address \
--mint="$tokenamount $policyid.$tokenname" \
--minting-script-file $script \
--metadata-json-file metadata.json \
--invalid-hereafter $slotnumber \
--witness-override 2 \
--out-file matx.raw

Metadata file -
{
"721": {
"HIDDEN": {
"HIDDEN": {
"name": "NFT NAME HERE",
"image": "ipfs://IPFSLINKHERE",
"mediaType": "image/png",
"description": "DESCRIPTION HERE",
"files": [
{
"name": "PIC NAME HERE",
"mediaType": "image/png",
"src": "ipfs://IPFS LINK HERE"
}
]
}
},
"version": "1.0"
}
}

Please, take a look on this answer: https://cardano.stackexchange.com/a/4882/1231

Could you please include the error that you are getting?

It's likely because your token name doesnt match between the CLI and the metadata.json file. Hard to say since you've hidden them...

It looks like more of a data issue within the metadata json, rather then a problem in the transaction format.
It looks like you're following the https://developers.cardano.org/docs/native-tokens/minting-nfts/
Please note that the --mint="$tokenamount $policyid.$tokenname" \ $policyid and $tokenname, have to match the two HIDDEN fields in the metadata.json
Furthermore, the digital asset (eg. the image/audio/video/whatever) needs to be in a IPFS server. Sometimes some IPFS services are slow at serving/propagating the asset, so a workaround, is to create an account on pinata.cloud and load your asset there. Then you're sure everything is fine.
For further help, can you share a minting transaction hash? This way we can inspect the tx and tell you exactly whats wrong.
If you want to do a test, you can use new policy/image whatever, so you won't share private stuff.
Thanks and good luck

Your metadata file is not structured correctly. Please check CIP 25 - NFT Metadata Standard.
{
  "721": {
    "<policy_id>" {
       ...


text:
Is there a publicly available Cardano API with pre-indexed blockchain data?
I'm looking for a public API that has idempotent endpoints that can be used to query for transaction data for a given address. Specifically, I'm looking for reward payout data. Does this exist in this ecosystem?
Thank you

Yes, have a look at blockfrost.io an API as a service that allows users to interact with the Cardano blockchain and parts of its ecosystem.

Thank you for this

Alternatively you can also try a community driven project https://dandelion.link/

Awesome ill check this one out


text:
BlockFrost API Historical Supply By Epoch Data?
Currently https://cardano-mainnet.blockfrost.io/api/v0/network gets the current network supply data. Does anyone know an endpoint from any API that has historical supply usage data by epoch?

Bumping question - I'm also interested to know if this is possible via API calls.


text:
Plutus V2 Primitives
Does any have (or has anyone found) a simple summary of Plutus V2 Primitives?  They made the short list of big changes in the Vasil fork announcement, so they seem important.  Other than just reading haddock after searching for Plutus.V2, is there a resource for understanding and using the new stuff?
Might be a Lars Office Hours kind of question.

In addition to what Michele said, maybe the following repo helps understand the new cips (1). It has some nice examples on how to use the new functionalities.
Note however that we are currently in the transition of a new cost model on the testnet, we have to wait for epoch 216 I think). After that update Plutus V2 script will become available.

Great repo with enough information to lead me where I want to go.  Thanks @fermat.

If you try to compile the code examples, do not forget to use the next node branch of the plutus-app repository. The main branch is not ready yet for plutusV2, I think.

for this purpose, I found useful the source code itself
in particular, I think a good starting point would be the Plutus.V2 version of TxInfo
other than the new information available there should not be any difference in writing the smart contracts.


text:
Is there any way to mint/airdrop tokens and NFTs to members/users without sending them ADA
I have a game I would like to integrate with the Cardano blockchain and I want a good way to airdrop tokens and NFTs to the users for that game. The ways I have been able to find are:

Mint directly to users -> many small fees and require to send users ADA?
Mint all tokens and later transfer to users -> I have to also send them ADA every time
Use NFT marketplace -> I can not find any which can do this, at least not that has an API
Write smart contract?

Is there any other way I have missed?
Also, using #2 which was my initial plan seems practically impossible since I do not want to send my users ADA just to be able to airdrop a token to them. Are there any smart contracts for this scenario being developed? An other network that I have worked a bit with does not have this limitation, I can simply transfer NFT or tokens for the normal transaction fee.

You can also create minting transactions that are payed by the users directly and you mint directly into their wallets. This should be possible if you interact with their wallet using a DApp connector (right now only Nami has one, but Yoroi should relese one soon, and probably other wallets, too).
I cannot give you an example, I wish I were able to do it myself.
You can also mint the tokens into your address, and put users send 2 ADA to an address to claim tokens, and send them back the tokens and the rest of about 1.8 ADA back with the tokens.

Both those approaches would work if the user buys something in the game, like an NFT, and is what I meant by #1 and #2 in my question. But #2 adds too much complexity for an airdrop to the users, and they have to pay to get the "free" drop. Mint the token directly to the user seems to be the less bad way but I still don't like it since it can incur a lot of smaller fees that adds up, on the other hand I want to use Cardano and not any other network so it seems im stuck between a rock and a hard place..

I've used this technique in practice in a simple dApp I've created (https://native-asset.com/) You could load a nami wallet with some test ada on the cardano test net and see if you think the user experience is good enough.

@Hampus Weslien I could only see minting tokens not distribute them to users, or did I miss something?

Sending Native Assets does require at least 1 ada to be sent along. This is a protection mechanism.
There is a project called Cardanotales that has done this very same thing in the past. They recurred to a minting platform where, after sending X $ada, then a minting transaction was issued to the wallet that originated the payment.
I would recommend the same approach as it seems to be the trusted standard these days.
They do have a twitter account too https://twitter.com/CardanoTales so you might ask directly.
Last but not the least there was a team called ludotoken (https://www.reddit.com/r/cardano/comments/q4ok83/kaizens_interview_with_the_ludotoken_team_amazing/) I can only find this interview. They are building tools for gaming platform like the one you described.
Hope this was helpful!

I just wanted to add some more information if anyone comes here looking for the same answer.
As the two answers before me say, the common practice seems to be that users has to pay ADA to release their tokens. Personally I do not like this approach, but the community seem to be fine with it. After digging around more on this topic I found out that almost all native tokens on Cardano use the https://dripdropz.io/ service. So taking a look at this service might be a good starting point.


text:
How do I use Plutus to check that payment has been made to a native script?
If I want to check that payment has been made to a Plutus script, then I can use the function valueLockedBy txinfo vhash where vhash is the ValidatorHash of the Plutus script. Is there an analogous function to check that payment has been paid to a native script?

I'm confused by what you mean by "native script" vs "Plutus script."

This video introduces native scripts. (As you can see, they are distinct from scripts written in Plutus.)


text:
Verifiying a digital signature in a Plutus script
Is there a function like signedBy that I can call in a Plutus script to verify a digital signature?

So are you looking for a type like this: verifySig :: Signature -> PubKey -> Bool? (signedBy without the tx)?

Well the problem is that a Plutus script calling signedBy will not compile because signedBy is not inlinable. So I need a function that can be called by a Plutus script. The TxId argument isn't a big deal because I can always get that from the ScriptContext.

You can use this function to verify signature from a validator


text:
Nix error trying to install correct GHC version for Plutus
As recommended by Haskell/Nix expert lan Burzynski, I'm trying to use Nix install the correct GHC version for Plutus as follows:
nix shell nixpkgs#haskell.compiler.ghc8107BinaryMinimal nixpkgs#cabal-install

However I get the following
error: flake 'flake:nixpkgs' does not provide attribute
packages.x86_64-linux.haskell.compiler.ghc8107BinaryMinimal',
'legacyPackages.x86_64-linux.haskell.compiler.ghc8107BinaryMinimal' or
'haskell.compiler.ghc8107BinaryMinimal'

Can anyone help?

Installing the compiler using nix-shell -p haskell.compiler.ghc8107BinaryMinimal seems to work. Can't explain why though. I guess it is related to where nix looks for the package.

Thanks for the response! But I thought that commands that contain "-" like nix-shell were deprecated. Is it possible to use "nix-shell" to install ghc and then use "nix shell" thereafter for Plutus development?

You are correct. So I think I know what is causing this. The package haskell.compiler.ghc8107BinaryMinimal is only available in the 23.05 channel and not in the unstable channel. You might have configured your nix to use the nixpkgs-unstable as the default channel, which errors because it is not there. Forcing nix to use the 23.05 channel like so nix shell github:NixOS/nixpkgs/nixos-23.05#haskell.compiler.ghc8107BinaryMinimal will proceed to install the package in your shell. I think nix-shell uses the 23.05 channel by default, which is why that command worked.

Thanks for the tip! I don't get the error message anymore, but after downloading, the process just exits without taking me into the nix shell.

Yeah, in fact that is the expected behavior and you are placed in a nix shell, but with the exception that you keep your existing shell environment with the addition that the downloaded package has been made available to your shell. Running ghc --version should succeed using the correct version. You can exit out of that nix shell by sending the EOF character using ctrl+d.


text:
Cabal build error when compiling simple Plutus code
From inside nix-shell, I run cabal build (after running cabal update) and I get the following error:
Failed to build libsystemd-journal-1.4.5.0.0.0.0.1.
Build log (
/home/eric/.cabal/logs/ghc-8.10.7/libsystemd-journal-1.4.5.0.0.0.0.1-e4cc9aa62753db444ead5dccd6f07aebc3786f63add34b8c61c50f4e70371832.log
):
Configuring library for libsystemd-journal-1.4.5.0.0.0.0.1..
Preprocessing library for libsystemd-journal-1.4.5.0.0.0.0.1..
compiling dist/build/Systemd/Journal_hsc_make.c failed (exit code 1)
rsp file was: "dist/build/Systemd/hsc2hscall112768-0.rsp"
command was: /nix/store/k6yka69n28j47wjhm14h41r2kbv262y6-gcc-wrapper-11.3.0/bin/gcc -c dist/build/Systemd/Journal_hsc_make.c -o dist/build/Systemd/Journal_hsc_make.o -D__GLASGOW_HASKELL__=810 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Idist/build/autogen -Idist/build/global-autogen -include dist/build/autogen/cabal_macros.h -I/nix/store/rqggdpw465knwysk8nc8hs5w1dljkkln-vector-lib-vector-0.12.3.1/lib/x86_64-linux-ghc-8.10.7/vector-0.12.3.1-AounQdOy6Wd4pDDridaQzb/include -I/nix/store/yfdgpr8ivjzprxg8z4g3prmyqk21n7yv-primitive-lib-primitive-0.7.4.0/lib/x86_64-linux-ghc-8.10.7/primitive-0.7.4.0-5BIOLYRlNGvJcfQVHFW6fv/include -I/nix/store/qj45sjydypxwnrnbskzqf6m6ss190sy2-unix-lib-unix-2.7.2.2/lib/x86_64-linux-ghc-8.10.7/unix-2.7.2.2-ETifA5smZTZIWkxyIZe1zI/include -I/nix/store/jzmvd2ckp1hdvbrasqi6mfi8dl1vyc9d-time-lib-time-1.9.3/lib/x86_64-linux-ghc-8.10.7/time-1.9.3-AAq60BtyTvLBxnbhpLzOg0/include -I/nix/store/qbkv38qlsv0yxjk2rwq0zn5l7k00z5m8-bytestring-lib-bytestring-0.10.12.0/lib/x86_64-linux-ghc-8.10.7/bytestring-0.10.12.0-BvIZHiOJL8O7XxUygqQkmw/include -I/nix/store/x2kp6b7xwngvfzrh6pip3did10i08la4-ghc-8.10.7/lib/ghc-8.10.7/base-4.14.3.0/include -I/nix/store/xcrs6mk16vkxlzxginbjmcvi3c0my99w-gmp-with-cxx-6.2.1-dev/include -I/nix/store/x2kp6b7xwngvfzrh6pip3did10i08la4-ghc-8.10.7/lib/ghc-8.10.7/integer-gmp-1.0.3.0/include -I/nix/store/c6sr4xl1qnr69d849wm4p34a0z5bikym-numactl-2.0.14/include -I/nix/store/x2kp6b7xwngvfzrh6pip3did10i08la4-ghc-8.10.7/lib/ghc-8.10.7/include -I/nix/store/5yzcy5fglpifxs34n7afzpg7wk8sjfvb-libffi-3.4.2-dev/include -I/nix/store/x2kp6b7xwngvfzrh6pip3did10i08la4-ghc-8.10.7/lib/ghc-8.10.7/include/
error: Journal.hsc:1:10: fatal error: systemd/sd-journal.h: No such file or directory
compilation terminated.

cabal: Failed to build libsystemd-journal-1.4.5.0.0.0.0.1 (which is required
by academy-project-0.0.0). See the build log above for details.

Can anyone help?
(Is there perhaps a C library that needs to be installed (due to systemd/sd-journal.h: No such file or directory) but isn't the whole point of Nix that it takes care of that sort of thing automatically?)

You probably need to install libsystemd-dev.

I have installed libsystemd-dev but I still get the same error.

What does find / -name sd-journal.h say?


text:
Why is writeToScript reporting that my script costs 0 resources?
I have the following minting script:
{-# INLINABLE verify_mint #-}
script :: () -> V2.ScriptContext  -> Bool
script () _ = (3::Integer) == 2+1

and the following off-chain code to mint a token:
trace :: Trace.EmulatorTrace ()
        trace = do
            Extras.logInfo @Haskell.String "Starting..."
            handle <- Trace.activateContractWallet Test.w1 contract

            Trace.callEndpoint @"mint" handle ()
            Functor.void $ Trace.waitNSlots 5

        contract :: Contract () Schema Text ()
        contract = do
            Contract.logInfo @Haskell.String "Waiting..."
            Contract.selectList [ mint ] >> contract

        mint :: Promise () Schema Text ()
        mint  = Contract.endpoint @"mint" $ \() -> do
            let constraint = Constraints.mustMintCurrency (Scripts.mintingPolicyHash policy) "ABC" 1
            tx <- Contract.submitTxConstraintsWith @TScripts.Any (Constraints.plutusV2MintingPolicy policy) constraint
            Functor.void $ Contract.awaitTxConfirmed (Ledger.getCardanoTxId tx)
            Contract.logInfo @Haskell.String "Minted!"

However when I run writeToScript as follows:
let cmd = Scripts UnappliedValidators
    let config = ScriptsConfig "keystore-stats" cmd
    Haskell.print =<< writeScriptsTo config "x" trace Default.def

I get the following result:
(Sum {getSum = 0},ExBudget {exBudgetCPU = ExCPU 0, exBudgetMemory = ExMemory 0})

How can this be? Shouldn't minting require some resources?

It should. writeScriptsTo is buggy at the moment (not sure why, probably a placeholder has been set while we were working on it and we forgot to change it afterwards).
I'm creating a ticket to fix it.

Is there any other way to find out how much resources my script is taking in the meantime?

I didn't try it but you can use plutus profiling directly.

But how do I obtain the uplc executable? Running "cabal build" in the plutus-apps directory results in an error.


text:
1.) Do all sidechains require their own token, consensus, node operators, etc?
I just finished IOHK’s whiteboard video about sidechains.
https://www.youtube.com/watch?v=04D2BP33YI8
I felt like I absorbed much of the information like NiPoPow’s and the problems that sidechains can solve. However, I am left with a few burning questions:
1.) Do all sidechains require their own token, consensus, node operators, etc?
2.) How does the receiving chain mint the newly transferred coin? How is this even possible? I thought minting was only allowed based on a monetary policy. Is this a special exemption? I understand chain a will burn the token, and chain b will validate bc of the NiPoPow, but I don’t understand how chain b can mint a new token on request.

Sidechains do require their own tokens, consensus protocols, and operators, but there's no reason why all three of those have to be different than the tokens, protocols, and operators of the main chain.
They can be different, which is why sidechains are so flexible and versatile, it really just depends on the needs/purposes of the specific sidechain.
For example, a sidechain (or Hydra Head) whose sole purpose is to scale ADA or native token transactions can use sidechain-ADA on a 1:1 basis to mainchain-ADA, a modified version of Ouroboros that prioritizes speed over security, and a node operator that has already built a solid track record of distributed systems administration (i.e. established SPO's).
On the other hand, a side chain can have its own monetary policy with a (locally) global accounting style and arbitrary tokenomics, or any combination of services.
Sky's the limit!


text:
Can you create a DAO on cardano using only native tokens or would it require a sidechain?
I am researching creating a community-driven dapp with tokenomics similar to steem. Can someone point me in the right direction regarding implementation on the cardano ecosystem? I can not find a lot of information regarding DAO's and sidechains on cardano.

Your question seems to be asking for a technical answer to a non-technical question. As far as I understand it, a DAO is simply a way of conceptualizing a distributed/decentralized system for decision making. The specifics by which such a system is implemented can vary greatly depending on the needs of the organization/application. It can be as simple a trusted relationship between n parties with all transactions on mainchain, to as complex as a hydra head with its own monetary policy facilitating arbitrary business logic.
Really just depends what the DAO is intended for.


text:
Can't run test node on windows
When I try to run cardano-node on windows, it starts to run fine (Opened imm db, Replaying ledger from genesis, etc.), so configuration seems fine, but it exits upon trying to create a named pipe:
CreateSystemdSocketForSnocketPath "\\\\\\\\.\\\\pipe\\\\cardano-node-testnet"
DiffusionErrored CreateNamedPipe ('\\\\.\\pipe\\cardano-node-testnet'): does not exist (The specified path is invalid.)
That UNC-style path above is what I pass as the --socket-path param.  In fact, the docs say this is the path is used by the Daedalus Testnet Wallet for Windows, which is running on my machine.  Any proper pipe path should work, but none do.
Suggestions?
Command (powershell)
./cardano-node run --topology "C:\Program Files\CardanoNode\configuration\testnet-topology.json" --database-path "C:\Program Files\CardanoNode\db" --socket-path "\\\\.\\pipe\\cardano-node-testnet" --host-addr 127.0.0.1 --port 3001 --config "C:\Program Files\CardanoNode\configuration\testnet-config.json"

Version
cardano-node 1.29.0 - mingw32-x86_64 - ghc-8.10
git rev 4c59442958072657812c6c0bb8e0b4ab85ce1ba2

Well, comparing the 2 error messages above gave the answer; I needed to reduce the backslashes passed to --socket-path even though the backslashes reported in output as the pipe it tried to create was correct.  So I have to pass --socket-path "\\.\pipe\cardano-node-testnet" (apparently the cardano-run doubles them).


text:
Smart Contract NFT minting with Rarities
I'm trying to work out how an NFT collection might be sold on Cardano in the future, specifically by making use of smart contracts.
Let's say that I am creating a 10k pfp collection or something of the sort where each NFT has different attributes and therefore there is some sort of rarity distribution. As the creator of the project I can mint all 10k NFTs and transfer them over to a smart contract. For simplicity we'll say there is one NFT per transaction, so I have 10k UTXOs sitting at my smart contract with 1 NFT each.
When someone comes along to purchase an NFT, how can I make it so they are distributed a random NFT. Since they construct the transaction off the blockchain, they can just select the rarest available NFT.
I am able to come up with a mechanism where I might be able to sell placeholder "redeemable" NFTs that people can purchase and send back to the smart contract, but that would require me to then create a transaction on my end where I consume the buyer's placeholder NFT and one of the unpurchased NFT UTXOs to eventually send the buyer their asset. I don't like this solution because the final transaction, the one executed by the creator to send the NFT, can be executed by off-chain code that isn't transparent to the buyers, which would allow for it to rigged or otherwise incorrect in some way, and the buyer's would be unaware.
I apologize if this is the wrong venue for this question, but I'm eager to start writing Plutus code.
Thanks.

I think the problem is that, even if you create some sort of entropy source and force the user to use it to redeem an NFT, they will always be able to see what NFT they will be getting before submitting the transaction, so they could just drop it and wait until they can get the right random value for the one they want. A way could be by committing to the attributes of the NFT via a preimage (hash) on the metadata, and then after all NFTs are sold, reveal the values.

We could use your redeemable approach and make it so the seller cant rig it.
This is the idea, you will need to create 2 different minting policies, one for your NFTs and one for the redeemable NFTs, it is important that both policies do not allow duplication of the asset names (you can do that with something like this https://forum.cardano.org/t/mary-era-nfts-alonzo-era-nfts-which-are-better/82034/24)
Additionally, the policy of the redeemable tokens must allow anyone to burn the token.
So first, you create (but don't mint or reveal yet) the name of your main NFTs, the name of your NFT will have encoded the attributes of the metadata in base 58 for example (or hex even).
And you will have something like:
AwesomeNFT00001mASD34fR342332
The bold part is the encoded metadata.
Then without revealing the asset name of these tokens yet, you create a redeemable token for each, which asset name is the hash of the original token encoded in base58.
AwesomeNFT00001mASD34FR342332 -> FHY45G86DFHY45G86DFHY45G86D
Now you have in policy 1
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.AwesomeNFT00001mASD34FR342332
And in policy 2
0000000000000000000000000000000.FHY45G86DFHY45G86DFHY45G86D (Redeemer token)
And you place all these redeemable tokens in your contract. Once all the redeemable tokens are sold. You then mint the real tokens and place them in a contract with the following condition:
The eUTXO can only be spent if an asset with policy id "0000000000000000000000000000000" and an asset name which is equal to the hash encoded in base58 of the asset name of the token inside this eUTXO is brunt.
Of course, you could have more validations on the contracts, etc.
Now because the contracts don't have access to the transaction metadata, we can't really enforce which values will be there, so this is why I encoded the metadata in the token name instead.
All hashes, encoded values, and policy IDs are dummy values just for demonstration.
In essence, the key would be to commit to the attributes without revealing them, so the buyers cant choose, and the minter cant rig it as they already committed to the value.
I think the current trend of having the NFT attributes in the transaction metadata is not very good, as we can't access these attributes from the contracts, we need to find a better way to express and display attributes on the tokens themselves (and not the transactions)


text:
Yoroi from Daedalus and Ledger nano
I'm sorry if this has been answered elsewhere, I couldn't find it specifically.
If I have been using Daedalus with a Ledger Nano and I download Yoroi on Brave browser (I want to get involved in Sundaeswap), what would I need to do to see the funds in there? Do I need to enter the seed phrase? I heard it's generally not a good idea to be typing that in and you'd prefer to avoid it. Is that true? Thanks in advance.

If you have a Ledger, you can just connect to it in Yoroi, no need to restore with your seed phrase or create a new wallet.
With that said, you never should enter your Ledger phrase anywhere except for a Ledger device that you own. Meaning if your device breaks, buy a new one to restore to.
I hope this helps!

Wonderful, thank you. I have it set up now. One quick question, when I was exporting the public key on my ledger, it said something about Byron? Why would Byron have anything to do with it?

My best guess is you have a Byron era wallet on the ledger. How long ago did you get the wallet?

I just checked my emails and the receipt for my ledger was Feb 5th. So it probably arrived and I had it set up by Mid Feb. I can't remember when we went to Shelley.

Oh weird, the hard fork was July 29th, 2020, so I wouldn't think it would be a Byron wallet. But you can tell by what the address begins with if it is addr it is shelly.

Yeah all mine begin with addr. I tried on a new browser (last time was Firefox, this time Brave). I got the same results - after choosing Ledger Nano S - it pops up a grey box on screen about USB etc. Then on the Nano screen it says Export public key. I click both buttons at once - then I get nothing new on Yoroi. I choose Ledger Nano S again and this time it is saying Byron Account #1 and a bunch of letters and numbers and slashes I wrote down. By the way, it is transacting fine in AdaLite.

When I connected to ADALite it says "Export 6 public keys?" and I choose the tick and it works. I have been looking at the advanced tab and it says Keys: Byron Extended Public Key, Shelley Extended Public Key, Staking Key, Reward Address and Staking Key Hash Hex. I also tried Nami and it works but it didn't have any funds. It turns out that only uses the Account #2 while Daedalus had things setup to use Account #1. Yoroi just seems to have an issue with an old Daedalus Shelley wallet so I'll just use Nami I guess.

Thanks for the update. That is very odd. I have a Ledger as well, so I'll try playing with it and seeing if I have a similar experience.

It is recommended to create a separate wallet in Yoroi and transfer some small test funds to carry out the test. Never enter seed phrase in a website.,Never enter seed phrase in a website. Yoroi is a browser extension. In case you decide to migrate to Yoroi in the future you may need to enter the seed phrase. But please do not do it unless you are quite clear on what you are doing. You can refer to this video Restoring a Daedalus Software Wallet in Yoroi

Just to repeat it is recommended that you create a new wallet in Yoroi and use it for testing.


text:
Is it possible to recover ADA sent to wrong address?
I have sent the ADA token to FTX using BNB network. But FTX doesn't support the ADA token. Is is possible to recover/retrieve the ADA token?
Thanks.

To which address you had sent the ADA if it was not supporting? If you have the address use cardanoscan to find the transaction. It is not possible to retrieve unless the address owner can be found and he send it back.

If querying the chain (either directly through CLI or using an explorer like cardanoscan) shows that ADA has been sent outside of any wallet to which you have the signing keys, you no longer have access to that ADA. Plain and simple. :|
The only workaround is if the receiving address decides to send it back to you.

I wonder if one day someone can create a website where you can just input the address the crypto was sent to and dispute the charge proving if the coins are yours or not. What a simple world that would be lol but then again it’s a decentralized world sadly.


text:
Disable cardano address generation on transaction
I have instances of cardano-node and cardano-wallet.
Can you tell me how to disable auto-creation of an address for each transaction?
I understand that it is not safe, but I need to do it for tests.

Am I correct in understanding that this is not foreseen because it is contrary to EUTxO?

I think you would have to manually calculate the change and provide the change back to the same address as an output to the transaction when using the cardano-wallet transaction builder API.

You can use the same address over and over. There is nothing such as auto-creation. The safety for Shelley addresses is the same.

I think the OP is referring to the auto selection of a change address.


text:
Need to add signatures to plutus-simple-model-transaction
Any idea how to sign a transaction with multiple keys in plutus-simple-model ?

Seeing that source code just adds signature to the txSignatures map, you can call your signTx method multiple times for your different keys followed by sendTx to submit this transaction.


text:
How can I access Haddock documentation for Plutus?
The link to the Plutus documentation - https://playground.plutus.iohkdev.io/doc/haddock/ - is broken. Is there another way to browse the haddock documentation for the latest version of Plutus?

The playground has been discontinued. Haddock can now be accessed at https://input-output-hk.github.io/plutus/master


text:
Unable to convert BuiltinString to JSON
I would like to include a BuiltinString in a datum but am unable to do so as BuiltinString has neither a FromJSON nor a ToJSON instance. Is there an alternative to implementing these instances by hand?

BuiltinString has no ToData instance so it cannot be used as Datum. One option is to encodeUtf8 and use the BuiltinByteString. Not sure why you want to use JSON though.


text:
Onchain validation fails for hard-coded pkh
When modifying the week5 code in e.g. Signed.hs from
mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ unPaymentPubKeyHash pkh

to the hard-coded pkh from Wallet 1,
mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ PubKeyHash "a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2"

the validation fails with
CONTRACT STOPPED WITH ERROR: "\"WalletError (ValidationError (ScriptFailure (EvaluationError [\\\"PT5\\\"] \\\"CekEvaluationFailure\\\")))\""

I verified in the repl:
mockWalletPaymentPubKeyHash (knownWallet 1)
a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2

and also in the offchain code logging Contract.ownPaymentPubKeyHash gives the same a2c2...09c2 hash.
What is going wrong here?
I unsuccessfully tried to debug it with
mkPolicy pkh () ctx = traceError $ decodeUtf8 $ getPubKeyHash $ head $ txInfoSignatories (scriptContextTxInfo ctx)

which resulted in an error as well.
CONTRACT STOPPED WITH ERROR: "\"WalletError (ValidationError (ScriptFailure (EvaluationError [] \\\"BuiltinEvaluationFailure of DecodeUtf8\\\")))\""

What is the correct way to debug this? e.g. in this case to check what the pkh used in the onchain code was? Is decodeUtf8 the right function at all for BuiltinByteString -> BuiltinString in this case or is it a special byte string?

Both wallets call mint endpoint and if you explicitly allow only one of the wallets to mint then it will of course throw error. Try removing or commenting the other wallet's call to endpoint.

@Tuvshintsenguun thanks, forgot to mention this: the EmulatorTrace was adjusted to only have 1 mint call from wallet 1.

This was answered in PPP Q&A, the issue was the string literals in Plutus Core code.
Instead, one has to use variables
{-# INLINABLE mkPolicy #-}
mkPolicy :: PaymentPubKeyHash -> () -> ScriptContext -> Bool
mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $
unPaymentPubKeyHash pkh

and put the literal into the liftCode expression:
policy :: Scripts.MintingPolicy
policy = mkMintingPolicyScript $
$$(PlutusTx.compile [|| Scripts.wrapMintingPolicy . mkPolicy ||])
`PlutusTx.applyCode`
PlutusTx.liftCode (PaymentPubKeyHash "a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2")


text:
Why does building cardano-node require unreasonable amounts of disk space?
What is the reason behind the build process with nix requiring so much disk space when building cardano-node?
I totally understand when video games with 4K videos, high resolution textures, large trained neural networks etc take a lot of space. But shouldn't it just be "code" for cardano-node? Are there any big non-code assets or is there a lot of code duplication? (and anything which can be done about it besides buying a larger disk?)
Building with cabal seems to use a bit less space, but it's still GB's.

When using Nix, you need to download and install a huge amount of Nix related stuff that is not required if you are not using Nix.
I am sure you have heard the expression "the only reason I have seen so far is because I am standing on the shoulders of giants". This is also true for Cardano, which stands on the shoulders of a huge number of libraries.
There are a small number of assests like PDF files, but if you look in the git repos, you will see that they are well over 95% code. However, when you install Nix you are installing binaries (for everything down to the most obvious executables like ls).


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

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

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

Thank you, this worked for me as well.

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


text:
How to new Cardano.Bip32PrivateKey from cborHex in file .skey generate by cardano-cli
I'm trying to new Cardano.Bip32PrivateKey from string cborHex which in file skey generate by cardano-cli
import * as Cardano from "@emurgo/cardano-serialization-lib-nodejs";

function genAccountKey(cborHex: string) {
    return Cardano.Bip32PrivateKey.from_bytes(Buffer.from(cborHex, "hex"))
        .derive(harden(1852)) // purpose
        .derive(harden(1815)) // coin type
        .derive(harden(0)); // account #0

}
genAccountKey("58204022747367deee69f601900e15ddc04fc8024753b6a1539ee2a8bed29832f420");

but I got this err (node:87994) UnhandledPromiseRejectionWarning: Invalid Secret Key size

Is it possible to use .skey(s) and .vkey(s) to construct transactions with the Cardano Serialisation Library? Based on your response it seems as though it is not possible since one cannot backwards derive the necessary privatekeys ...

Welcome aboard.  Your answer isn't an answer but it would make a good question.  Don't forget to check out the [tour] and read some of the pinned messages in the [help/dont-ask]

The CLI key you generate is not the same as Bip32PrivateKey associated with HD Wallet, the Root key you're considering is green box below - while the CLI key is red one. You can derive from parent key to child, but not the other way round.

You can derive a private key from skey CBOR using:
    // Sign with the backend wallet
    const signingKeyHexCBOR = 'THISISYUURKEYCBOR'
    const signingKey = this.S.PrivateKey.from_normal_bytes(Buffer.from(signingKeyHexCBOR,'hex'));

    const vkeyWitness2 = this.S.make_vkey_witness(txHash, signingKey);
    vkeysWitnesses.add(vkeyWitness);
    ```

do you know how to go the other way? Starting from a Bip32PrivateKey to a CBOR string that I can paste into an skey file that can be used to sign a transaction with cardano-cli?


text:
Unlock the Funds in the Script with CSL
I'm building a transaction that using UTXO at script as the input.
Seem I signed enough vkey, perhaps include transactionWitnessSet.set_plutus_scripts.
Finally, i got this error Script inputs not supported yet.
Does anyone know work-around solution? ref: https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/src/tx_builder.rs#L95


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

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

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

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

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

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


text:
Denied Cabal Access to pictures. Now Getting error
Accidentally denied Cabal Access to pictures through a prompt given.  Now, when I try to cabal Init I get this message "User/******/Library/Application Support/MobileSync: getDirectoryContents:openDirStream: permission denied (Operation not permitted)"
Ive tried change permissions in the file with CHMOD and reinstalling Cabal without success. Can anyone help me solve this permissions issue?  Im using a MAC.

I wonder if you need to follow these steps. If Cabal isn't listed as an app, try terminal. https://support.apple.com/guide/mac-help/control-access-to-files-and-folders-on-mac-mchld5a35146/mac


text:
Can there be two identical secret seed phrase generated?
This is an interesting question for me. The first question in my mind was, does "Yoroi" (for example) know my secret seed phrase when I create it? Is it stored somewhere in their servers?
Then I thought to myself, that would be outrageous, it should be generated randomly and only you can know it.
But then, I thought, how can Yoroi's "algorithm" (again using Yoroi for this example) create a seed phrase that is unique to a certain person without (I assume) knowing other seed phrases? (Since it cannot compare seed phrases because it doesn't know other people's seed phrases)
This applies also to other wallets when you create on their platform: Nami, Yoroi, ADALite, etc., etc. (Might be also applicable to other wallets like MetaMask, Phantom, or even Trezor and Ledger).
It's truly a very curious question. Thanks in advance!

The literal answer to your question is yes, the practical answer is no.
Key-derivation is an entirely offline process. CIP-3 talks about how it is currently implemented in cardano (used by all relevant software, including Yoroi, Nami, cardano-cli, etc). A 24-word mnemonic equates to 256 bits of entropy. If generated in a secure fashion, it would take all the computers in the world orders of magnitude longer than the age of the universe to sift through all the possibilities. Ditto for the chances of two identical keys being generated.
It is worth noting that generating your keys using naked Yoroi (no hardware wallet) is not considered secure. The above still applies, but the seed is stored on your computer, and is thus much more likely to be stolen than guessed.
If you'd like to learn more about cardano key-derivation, I recommend the following video by Andrew Westberg: https://www.youtube.com/watch?v=4tSQBK75CPU
It also couldn't hurt to go through BIP-32 and BIP-44 :)


text:
Return tAda using Cardano-CLI
I want to return test ADA to the test faucet. Is there an easy way to return the tAda? I'm using this documentation to create and submit a transaction to testnet: How to create a metadata transaction using cardano-cli
cardano-cli query utxo --testnet-magic 1097911063 --address $(cat payment.addr)

cardano-cli transaction build-raw \
--tx-in dfb99f8f103e56a856e04e087255dbaf402f3801acb71a6baf423a1054d3ccd5#0 \
--tx-out $(cat testfaucet.addr)+999825875 \
--metadata-json-file metadata.json \
--fee 174125 \
--out-file tx.draft

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

cardano-cli transaction submit \
--tx-file tx.signed \
--testnet-magic 1097911063

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 0 (fromList [])) (Value 1000000000 (fromList []))))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (BadInputsUTxO (fromList [TxIn (TxId {_unTxId = SafeHash "dfb99f8f103e56a856e04e087255dbaf402f3801acb71a6baf423a1054d3ccd5"}) 0]))))])

You'd need to set a --ttl <SLOT NUMBER> parameter for the transaction build-raw command


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

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

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

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

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


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

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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

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

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


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

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

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

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

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

will give you slot 90761271.

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

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


text:
Is there an established pathway yet for someone with a purely mathematical background to become a fully equipped Cardano developer? If so, what is it?
Title asks my question. I have a mathematics degree (undergrad) and have dipped a toe in the water of software development in Python, but have no clue where the optimal place to start to become an effective Cardano developer would be. Presumably someone here has walked the path I’m hoping to set out on towards building on Cardano, I’d love some advice.
Thanks in advance.

Welcome, Brody Alden. I feel math and Cardano goes hand in hand. Most of the core team including the founder is a mathematician. However, this is an opinion-based question and it is best suited in the Cardano forum at https://forum.cardano.org/ . Hoping to see you often with technical questions on Cardano here.

You can start learning Haskell which will help you in Math too. Then you can migrate to smart contract development with Plutus. haskell.mooc.fi/ is one of the site for starting Haskell. https://www.youtube.com/watch?v=igV7kMXcdpw is the best material to start learning Haskell.

Take a look on this: https://cardano.stackexchange.com/questions/4444/i-am-completely-new-to-cardano-eco-system-to-learn-it-from-the-absolute-basic

I would suggest reading the book Mastering Bitcoin (https://github.com/bitcoinbook/bitcoinbook) and then following the videos of the Plutus Pioneer Program (https://youtube.com/playlist?list=PLK8ah7DzglhgV7W6BHcoIzRArjzs_UuSY).


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

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

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

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


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

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

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


text:
How can I create babbage era tx. Whats the difference from Alonzo Era?
I can't use my old Tx creator (cardano-cli) from Alonzo era.
Command failed: transaction build  Error:
 The era of the node and the tx do not match.
  The node is running in the Babbage era, but the transaction is for the Alonzo era.
  \n"}

How can I create babbage era tx. Whats the difference from Alonzo Era?

You can probably just add --babbage-era to your cardano-cli transaction build (or build-raw) command. You'll see this option when you enter cardano-cli transaction build -h.
As per this issue and this comment the alonzo-era is still set as the default for now.
Regarding the differences, the babbage era brings lots of new features and possibilities, that you can find a good technical overview of here, including: reference inputs, reference scripts, inline datums and much more.


text:
Build transaction script ERROR in cardano .Not support the policyid with tokenname
this is my transaction build script

cardano-cli transaction build
--mainnet
--alonzo-era
--tx-in $txhash#$txix
--tx-out $address+$output+"$tokenamount $policyid.$tokenname"
--change-address $address
--mint="$tokenamount $policyid.$tokenname"
--minting-script-file $script
--metadata-json-file metadata.json
--invalid-hereafter $slotnumber
--witness-override 2
--out-file matx.raw

And i get this error when i add tokenname with policy id
if i remove the tokenname then its working fine.and also not showing tokenname in cardanoscan

option --tx-out:
unexpected 'N'
expecting alphanumeric asset name, white space, "+" or end of input

Are you using cardano-cli v1.31?
If so, please refer to Errror cardano-cli build-raw: AssetName deserisalisation failed expecting hexadecimal digit

This line is problematic:

--tx-out $address+$output+"$tokenamount $policyid.$tokenname"

One your variables is not set. To try it out, just put echo  in front of the command to print out what the command really is with variables filled in.

--tx-out addr_test1vzzql63nddp8qdgka578hx6pats290js9kmn4uay5we9fwsgza0z3+1400000+1 71421b480f31fd04905d50d0fa5026a459f545acf78ba3f359cc053b.NFT1

above is the echo result of tx-out

authors: PJ Food 優質食材網購批發


text:
how can i show my minted NFT images on cardano testnet
this my minted nft address

https://testnet.cardanoscan.io/transaction/38415ba47ba757b5ccb7240962fc064be56850b19f820e9a837aeed6e56e8081?tab=utxo

Now i wants to show these minted NFT Images to any testnet marketplace if i want to create my own marketplace then how should i display my minted nfts there
or is there anyway to show nfts images to wallet like solana wallet

Also you can fetch all the assets in your wallet using the  BlockFrost Api https://blockfrost.io/, and then set the image src in you HTML to the corresponding IPFS URL.

Adatools has a way to display minted NFTs on the Testnet:
https://testnet.adatools.io/nft

Nami wallet can switch between testnet and mainnet in the settings:

And it also supports visualising your NFTs, though the NFTs I have aren't image files so Nami doesn't load them properly. If the NFT was minted with proper metadata, and contains an image, Nami will load the image from IPFS in place of the big "T" here:


text:
Playground client can't connect to playground server (all localhost)
I am on an Intel based iMac Pro running Big Sur (11.6.1)
I have followed every variant of the local playground setup I can find (all are some version of page 2 in this document https://docs.google.com/document/d/13112LHG9vVvNUs40oZSqZ-DF6_yFiT_SJZ2NaEmjMM4/edit#heading=h.orxckbtlhnnq) and while I can get both the playground client and server to start, and I can load up the playground client web page in my browser, I can't "compile" the code in the playground because of the web page receives 504 connection errors.  So, here is what the playground web page looks like:

And I see these errors in the Plutus-playground-client console when I do anything in the UI:
[HPM] Error occurred while trying to proxy request /api/oauth/status from localhost:8009 to http://localhost:8080 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

[HPM] Error occurred while trying to proxy request /api/contract from localhost:8009 to http://localhost:8080 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
Interestingly enough, if I copy the "compile" request from the chrome inspector as a curl command and adjust the URL to be the playground-server port, The connection to the playground-server is successful and the code compiles, so something seems broken with the client.
Also, using lsof, I have verified that both the server and client are listening on the correct ports.

Not sure if answering my own question is some sort of faux pas, but, figure I will put it in here because I have been banging my head on this one for hours and the fix appears to be very simple.
edit Plutus-apps/plutus-playground-client/webpack.config.js,adding a 'host' param as well as turning off HTTPS (its local dev, https isn't critical here):
devServer: {
    contentBase: path.join(__dirname, "dist"),
    compress: true,
    port: 8009,
    host: '0.0.0.0',<-- Add this
    https: false, <-- Change this from 'true' to 'false'
    stats: "errors-warnings",
    proxy: {
        "/api": {
            target: "http://127.0.0.1:8080",
        },
    },
},

Additionally, I need to specifically build the Plutus-playground-client:
cd plutus-apps
nix-build -A plutus-playground.client
nix-shell
cd plutus-apps/plutus-playground-client
npm run start


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

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

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

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

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

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

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

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

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

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

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


text:
Installing cardano-node: pathspec 'null'
I'm following the instructions here for both Linux and Mac M2 chip...
Both installs are stopped at this instruction, with the following error:

~cardano-source/cardano-node$ git checkout $(curl -s https://api.github.com/repos/input-output-hk/cardano-node/releases/latest | jq -r .tag_name)
error: pathspec 'null' did not match any files(s) known to git
~cardano-source/cardano-node$

Since I don't see any similar queztions here at Stack... I'm guessing I did something wrong, but I don't see it.  Even after going through all the steps again.  Can someone with better eyes than me provide some insight?

This was the previous command >git fetch --all --recurse-submodules --tags

At any rate, git describe --tags seems to match the api doc at the url given; and git describe --tags | git checkout did it in both the mac and linux boxes.


text:
VS Code Remote VM IntelliSense Issues
I was having trouble getting Plutus running properly on Windows & WSL2, so I spun up an Ubuntu Server VM on my Proxmox server and set everything up there. I use VS Code via SSH to connect from Windows. The Plutus application/code and playground run without issue, however, there is no IntelliSense for the Haskell code.
I already have the Haskell extension installed in VS Code for the remote VM (as suggested here: How to get intellisense/auto suggestion working for Plutus in VSCode?). The extension does not have any errors. It does act like it is processing the files, but the types, etc. never appear on hover.
I already have Nix, docker & GHC installed on the VM.
I have tried running it in and out of the devcontainer, but no luck with IntelliSense.
Here is the source code: https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week02
The one thing that did work with IntelliSense was running the following project via devcontainer: https://github.com/input-output-hk/plutus-starter. However, I currently do not understand why this would vary project to project. I even tried replacing the docker image in the pioneer program devcontainer.json with the one from the starter project, but that didn't work either.
The Plutus Pioneer Program is my first foray into the Haskell ecosystem, so I'm sure it is something fundamental that I have misunderstood. Any clarity on this would be much appreciated.

Unfortunately this doesn't work in the plutus pioneer program weeks so far (currently week03). Your IDE uses the haskell language server to get type references but if you run the command haskell-language-server in a nix-shell in the current week's repository you will get an error. This is documented in this question: HLS Compiler Error PPP Week01 (WSL2 + VSCode)


text:
Where is the best place to start looking for Haskell Developers?
I'm looking to hire developers for a project and most people I speak with have experience with Solidity and therefore trying to convince me to focus on the Ethereum ecosystem.
I like what the Cardano community is doing, especially the Founder's vision and approach, and accordingly want to focus on the Cardano ecosystem. I'm therefore looking for developers with Haskell experience and don't know where to start. Is there an area within the Cardano community to specifically post jobs and recruit individuals desiring to work on Cardano?

Keep doing that^, and they will come.

You can post your opportunities on IOHK discord. There is a #post-a-job channel, under Lounge category.

I find the Haskell to be still rather niche language, meaning not so many developers out there, thus it's difficult to find someone on common boards.
I would agree with the others that it's a good idea to be looking specifically around Cardano, Haskell and functional programming communities

A nice place worth checking is functional.works-hub.com
functionalprogramming.slack has numerous channels for job postings (#jobs, #haskell-jobs)
Cardano official developer community list


text:
Formatted error messages in Playground
Is there any way to get the Playground errors with proper indentations?
This can help read better the issue at hand.
Instead of getting one huge line:
(Tx {txInputs = fromList [TxIn {txInRef = TxOutRef {txOutRefId = 183d5544f89d5e0a5cfcbd8330c73a5f629925ed5f076b5a1b06e60a35147d4c, txOutRefIdx = 2}, txInType = Just ConsumePublicKeyAddress}], txCollateral = fromList [], txOutputs = [TxOut {txOutAddress = Address {addressCredential = PubKeyCredential a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2, addressStakingCredential = Nothing}, txOutValue = Value (Map [(,Map [(\"\",100000000000)])]), txOutDatumHash = Nothing},TxOut {txOutAddress = Address {addressCredential = ScriptCredential 8c770b7ff9ed4a5df36ca914d18723596df69556597678d9872e2158, addressStakingCredential = Nothing}, txOutValue = Value (Map [(66,Map [(\"T\",1)])]), txOutDatumHash = Just 50536f27f0948527e1df0489a97781d16155f92623b8559e00e7341f2fb0f24d}], txMint = Value (Map []), txFee = Value (Map []), txValidRange = Interval {ivFrom = LowerBound NegInf True, ivTo = UpperBound PosInf True}, txMintScripts = fromList [], txSignatures = fromList [(8d9de88fbf445b7f6c3875a14daba94caee2ffcbc9ac211c95aba0a2f5711853,b129c9922646ca3d0b1fb5349ce515d4b4aca392825794478df4479182f8e2d53c5157829cf1c72628bb7b419cafd131cfcab251188af2c9e9c5064e03045d08)], txRedeemers = fromList [], txData = fromList [(50536f27f0948527e1df0489a97781d16155f92623b8559e00e7341f2fb0f24d,Datum {getDatum = Constr 0 [Constr 0 [B \"\\162\\194\\fw\\136z\\206\\FS\\217\\134\\EM>Nu\\186\\189\\137\\147\\207\\213i\\149\\205\\\\\\252\\230\\t\\194\",I 1596059101,I 100000000,B \"f\",B \"T\"],Constr 1 []]})]}) (Lovelace {getLovelace = 2000000})))" ]

To get more something more like:
Tx {
  txInputs = fromList [
    TxIn {txInRef = TxOutRef {txOutRefId = 183d5..47d4c, txOutRefIdx = 2}, txInType = Just ConsumePublicKeyAddress}
  ],
  txCollateral = fromList [],
  txOutputs = [
      TxOut {
        txOutAddress = Address {addressCredential = PubKeyCredential a2c20c778..09c2, addressStakingCredential = Nothing},
        txOutValue = Value (Map [(,Map [(\"\",100000000000)])]),
        txOutDatumHash = Nothing
      },

Welcome to Cardano SE! As a new user be sure to take the [Tour].

I don't think there is a pretty printer for this (yet). But you could file an issue/feature request with plutus.

Great thank you Angeman!


text:
Why unstable functions?
What is the benefit of using unstable functions if those should not be used in production?
Can you name an example use case in favour of the unstable versions?

I think the best use case for unstableMakeIsData is for rapid prototyping. You can use it without having to know the target type's constructor. This also means you don't have to change the call to it every time you change the type while developing the contract.
Ultimately, once the type is more solidified, you'll want to use makeIsDataIndexed with an explicit mapping of the constructor. This is the more "strict" and safe way to do it for production.

MuesliSwap uses unstableMakeIsData in its validator too. Is there really a use case for makeIsDataIndexed ? (see: https://github.com/MuesliSwapTeam/muesliswap-cardano-contracts/blob/main/order-validator/src/Cardano/MuesliSwapOrderValidator/OrderValidator.hs)

That's really bad practice and ideally should be caught in code audit.


text:
ppp Class 4: What happens when a contract is called while it is not waiting?
The off-chain contract code is recursive, holds and waits until endpoint is called, then executes code (gets busy for a little while), then recurses.
What happens when a endpoint is called while the contract code is "busy" handling another previous call, hence it is not listening.

The endpoint is a Promise - which is asynchronous. When called multiple times with different ContractInstance, it works without any conflicts.
What happens when an endpoint is called twice by the same ContractInstanceId can be found here


text:
(ppp Class 3). Parameterized contracts. What's the benefit for given example? and more use cases
In the auction example (Class 2), the endpoint for Grab just only requires the Wallet as parameter. The wallet and the validator will retrieve all UTxOs for that wallet that are available (past their deadline).
In class 3 example, now there cannot be a grabAll endpoint because the deadline is a parameter, so I did not see a benefit in this approach, please enlighten me.
Can you please provide more examples where this is actually useful?

The benefit is limiting scope of addresses to scan to the beneficiary (and deadline). The reason you'd want to do this is say 1 million people are using this contract. Someone redeeming would need to filter through millions of utxos with the first approach but in the second only has to look at utxos associated with them. The homework switching this to 50/50 approach takes the best of both worlds. All utxos found are for the beneficiary but then you can filter on the datum for all transactions that are vested to redeem.

In class 3 example, now there cannot be a grabAll endpoint because the
deadline is a parameter, so I did not see a benefit in this approach,
please enlighten me.

Can you please provide more examples where this is actually useful?

As you said, the deadline is the parameter and as I understand it one can actually 'grabAll' as long as the deadline parameter of that particular grab is after all the deadlines specified by the gifts.
I think the example is useful in cases if you want to stagger the redemption of the gifts by beneficiaries into different deadlines or slots or specific times.

Here is a real example on Cardano mainnet and how one of the decentralized exchanges uses it. https://twitter.com/adax_pro/status/1488524779686608903


text:
Is there any script or smart contract which send tokens?
I wondering if is there any script o smart contract example which when i send X ada to a wallet after i receive a native token

You can do this with multisignatures (no smart contract required). Because of how flexible the (e)UTXO model is, it's possible to construct a transaction that spends from two different addresses, as long as both of the parties involved sign the transaction with their signing key. Imagine party A has 10 ADA, and party B has 1 native asset lets call it XDA, the aim is for party A to buy one XDA from party B in exchange for 10 ADA.
Party A: build Tx with their own utxos as input, and as output they set 10 ADA to party B, and then they add another input using the UTXO of party B, and as output they set 1 XDA to party A address. So you get a transaction like so:
INPUTS
  partyAUtxo [containing ADA]
  partyBUtxo [containing XDA]

OUTPUTS
  10 ADA -> partyBAddress
  1  XDA -> partyAAddress

party A now signs this transaction and sends the serialized signed transaction to party B. Now party B verifies that the trade seems fair (simply checking the price is fair or whatever), signs it with their keys and submits the transaction to the blockchain.
This constructs an atomic swap in a SINGLE TX, which would require two transactions if using a smart contract (lock, and unlock).
I would include the code here, but it'd require quite a bit of code to give you a working demo so I can just guide you to checkout cardano-serialization-lib, and Nami wallet - these two libraries/APIs provide all of the above functionality in terms of getting UTXOs, constructing transactions from UTXOs with custom outputs, building/serializing the transaction, signing it with a wallet, and submitting a transaction to Blockfrost. If I get a simple demonstration of this in action soon I will update here.

There are no such example that I know of, but you can create one, by monitoring an incoming address for new transaction and trigger a faucet server, something like cardano-faucet.
If you are looking for a smart contract and not a federated solution, you are probably thinking about a token swap.
In the Plutus Pioneer Program, the Lecture #10 explains an uniswap contract, which might be helpful to you.


text:
How to deploy a marlowe smart contract on cardano
I'm  a beginner, I have the haskell code and I wnat to know the following steps, I couldn't find specific information how can i deploy a smart contract on the mainet or testnet.

Submitting transactions on Cardano is a bit like submitting your taxes to the federal agency. The agency won’t tell you how to compile the documents and how to calculate the amount due, but it will check them and tell you if you did something wrong (actually only if the mistake is at their disadvantage. It is not a perfect analogy).
The Cardano blockchain is this federal agency. It will check the transaction and validate the smart contracts. But is has no knowledge of how to construct this transaction. This logic is implemented in your off-chain code. This code is as the name says never deployed to the blockchain. It needs to be executed by someone, though. In a centralized service it is usually the server backend of the party that provides the service. But you can also make the off-chain scripts publicly available so that anyone can use them.

Here are lectures that explain the process of running Marlowe contracts on the Cardano blockchain. The third lecture includes a step-by-step example.

Here is a tutorial that should help you get started with executing your Plutus script.
Plutus scripts are not actually "deployed" to the blockchain, rather once they are serialised to Plutus (from Haskell or other languages) they are used to generate script address and then are submitted to the generated address in a transaction.
The tutorial should walk you thought on how to submit transaction once you have serialised plutus script.

The question was about Marlowe, not Plutus, and I have the same question.  It is really hard to understand why simple things seem so difficult.  Is there any way, in Feb 2022, to enter into even the simplest possible financial contract with somebody else, without writing your own Plutus script?  Thanks :)

authors: موقع شقق العقاري