text:
Testnet relay doesn't have any incoming peer connections other than my BP node
I just recently set up a stakepool on the Testnet.  I am running v1.32.1 of Cardano-node on both my relay and BP. Each node (relay and BP) are EC2 instances within the same VPC, and both are running the AWS version of Linux.  I have also verified that I can reach my relay's IP and port from the internet.  But when I run gLiveView on my relay, I only see one incoming peer connection, and both total and pending tx's are at 0.  The pool has been up and running for a couple of days now, so I am not sure if I have something misconfigured or if it just takes a bit of time for my relay to be discovered by the network?

Also, I set up the topology updater script, and when I run it manually, its successful:
{ "resultcode": "201", "datetime":"2021-12-29 22:45:01", "clientIp": "3.142.120.205", "iptype": 4, "msg": "nice to meet you" }

But when its running in cron, it always errors out:
{ "resultcode": "502", "datetime":"2021-12-29 23:33:03", "clientIp": "3.142.120.205", "msg": "invalid blockNo []" }

How would I go about troubleshooting this?
Linux Info:
Linux version 5.10.82-83.359.amzn2.x86_64
(mockbuild@ip-10-0-37-156)
(gcc10-gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1), GNU ld version 2.35-21.amzn2.0.1) #1 SMP Tue Nov 30 20:47:14 UTC 2021
Update:
I forgot to mention in the original post the ticker I am using is "HLTH".  Here is the link to the pool in Cardanoscan: https://testnet.cardanoscan.io/pool/614235f4d6c44cfc46a1ee16c95eb6d10008204c830d056f188e7677
I see now that my ticket isn't showing up, so maybe I have screwed up something with my metadata?
Here is the topologyUpdater.sh script I am using, I got this from the coin cashew tutorial:
#!/bin/bash
# shellcheck disable=SC2086,SC2034

USERNAME=ec2-user
CNODE_PORT=6000 # must match your relay node port as set in the startup command
CNODE_HOSTNAME="CHANGE ME"  # optional. must resolve to the IP you are requesting from
CNODE_BIN="/usr/local/bin"
CNODE_HOME=/home/ec2-user/cardano-src/relay
CNODE_LOG_DIR="${CNODE_HOME}/logs"
GENESIS_JSON="${CNODE_HOME}/testnet-shelley-genesis.json"
NETWORKID=$(jq -r .networkId $GENESIS_JSON)
CNODE_VALENCY=1   # optional for multi-IP hostnames
NWMAGIC=$(jq -r .networkMagic < $GENESIS_JSON)
[[ "${NETWORKID}" = "Mainnet" ]] && HASH_IDENTIFIER="--mainnet" || HASH_IDENTIFIER="--testnet-magic ${NWMAGIC}"
[[ "${NWMAGIC}" = "764824073" ]] && NETWORK_IDENTIFIER="--mainnet" || NETWORK_IDENTIFIER="--testnet-magic ${NWMAGIC}"

export PATH="${CNODE_BIN}:${PATH}"
export CARDANO_NODE_SOCKET_PATH="${CNODE_HOME}/db/socket"

echo Network Identifer: ${NETWORK_IDENTIFIER}
blockNo=$(cardano-cli query tip ${NETWORK_IDENTIFIER} | jq -r .block )

# Note:
# if you run your node in IPv4/IPv6 dual stack network configuration and want announced the
# IPv4 address only please add the -4 parameter to the curl command below  (curl -4 -s ...)
if [ "${CNODE_HOSTNAME}" != "CHANGE ME" ]; then
  T_HOSTNAME="&hostname=${CNODE_HOSTNAME}"
else
  T_HOSTNAME=''
fi

if [ ! -d ${CNODE_LOG_DIR} ]; then
  mkdir -p ${CNODE_LOG_DIR};
fi

curl -s "https://api.clio.one/htopology/v1/?port=${CNODE_PORT}&blockNo=${blockNo}&valency=${CNODE_VALENCY}&magic=${NWMAGIC}${T_HOSTNAME}" | tee -a $CNODE_LOG_DIR/topologyUpdater_lastresult.json

Additionally, here is my Testnet-topology.json file.  I decided to try swapping in the IP addresses of each relay, and so I could remember which ones were which I put the DNS name of the relay into the "continent" field.
    {
        "Producers": [{
                "addr": "172.31.25.89",
                "port": 6000,
                "valency": 1
        },
        {
                "addr": "relays-new.cardano-testnet.iohkdev.io",
                "port": 3001,
                "valency": 2
        },
        {
                "addr": "64.225.4.242",
                "port": 3001,
                "valency": 2,
                "continent": "relays.testnet.stakenuts.com",
                "state": "New Jersey"
        },
        {
                "addr": "34.223.107.64",
                "port": 3001,
                "valency": 2,
                "continent": "testnet-relays.onyxstakepool.com",
                "state": "Oregon"
        },
        {
                "addr": "89.162.88.186",
                "valency": 2,
                "port": 9015,
                "valency": 2,
                "continent": "testnet.adanorthpool.com",
                "state": "NO"
        },
        {
                "addr": "202.92.217.26",
                "port": 9710,
                "valency": 2,
                "continent": "testicles.kiwipool.org",
                "state": "NZ"
        }
        ]
}

I followed a mix of the stakepool course tutorial and coin cashew to get this done.  If I can't get this figured out I am probably going to tear it back down and then just start with the Guild Operators site and start from the prereqs.sh.

Seems something wrong with your topology script, you need to fix it. Maybe it has some shortened paths like ./bla.json. It should have access to testnet-shelley-genesis.json file(or maybe it called a bit different in your case) and seems this error hints that script can't access it.
Please post your topology updater script so we can fix it.
Currently when p2p is kind of really early on testnet(and it will work only with 1.33 version), you will need kind of relay on topology updater script.
When everything is fine you should see in logs something like this:
"nice to meet you"
"welcome to the topology"
"glad you're staying with us"
"glad you're staying with us"
"glad you're staying with us"
...
"glad you're staying with us"

So in your case you didn't register properly with topology script and nobody is knowing about your relays. On other hand topologyupdater is kind of optional and after some time(it can be a long time) everybody should know your relay if you registered your pool correctly. So maybe you can share your ticker too? In any case I highly recommend for beginners to use topologyupdater, so start with fixing it.

Thanks for the reply!  Just updated my original post.  I also don't see my ticker in Cardanoscan, so maybe its a metadata issue?

So there are several issues. Check here:
https://testnet.adatools.io/pools/614235f4d6c44cfc46a1ee16c95eb6d10008204c830d056f188e7677

6000 port is not unreachable from outside world. Your relay should be accessible on 600 port from everywhere, check your FW.
https://git.io/JyDWW -- is empty file, so you registered your pool with topology file what do not contain anything

Regarding topology script, can you run which cardano-cli and post it here?

without opening FW(6000 port of your relay) no other relays will be able to connect even if topology script is running as it should

Not sure if it matters, but I used my relay’s private ip, rather than the AWS public ip when I created the pool cert.  So I’m also working on fixing that.  I’ll come back and comment when i’ve been able to move it forward

Yes, you should not use private IP. Please send me which cardano-cli output, so we can fix your topology script. Plus don't forget to fix your metadata link, it is empty now.

After a fair amount of fat fingering, I finally got a pool registration transaction together with the correct metadata: https://testnet.cardanoscan.io/transaction/aa09bf8b7ca07227e01f59cd9ee313050ec705685dcb70071defe3aeb77994be?tab=poolcertificates
I am going to wait for this to take effect and if everything starts working I'll update my original question with what I had wrong as well as give you the green check mark @os11k :)

Hi, thank you! Now everything seems look right: https://testnet.adatools.io/pools/614235f4d6c44cfc46a1ee16c95eb6d10008204c830d056f188e7677. In any case I would recommend to fix topology script, seems you have incorrect this part CNODE_BIN="/usr/local/bin", what should be path where cardano-node binary is located. To check where binary is you can run which cardano-node

The topology script I posted is from the coin cashew tutorial, I actually decided to stop using that one and grabbed the topology updater script from the guild and started using that.  I let it run over night and now I have a brand new topology in my Testnet-topology.json file!  Thank you very much for all the help!

Cool, glad that you make it work. Cheers!


text:
validation and minting policy script
I am trying to create transaction in which a user interacts with a validator script by sending it 30 ADA.I want the validator script to then send the user a native token while sending the creator of the transaction the leftover ADA how do I do this?
Is it possible to have a validator script that also holds a minting policy?
Can I make a minting policy in which only a validator script is allowed to make the tokens?

source: Stack Exchange

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

sort: votes


text:
How to obtain wallet addresses of stake pool delegators?
I am trying to figure out how to write some scripts that will dish out rewards to delegators on my staking pool - I want to get the wallet addresses of delegators, and determine rewards based on the relative amount they have staked (e.g. 5%, 10%, 50%...).  Has anyone done this?  If so, how?  Here is what I tried:

cardano-cli - I tried digging through cardano-cli queries, but I didn't see any relevant queries to what I am trying to do.
blockfrost - using /pools/{pool-id}/delegators, I can get a list of delegators and the amounts they delegated, but these are staking addresses, and I can't do anything with these addresses directly.  I can easily calculate relative stake with this based on live_stake value returned.  So, I tried /accounts/{stake-address}/addresses with the first delegator stake address, and it returns something like 15 addresses.  What do I do with that?  How do I know which is the wallet address I want to send rewards to?

You were onto the right idea, try the blackfrost approach again. After calling /accounts/{stake-address}/addresses endpoint you will see a list of addresses linked to the stake address. Pick any address from that list.
Another approach that should work is using cardano-address. First get all stake addresses:
cardano-address address inspect [ADDRESS]
Then query your cardano-db-sync. Use an INNER JOIN query to map addresses to stake addresses.

Aha, lightbulbs are turning on.  That is cool, thanks for sharing that.  One more depth to delve into.  I think the blockfrost may be more straightforward and simpler, but I will keep that in mind.

What I do is query & grab all the data I need from:
https://cardanoscan.io/pool/f8e64037e3917cd7cb94969a5374e11b9e6c939b4b69118a8eb4509f?tab=delegators
And then send whatever I want using cardano-cli. Works like a charm!

Hmm, this is the same as the blockfrost /pools/poolid/delegators call.  It is returning staking addresses.  But you say you send money to those addresses no problem?

I've never heard of or used blockfrost, but yes - you can send money to those addresses in Cardanoscan no problem. I do it everyday and have never enountered an issue.

You should check out Blockfrost.io - it's a free RESTful API to call Cardano networks (mainnet or testnet)

You pick any of the addresses associated with the staking address from the point 2, they are all in the same wallet.

What do you mean "from the point 2"?  Do you mean anything other than the first address?

This is point 2:
blockfrost - using /pools/{pool-id}/delegators, I can get a list of delegators and the amounts they delegated, but these are staking addresses, and I can't do anything with these addresses directly. I can easily calculate relative stake with this based on live_stake value returned. So, I tried /accounts/{stake-address}/addresses with the first delegator stake address, and it returns something like 15 addresses. What do I do with that? How do I know which is the wallet address I want to send rewards to?

Any of those 15 address will be OK. They are all in the same wallet.

How do I know which is the wallet address I want to send rewards to?

In theory, any address associated with the staking key will do.
Just a reminder that the address can be mangled, so the owner of the stake rights might not be the same person as the owner of the payment funds.

I'm not sure the implications of this statement.  Does this mean that the address that is returned may not be the address of the staker?  That seems at odds to the call, so I don't think that's what you meant.  Or what payment funds are you talking about, you mean the funds in the wallet that is staked to my pool?  Sorry, I am new to SPO, so I am trying to make sure I understand the answers you are giving.  Thanks for replying!

You can get the wallet address of stake pool operator by using adapools.org. First go the desire pool, then delegators and click on the pool staking address. You will see it. An example can be found here.

This does not answer the question. The OP was asking for delegators addresses, not the SPO's address.

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


text:
submitting transaction FeeTooSmallUTxO
So I have a basic script that attempts to transfer everything from 1 address to another. In order to correctly conserve and to spend the minimum fee, I just build a transaction that uses 100% of the lovelace and let the build command tell me how much I am short, then rebuild the transaction - the fee from the error before.
But that stopped working for some reason. In my current example, the build command says I am short by 168185, then I rebuild minus that fee, and it works fine. I sign, and go to submit and I get this strange error showing my being just a tiny bit short:
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 169593) (Coin 168185))))])

My question, is there a way to  know the min fee without going through multiple iterations? and why is this fee different then the one from the build command?
EDIT:
I can't actually submit this transaction at all, because when I try to change it to "169593" then the change output of 1408 doesn't meet the minimum utxo threshold for the change output. how can these two be calculated differently? Do I need to build raw and specify the fee explicitly of the higher amount?
Command failed: transaction build  Error: The transaction does balance in its use of ada, however the net balance does not meet the minimum UTxO threshold.
Balance: Lovelace 1408
Offending output (change output): addraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + 1408 lovelace

face address of course

The build command will differ from the amount when submitted from the signatures. So the problem is that the cost goes up with each signature. You can include this estimate by using the "--witness-override 2" if you know you will be signing it with 2 signatures and it will give an accurate fee.

You should be able to create a transaction draft where you should specify a fee of 200000 lovelace (to have the same transaction size as the final transaction), then estimate the fees, and create the final transaction.
You can also use "cardano-cli transaction build" command and you don't need to calculate the transaction fees or build the transaction 2 times, you only build it once, sign it and submit it.
In case the change is smaller than 1 ADA, the only way to do the transaction without consuming another UTxO is to pay a higher fee for the transaction (add the change to the fee) or to send a higher amount to the destination address than what you wanted to send (add it to the output instead of paying it as a fee).

If you want to send everything in a wallet the new way that calculates the fee and adds ttl you can query for all the utxo's in the wallet.
cardano-cli query utxo \
--address $(cat payment.addr) \
--mainnet

grab all the utxo's and add them as tx-in as you normally would. You can have multiple in and out.
If it is all going to one place use --change-address. It will send whatevers left over after the fee to that address.
cardano-cli transaction build \
--tx-in a-utxo#1 \
--tx-in another-utxo#0 \
--change-address <to-addr> \
--witness-override 1 \
--out-file tx.unsigned \
--alonzo-era \
--mainnet

It will print the fee. Witness is the number of keys needed for signing. 1 if it's just sending ada somewhere.
cold machine-
cardano-cli transaction sign \
--tx-body-file tx.unsigned \
--signing-key-file payment.skey \
--mainnet \
--out-file tx.signed

-online submit
cardano-cli transaction submit \
--tx-file tx.signed \
--mainnet

Thanls for the complete example, this was exactly what i did nearly when I got the error! The issue was the number of signatures differed from the witness override

Fees are variable - You cannot depend on them being the same for every transaction. Things such as changing the number of signing witnesses, or number of receivers, can make fees adjust.
To determine the correct fee, first create a draft TX and just use a dummy ada amount for the txout and txin parameters, such as 0, and then run:
cardano-cli transaction calculate-min-fee --tx-body-file matx.raw --tx-in-count 1 --tx-out-count 1 --witness-count 2 --mainnet --protocol-params-file protocol.json
And fill in the correct #'s for the various parameters above. This will give you the exact fee.
Finally, go back and edit your draft TX with the final numbers so that everything balances out.


text:
How to sort wallets in the Daedalus wallet sidebar
Is there a way to customize the order of wallets in the sidebar of the Daedalus wallet?

Daedalus automatically sorts wallets by their names. The only way to set the needed alphabetical order of your wallets in the sidebar is to rename each wallet accordingly.
To do this, go to the More tab.


text:
How do I call the amount of ADA sent to a validator script in an Integer
I am trying to create a validator function that only lets the user send ADA to the creator of the script if the user sends x amount of ADA how to I find out the amount of ADA the user sent and then put it in a boolean statement?
(____ == ADA.lovelaceValueOf 30)

You can not disallow users to send ADA into your smartcontract script address.
You can only deny unlocking.
However you can check how much of value is being sent with outgoing transaction from txOut by checking txOutValue field.


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:
Is there an easy way to see how many NFT's exist on the Cardano blockchain?
I would like to get the number of all NFT's ever created on Cardano. This means all native assets with a supply of 1. Is there a website where I can find this information or are there tools that can achieve this?
I don't mind running my own node for this, if there is no other way.

Check https://pool.pm/tokens which seems to provide the total at the top of the page.

Also you can fetch them all from blockFrost with this end point
https://cardano-mainnet.blockfrost.io/api/v0/assets
For a detailed explanation here is the Link
https://docs.blockfrost.io/#tag/Cardano-Assets/paths/~1assets/get


text:
Sign transaction with multiple inputs
I built a transaction with cardano-cli shelley transaction build-raw command that has multiple inputs. I have the private keys and .skey files of these addresses but I don't know how to sign the transaction with the cardano-cli. How can I do this?

A single transaction in Cardano can contain many inputs and outputs. As long as the transaction is signed by all the private keys associated with each address, it will be valid. In other words, the number of inputs doesn't effect the number of signatures needed, only the number of unique addresses does, where each unique address requires a signature.
For example, if I have constructed an transaction with an arbitrary number of inputs, but those inputs all come from N-number of unique addresses, the command would be:
cardano-cli transaction sign \
--tx-body-file <RAW_TX_FILE> \
--signing-key-file <SKEY_1_FILE> \
--signing-key-file <SKEY_2_FILE> \
--signing-key-file <SKEY_N_FILE> \
--mainnet \
--out-file <SIGNED_TX_FILE>

Does it automatically find which file belongs to which address or I should specify that?

it will automatically find them, There is no need, nor an option, to specify.

Got it, Thanks!

Here's an example of a signing command - just add/remove --signing-key-file parameters as necessary!
cardano-cli transaction sign --signing-key-file payment.skey --signing-key-file policy.skey --mainnet --tx-body-file matx.raw --out-file matx.signed


text:
What does the txOutValue refer to?
What is the txOutValue in reference to in a validator script? Is it the output value sent to the script by a wallet or is it the value sent by the script after compilation?
Also what does the txInInput refer to?

Can I see what yu were reading?

A transaction has inputs and outputs. When an input is from script address, the validator script is run to allow or disallow spending the UTxO protected by it in that transaction. While deciding whether to allow or disallow, it can see the whole transaction with its inputs and outputs. Let's say that one of the outputs is o :: TxOut. You can use txOutValue o to get the value (of type Value) of that output.
I'm not aware of txInInput. The closest I can think about is txInputs which is the set of inputs to the transaction being validated. Similarly, txOutputs is the set of outputs.


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:
Project One: IOHK light wallet in the making - where to find the source code?
There was a talk at the Cardano summit mentioning the new Cardano light wallet in the works by IOHK and Charles Hoskinson very briefly made a reference to the same project in his latest Dapps whiteboard talk (from 46 min 34 s).
Do you know if the source code will be open-sourced? If the source code is already accessible and where? Github doesn't seem to have a repo for it.
I would really love to understand if this wallet could be the MetaMask equivalent in the Cardano ecosystem.

As far as I know, the wallet or its source code is not yet release.
If you are looking for a metamask equivalent, you might want to check Nami wallet.

Thanks for your answer. Nami wallet is interesting but isn't available on mobile and doesn't include a built-in browser unfortunately.

What is a build-in browser? Also, I'm not sure if there are plans for mobile version of One.

I don't think IOG has announced if it will be or not. It is still in development/testing so maybe that is why. I would guess it will be open sourced based on Emurgo open sourcing their Yoroi wallet: web and mobile.
IOG did say they want this new wallet to be interoperable with other chains so I think if they are taking on MetaMask (also open source) they would do the same.
This new light wallet could certainly be the MetaMask equivalent. I think of it similar to the official Algorand Wallet. Although there is a point to be made around the success and innovation of these 3rd party wallets in our space.

I think you might be talking about 'Mithril'.
Here is some info as a starting point:
https://iohk.io/en/blog/posts/2021/10/29/mithril-a-stronger-and-lighter-blockchain-for-better-efficiency/


text:
How to parse PubKeyHash hash into a Plutus Smart Contract for on Chain Validation
I am trying to use a PubKeyHash as a variable in my on-Chain code, something like this:
pkh :: PubKeyHash
pkh = "dca6035712f164db2f99c71404d392115d2bdde366fbbe359ae01f1d"

But this does not work, just give me a strange error when compiling  I tried to add the In-linable but that did not work either. I tried with some BuildIn constructors as well and that did not work either.

I managed to use PubKeyHash by using parameterized smartcontract code like I have showed in another question here

It seems so strange to me that parametrizing works but not direcly :s


text:
Is secure to Fetch Data from BlockFrost from the Front-End?
I am building a daap, but I must fetch data from Blockfrost in order to make the transaction, I am not sure if should i Add my personal project ID in a request from the front end. Currently i have that in my backend as an .env variable and my back end does the request and sends back the info to the front End. I was thinking about to change it to the Front End so that my server does not have to listen all that requests. But i am afraid it may compromise the security of my project Id

It is not a recommended practice, as you said yourself, it will leak your security token to the public.
Blockfrost is an alternative way to access the Cardano blockchain, it is not a replacement for your own backends.


text:
How does one-time minting policy actually work?
In week 5 of plutus-pioneer-program with NFT example this plutus minting policy code is provided:
{-# INLINABLE mkPolicy #-}
mkPolicy :: TxOutRef -> TokenName -> () -> ScriptContext -> Bool
mkPolicy oref tn () ctx = traceIfFalse "UTxO not consumed"   hasUTxO           &&
                          traceIfFalse "wrong amount minted" checkMintedAmount
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    hasUTxO :: Bool
    hasUTxO = any (\i -> txInInfoOutRef i == oref) $ txInfoInputs info

    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoForge info) of
        [(cs, tn', amt)] -> cs  == ownCurrencySymbol ctx && tn' == tn && amt == 1
        _                -> False

Script validates if minted NFT is 1. Here are my questions regarding one-time minting:

Is this an example of a one-time policy script which is referenced in Cardano documentation here ?
If this is a one-time minting policy, how does it ensure that only one and only NFT is to be minted with this minting policy? What stops me of instead minting many NFS with single transaction creating many transactions to mint many NFTS one by one?
If this is not a one-time minting policy, how does one-time policy actually look like? How does it ensure that only one token or NFT is to be minted in Cardano network?
Is it possible and if so how to secure the total amount to be minted with minting policy? How would simplest example of that plutus script code look like?
Is it possible to create such minting policy, that it allow to mint only if total minted token amount is not reached and if so how?
Is it possible to create such minting policy, that total amount to be minted is dependent on the time (slot). For example by Monday total amount minted can be 10000, but by Tuesday it can be 20000?

Yes, this is an example of a "one-time minting policy" referred to in the Cardano documentation.
The policy ensures that only one NFT is minted by a combination of i) being parametrised with a specific UTxO that needs to be consumed by the transaction (checked by hasUTxO) and ii) checking that the total mint quantity is 1. As all UTxOs are unique, this policy can only succeed one time and then never again. The parametrisation ensures that the NFT currency symbol depends on this UTxO, so that if you define the same policy with another UTxO it would not be the same NFT.
I did not understand the question in bullet point 4.
To get a minting policy that allows to mint up to a total fixed supply, I would combine the policy with a script UTxO that keeps track of the minted value in the datum. You need to put an NFT in this script UTxO as well and the minting policy would need to check the presence of it in the transaction and delegate the validation to the script. The script can then check the newly minted value and apply some logic, like checking the weekday. But it would be much easier to just mint the total quantity in one transaction and then distribute the tokens with another mechanism.

Is it possible to read Datum values in UTXO from plutus policy script?

Minting policies also get a ScriptContext passed to. Through this context you can access the datums of the transaction inputs and outputs.


text:
help, i register script policy with pool.pm was not approved?
I'm learning to create nft. by using cardano serialization lib and nami wallet
but the nft I created, register script policy with pool.pm was not approved.
I don't know if it's caused by a signed key or not? please advise
Thank you.

Can you please provide more information, such as share your policy you try to have approved?

To register a NFT's Policy script in pool.pm you will need to paste your json policy script into the NFT's script text input.
The JSON file should be formatted like this:
{
    "type": "all",
    "scripts": [
        {
            "slot": 70000000,
            "type": "before"
        },
        {
            "keyHash": "2bac2f5b08379b3756f594fbce1d3c53565f83b78ab7b106df1f7e950e",
            "type": "sig"
        }
    ]
}

If the hash of the json policy script matches the PolicyId then the policy will be verified automatically and the timelock symbol will appear.

It sounds like you're confusing two things (at least it's confusing to read from your description)...
The first is entering your policy.script file contents into pool.pm. This will turn the ? into a lock. There is no approval process here - it happens the moment you press submit assuming you did it right.
The second is registering your policy ID with CNFT github: https://github.com/Cardano-NFTs/policyIDs. This does require approval. I know they are SEVERLY backed up from the holidays, so unless your pull request failed then you just have to continue to be patient.


text:
Can you manually list an address in a Smart Contract
Can you manually list a wallet address in a smart contract transaction? For example lets say I create a smart contract that allows any user to send Ada to a specific address by sending it to the scripts UTXO address is this possible?

You could hardcode public key hash of a receiver address and then validate if outgoing transaction is going towards address with same public key hash.
Here is an example how that would look like in plutus code:
...
data ContractInfo = ContractInfo
{
   recvPkh :: !PubKeyHash
} deriving Show

contractInfo = ContractInfo
{
   recvPkh = "3f7846896a48c59359746ff096d63606ceb82e65900d20a9fd2b8a93"
}

{-# INLINABLE mkValidator #-}
mkValidator :: ContractInfo -> () -> () -> ScriptContext -> Bool
mkValidator contractInfo@ContractInfo{..} _ _ ctx =
  any outputToCorrectAddr txOuts
 where
     info :: TxInfo
     info = scriptContextTxInfo ctx

     txOuts :: [TxOut]
     txOuts = txInfoOutputs info

     outputToCorrectAddr :: TxOut -> Bool
     outputToCorrectAddr txo = case toPubKeyHash $ txOutAddress txo of
       Just pkh -> recvPkh == pkh
       Nothing  -> False
...


text:
How to be approved or reviewed on cardano-token-registry?
I made a pull request on cardano-token-registry
but after days it's still blocked.
How to ask for a review or some type of approval?
My request is #1030
Andrea

You just have to wait, because these are reviewed by human beings working at the Cardano Foundation and it might take few days to work the back queue.

I must say that it's quite frustrating being leaved in a limbo for days just because the first CI run failed for an error in another project and not in mine. However, thank you for your answer.

Merged! Frustration ended! :P


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:
Is there complete cardano-cli documentation?
Hello all I can find is the cardano-cli help and
https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/cardano-node-cli-reference.md/
I am trying to get information on things like what --tx-out-datum-embed-file FILE does

This is a cop-out answer, but in my experience there surest place to go for answers is to read the source code directly.

The flag --tx-out-datum-embed-file FILE allows you to embed the datum data on the transaction, not the datum hash like using that flag --tx-out-datum-hash-file FILE.
cardano-cli transaction build --tx-out-datum-embed-file DATUM.json

According to this web page, the definition is vague: The script datum to embed in the tx for this output, in the given JSON file. The file must follow the special JSON schema for script data.

I totally agree with you that a topic on datums/redeemers in JSON format for Tx is undocumented. However, I managed to find a very interesting GitHub post, which, I hope, will shed a light on some unclear things – Here it is. Unfortunately, that's all I could find on this topic.

I Appreciate the reference. I still wouldn't know how to actually create a json file that can be directly uploaded from these. Like would I put the path to an arbitrary file in the fields value of another json file, or do I have to encode to cbor first. Its all very incomplete

I've updated my answer.

I'm trying to learn this too. I could not find any further documentation other than the cardano-cli command help. This is pretty extensive and useful. Every command argument seems to have built-in help. So, for instance, to get help with building a transaction, issue the command cardano-cli transaction build. The help for this includes some info on the --tx-out-datum-embed-file FILE arguments.


text:
Obtain data about a CNFT project
I want to obtain some information about a given CNFT project. For instance, the number of asset minted, and all the assets metadata (e.g., attributes). How can I proceed with this? I mainly use R as a statistical/programing tool. Is there an api somewhere to do this? I have been web scraping this information, but it is really cumbersome and I am looking for an alternative.

I think the best option for this is: Blockfrost API
Specifically, Cardano > Assets endpoints
I.e. To retrieve the list of Tokens for a policy, you can use the following code:
curl --location --request GET 'https://cardano-mainnet.blockfrost.io/api/v0/assets/policy/c364930bd612f42e14d156e1c5410511e77f64cab8f2367a9df544d1' \
--header 'project_id: <project_id>'

Where <project_id> is your blockfrost API key.

Thank you very much! I am having a hard time understanding how to use the api. Could you give me just an example on how to pull data from one project via an URL api call (e.g., BCRC: c364930bd612f42e14d156e1c5410511e77f64cab8f2367a9df544d1)? That would really help me out.

@mat please check my updated answer.

thank you so much! But would it be possible to just have a single link? I use R to make api calls and they usually are in a json format or something similar. I Tried https://cardano-mainnet.blockfrost.io/api/v0/assets/policy/c364930bd612f42e14d156e1c5410511e77f64cab8f2367a9df544d1?project_id=<my_blockfrost_api_key> but it did not work...

@mat No, as you need to attach it as a header. You can take a look on this: https://stackoverflow.com/a/65649641/1133816 to use CURL in R with headers.

There are multiple ways.
As per the previous answer you can fetch data from Blockfrost.
But it looks you want to fetch loads of data in bulk, and that could lead to having to pay blockfrost as the basic account only gives you a limited number of api calls.
Alternative is to run cardano-db-sync by yourself https://github.com/input-output-hk/cardano-db-sync
Or leverage some open source like dandelion.link


text:
How to get information about UTxOs which created locking transaction on the on-chain?
I would like to create a smartcontract which makes sure that only the same person who made specific locking transaction can unlock that same specific transaction or to put it into simpler terms if Bob locks his Ada then smartcontract must ensure that only Bob can unlock his locked Ada.
I think in TxInfo one of the txInfoInputs UTxO should contain information about locking transaction. But from data definition of txInfoInputs :: [TxInInfo] field:
data TxInInfo = TxInInfo
    { txInInfoOutRef   :: TxOutRef
    , txInInfoResolved :: TxOut
    } deiriving stock (Generic, Haskell.Show, Haskell.Eq)

I can't tell how exactly could I get public key hash of source address or something else which could give me information for validation if unlocking transaction is being made by the same person who made locking transaction.
Another way I can think of is to add sender address into Datum but I can't think of a way how to ensure secure Datum creation process so that for example when Bob is creating transaction to luck funds in smartcontract Alices address as a receiver doesn't appear in Datum
So is it even possible, to create such smartcontract which would take information of locking transaction and by using that information validate if smartcontract funds can be unlocked?

In TxOut you have a field txOutAddress that you can use for this:
data TxOut = TxOut {
  txOutAddress   :: Address,
  txOutValue     :: Value,
  txOutDatumHash :: Maybe DatumHash
}

Use it to extract the pubkeyhash:
pkh = toPubKeyHash $ txOutAddress txOut

And then in the smart contract check if the transaction is signed by it:
txSignedBy (scriptContextTxInfo ctx) pkh


text:
Embedding address into the datum using the CLI
I have a validator that uses Address in datum. I also have an address generated (payment.vkey, payment.skey, payment.addr, stake.vkey, stake.skey, stake.addr). I'm able to get PubKeyHash using command line like this:
cardano-cli address key-hash --payment-verification-key-file payment.vkey
That gives an addressPaymentCredential that I'm able to embed to datum when building the transaction in cli. It has the same information as (addressPaymentCredential, _). How would I go about getting a full address with addressStakingCredential in it, that is, (addressPaymentCredential, addressStakingCredential)?
I think that the JSON structure of Address in datum should be like this:
{
  "constructor": 0,
  "fields": [
    {
      "constructor": 0,
      "fields": [
        {
          "bytes": PubKeyHash
        }
      ]
    },
    {
      "constructor": 1,
      "fields": [
        {
          "bytes": StakingCredentialHash
        }
      ]
    }
  ]
}

My problem is I don't know how to get StakingCredentialHash.
TLDR: How do I embedd an Address instead of just PubKeyHash into the datum in cardano cli? I have the address credentials in payment.* and stake.* files.

why not just use the address instead of PubKeyHash in your example?

@noone392 You mean in the JSON? The whole JSON is an Address which is composed of two parts, one of them being PubKeyHash. My validator used PubKeyHash, but I'm trying to replace it with Address. I did that and now I need to change the datum JSON appropriately. Or do you mean something else?

I am not following you. The JSON file is not the address it is the whole formatting required for a datum entry. you said you said you wanted the address instead of the public key hash. So just delete "bytes": PubKeyHash  and replace with "bytes": address? or if you want to add the address then add another "fields" key

Yes, I want to transform my address into the datum entry. The JSON I provided is slightly modified output of ToData a, where a = Address(addressCredential, addressStakingCredential). In the JSON provided, I can replace PubKeyHash (which is just a placeholder there) with the output of cardano-cli address key-hash --payment-verification-key-file payment.vkey. My problem is that I can't figure out, what I need to replace the StakingCredentialHash placeholder with. I have the stake.vkey file, but I need some command to transform it in a similar manner to how I did with payment.vkey.

i really can't follow what your asking. to transform stake.vkey in the same maneer just run
"cardano-cli address key-hash --payment-verification-key-file stake.vkey"

I see the problem now, the command does not work on stake.vkey, but it needs to get stake-address instead of just address. I'll add an answer.

The problem was that I was trying to use the cardano-cli command for address to a stake-address. The command for payment credential (PubKeyHash) is correct in the question:
cardano-cli address key-hash --payment-verification-key-file payment.vkey
The correct command for staking credential should be like this:
cardano-cli stake-address key-hash --stake-verification-key-file stake.vkey
Outputs of those 2 commands can be used to build correct Address in datum.
Also, the JSON I provided in the question is incorrect, the staking credential part should be deeper than the payment credential part, you can get the correct JSON by printing the datum in emulator using a command like in an answer to this question.

So then, are you embedding an address-hash of some sort in the datum? As far as I know, you can't recreate the full address using the hashes of the constituent keys. I'm just curious - is the purpose of this to embed the address hash or some sort of address-verification method into the datum?

I think that payment credential and staking credential are just hashes, so you can verify that an output goes to an address from datum without the need to reconstruct the full address.

You write "the JSON I provided is incorrect".  Would you please paste the correct JSON? I am lost from the links and your explanation is too vague


text:
How to add datum to UTXO in nami
Datum is hashed and assigned to an UTXO
When you send the transaction you can add optional parameters like metadata and/or datum
datum is used by smart contract since it's the only data that smart contract can see.
So in short:

Send the transaction to the address
Add json to metadata
Convert the json to datum and add to UTXO

how to implement "Convert the json to datum and add to UTXO" using NAMI wallet.

Be careful not to confuse metadata and datum, as they are different things. Metadata are part of a transaction, while a datum is part of an UtxO.
Metadata are completely optional and to the discretion of the transaction issuer, while the datum is mandatory when dealing with script addresses.
Some metadata can optionally be attached to a transaction independently of your decision to add some datum to the different UtxO. In addition, you don't send the datum directly, but its hash.
It is only when you want an UtxO back from a script that you have to provide a datum whose hash has to match with the one you defined previously.
This datum will then be part of the script context, as long a additional data you can provide through redeemers.
So, you can indeed record the datum intended for the script in the transaction metadata, but it not mandatory. It is just a mechanism to recover the correct information in case it is not possible otherwise.
Now, for the "how to do that ?", the best is to study some open source code, like the one for the SpaceBudz market. It heavily uses the serialization lib to provide the different information required by this wallet.


text:
send multiple assets in one transaction
I have 2 wallets.
I have about 10 assets (tokens, cnfts) besides ADA in each wallet.
I would like to send the assets from one wallet to the other to consolidate them.
Can I do this in one transaction?
Thanks!

Yes you can. A single cardano transaction may contain multiple inputs per address from multiple wallets, so long as the transaction contains a signature for every unique address from which a UTXO is being consumed.
For example, if all of your ADA/assets that you wish to consolidate are spread across 5 UTXO's in a single address, you can create a transaction where all 5 are consumed in 5 TX-inputs, and output to a single UTXO sent to the new wallet. If no change is being sent back to the original wallet/address, such a transaction would contain 5 inputs and one output. This transaction would require only one signature associated with the address whose UTXO's are being consumed. If there are multiple input addresses, you would need a signature from each input address.
I provided an example in this post.
Let me know if you need further clarification or a different example! :)

Wow, thanks. I'm glad this is possible, but it sounds confusing. Would I do this directly from my wallet, or is this done with a CLI tool?

if you are using a frontend wallet like Yoroi or Daedalus, I don't think there is an option for multi-wallet (batched) transactions. You could however consolidate assets from a single wallet in one transaction by sending all of the assets to a single address on your new wallet. If however you do need to construct multi-wallet transactions, cardano-cli or cardano-wallet would be the way to go.

Are you looking to use a light wallet client or do this using the cardano-cli?
If you’re looking to just get the one time task done, I’d recommend this.
Go to Send -> Input an address -> Input an amount -> Add assets to the same transaction -> Submit.


text:
Error loading cardano-serialization-lib
Trying a few different examples out there and I am getting the error:
The requested module '/node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.wasm?import' does not provide an export named '__wbg_address_free'
Using this project:
https://github.com/HarmonicPool/cardano-wallet-interface
Loader:

let private_wasm = undefined;
/**
 * *.wasm module can only be imported asyncronously
 * Loader class allow to load the cardano serializaton lib once and make it aviable every time
 */
 class Loader {

    // always call this method to be shure the wasm has been loaded;
    static async load() {

      //load once
      if ( private_wasm !== undefined ) return;

      /**
       * @private
       */
       private_wasm = await import(
        "@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib"
      );
    }

    static get Cardano() {
      return private_wasm;
    }
  }

  module.exports = Loader;

Any ideas why? The loader looks same as every example I've seen out there.

If you are using nodeJs then you are NOT in the browser, right? you are in the backend? if thats the case you might consider NOT using the browser library and in that case there is no need of a Loader. I have used just loader in ES6 versions, and always is a little of a mess to get it up working, because you have to configure so many things like Webpack etc.. package.json ... I would recommend to include a little bit more of the configuration of your project. Also check the webpack.config of the project you are using as a template as well as package.json and of course node version.

I was trying to do it with Vue + Vite and I think something about importing it with Vite is what wasn't working out, I thought I was follow the Vite docs but obvs not! Switched to Vue and Webpack and it's working now.

Thanks you for your answer you are amazing using WASM was horrible this implementation is much better

I found that using WASM comes with a lot of headaches ...
There is a non-wasm version of the same lib which I have installed and have been using. Here is my github repo with an example:
https://github.com/dynamicstrategies/cardano-wallet-connector
The non-wasm npm to install is here:
https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-asmjs


text:
New payment address in Java
I am creating a project and would like to be able to give new addresses for each transaction to simplify tracking of payments. I need a method to create a new payment address similar to the below question but in Java.
How can i generate new wallet address using cardano-wallet cli and cardano wallet api after created my wallet?
Currently I am using Blockfrost Api Java SDK and cardano-client-lib but neither are able to create a new payment address from what I can tell.
I would like to avoid needing to run Cardano-cli and JNI (no experience) if possible.

@samuelleathers put in time and effort to answer your question.  If you want to keep getting good answers, don't forget to vote an answer up when you accept it. :-)

A better question might have been, "How can I create a new payment address using the Blockfrost Java API"

A payment address is just the hash of the payment pubkey (and optionally the stake pubkey if that addresses funds will delegate) with some prefixed bytes that indicate what type of address it is. The payment secret keys can either be randomly generated (such as how cardano-cli address key-gen works), or can be derived from a wallet root private key (which usually has an associated mnemonic to generate the root private key).
If your app doesn't need to use a full wallet, you can generate random bytes, convert that to a pubkey, get the payment key hash and assemble an address.
If your app does use a wallet, you would generate keys under the derivation path: 1852H/1815H/0H/0/$i using cardano-addresses, and then the rest of the steps are exactly the same, but using the bytes derived rather than randomly generated.
If you go the random generation route, please ensure you have many backups of every secret key you generate, otherwise if the keys are lost, those funds are completely unspendable!

Between this answer and https://github.com/uniVocity/cardano-tutorials/blob/master/cardano-addresses.md#generating-a-payment-address. I get the process from a high level using cardano-address but what happens during the hashing process and can this be easily easily implemented if I have the root pub key and the derivation path?

You need the account pub key. Any derivations followed by H are hardened and need the private key to derive.

You could use Blockfrost API to create a new address. Please refer here.

Thanks for the reply. That would be perfect if it was implemented in the Java SDK. However it still might be a better alternative than running a node like I was thinking of doing.

Blockfrost has a Java SDK too https://github.com/blockfrost/blockfrost-java


text:
Cannot build cardano-wallet-2021-12-15
I'm trying to build cardano-wallet with cabal. However, it fails wit the following error:
[19 of 20] Compiling Cardano.Ledger.TxIn ( src/Cardano/Ledger/TxIn.hs, dist/build/Cardano/Ledger/TxIn.o, dist/build/Cardano/Ledger/TxIn.dyn_o )

src/Cardano/Ledger/TxIn.hs:108:12: error:
    Not in scope: ‘HS.viewHash32’
    Module ‘Cardano.Crypto.Hash.Class’ does not export ‘viewHash32’.
    |
108 |       case HS.viewHash32 (extractHash sh) of
    |            ^^^^^^^^^^^^^

src/Cardano/Ledger/TxIn.hs:109:9: error:
    Not in scope: data constructor ‘HS.ViewHashNot32’
    Module ‘Cardano.Crypto.Hash.Class’ does not export ‘ViewHashNot32’.
    |
109 |         HS.ViewHashNot32 -> TxInCompactOther tid (fromIntegral index)
    |         ^^^^^^^^^^^^^^^^

src/Cardano/Ledger/TxIn.hs:110:9: error:
    Not in scope: data constructor ‘HS.ViewHash32’
    Module ‘Cardano.Crypto.Hash.Class’ does not export ‘ViewHash32’.
    |
110 |         HS.ViewHash32 a b c d -> TxInCompact32 a b c d (fromIntegral index)
    |         ^^^^^^^^^^^^^

src/Cardano/Ledger/TxIn.hs:118:38: error:
    Not in scope: ‘HS.unsafeMkHash32’
    Module ‘Cardano.Crypto.Hash.Class’ does not export ‘unsafeMkHash32’.
    |
118 |     tid = TxId (unsafeMakeSafeHash $ HS.unsafeMkHash32 a b c d)
    |                                      ^^^^^^^^^^^^^^^^^
cabal: Failed to build cardano-ledger-core-0.1.0.0 (which is required by
test:unit from cardano-wallet-core-2021.12.15, exe:local-cluster from
cardano-wallet-2021.12.15 and others). See the build log above for details.

I've found a solution for similar error but adding the constraint of hashable < 1.3.4.0 doesn't change anything.
Has anyone succeeded with a cabal build?

Recommended way to build cardano-wallet is with stack. Check out this manual:
https://developers.cardano.org/docs/get-started/installing-cardano-wallet
I tried to build wallet recently and it was successful. Let me know if you will still have issues building it with stack. Cheers!


text:
How can I register a document on the cardano blockchain? Does it have cost?
I want to adopt cardano blockchain as a proof of existence and authenticity of documents on my job. How can I do that?
Making some research I found cardano CFC but I am not sure if is working already and if there are other alternatives at low or not cost.

While this is possible to do in principle, there is currently a lack of standards surrounding many potential such applications of blockchain tech. Establishing standards will require us to experiment a bit at first, tailoring each application to our specific needs. That being said, I'd imagine there's a few ways of going about document verification, depending on what your requirements are for user-friendliness, security, and accessibility. Here are a few naive ideas:

One can hash some document(s) using a popular hashing algorithm like SHA-256, and post the resultant hash on chain as metadata. Here are some basic introductions for attaching metadata to a transaction. If someone would then like to verify the authenticity of the document, they could hash it themselves and compare their result with what is posted on chain (provided you give them the tx-hash of the transaction so they could query it). Note: while this method is secure and works well for individual documents, it can get tedious keeping track of everything if there are many documents posted over a long period of time. One can write a piece of software that automates this process or:
One can securely generate a GPG keypair, whose fingerprint they post on-chain as metadata. Now, anything signed by the keys can be referenced by an external validator as being the same signatory whose key fingerprint is stored on chain. This method requires a higher level of trust in that the validator assumes your keys have not been compromised, but it is much easier to authenticate many documents since only your GPG fingerprint is stored on chain.

As far as paying for all of this goes, fees on cardano are deterministic, and it relatively cheap to submit basic transactions with metadata. Here is the formula for reference.
These are just a few spitballs of how I would begin going about solving your problem. However, I'm sure that, as time goes on, standards will evolve and cement themselves for such applications.

I think the COSE (CBOR signing and encryption) is now a clear pathway for document signing and encryption of the signature. (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030 , https://github.com/Berry-Pool/nami-wallet/blob/faf5a7a7993defbb7267a25a5f4cef4e06d39c7d/MessageSigning.md
are some references.). This is the wallet api: api.signData(addr: Address, payload: Bytes): Promise
that can help with using of the wallet private keys to sign while attaching the public key for verification in the backend.

The problem with GPG key scenario, is that it can lead to hacks where a central server generating the keys become the vulnerability and hence it is better avoided. Moreover for lay users they cannot store their keys. That is why it is best to use wallet which the lay users can use.


text:
Secure pledge with hardware wallet
technical question for securing the pledge with hardware wallet.
Is it possible to have the pledged secured with ledger nano and not having to sign pool updates with it?
I mean, just have the ledger address as second owner for that purpose and every pool update, or actions signed just with normal keys?
Thank you!

Any wallet that is registered as an "owner" wallet (a.k.a. pledge wallet) must witness any submission of a pool certificate, even if the certificate is being submitted for a minor update. If the certificate is submitted without the witness of a (currently) pledged wallet, then that wallet will be removed from "pledge" status the following epoch.
In other words, all owners and/or operators of a pool must witness pool updates, or their wallet(s) will loose pledge status.

OK! Thank you! :)

If you follow the steps below and register as a Pledge wallet you must sign as a witness for any pool update transaction. No way around that.
You'll need to do a few things to set up the 2nd pledge wallet:

Set up your Ledger, delegate, make sure you do this 2 epochs before any pledge changes
Install this to interface with your Ledger
Export your staking keys
Copy your stake.vkey to your cold env and update your stake pool registration certificate. Make sure you have these flags sent in:

--pool-reward-account-verification-key-file [LEDGER-STAKE].vkey
--pool-owner-stake-verification-key-file [NON-LEDGER-STAKE].vkey
--pool-owner-stake-verification-key-file [LEDGER-STAKE].vkey \

Copy your pool.cert back to block producer and prep a new multi-signature transaction
You'll need 4 witnesses:
node.skey
[LEDGER-STAKE].hwsfile
stake.skey
payment.skey
Submit the transaction

Thanks mate, I think I will do it!


text:
How can I get notified offchain when a transaction is included in a block that is validated?
I need to do an offchain action in an application when a transaction is included in a block that is validated.
Is there a way to register a listener for such a notification? Or is there another mechanism?
Thanks!

There is no listener for it. Pooling it in an interval is a common way to do that. The Listening for ada payments using cardano-cli page is worth referring to.
You can also watch the chain from cardano-db-sync or from some Cardano API providers such as Blockfrost.io.
If you use Blockfrost.io, you could use the Websockets link for Blockfrost.io API to create a WebSocket subscription.

Did you find out a way to listen for transaction completion?


text:
How does Cardano protect against DoS attacks against stake pools?
I was reading about Algorand’s core technology, and in their section on delegated proof of stake, they argue that DoS attacks are a key weakness of this, and hence Cardano‘s, model.
I was wondering what is Cardano‘s approach to address that challenge.
A related question, also comparison to Algorand; Algorand trumpets that the slot leader (in Cardano terms) picks itself via a VRF. Who picks the slot leader in Ouroboros?

I think you should consider whether this post should be edited to be more specific (detail the attack referred to) or more general (remove references to Algorand) and the title updated accordingly.  The [help] guidelines for quoting external sources should also be followed.

There are around 3000 pools in Cardano network(they call them delegates in that link what you shared). I would expect at least 2 relays per pool, some pools have even more and I doubt that any pool run with just one relay. To take down whole network you will need to DoS(by the way currently nobody use DoS, but mostly DDoS, because DoS is attack from one location and it is ineffective, because you can just block that IP/location with FW and etc) 6000 servers in different locations and different hosting like AWS, OVH and etc. This will be defiantly not an easy task and not cheap, I can assure you. Additionally most hosting like AWS, OVH and etc has quite sophisticated anti-DDOS mechanism:
https://www.ovh.com/world/anti-ddos/
https://aws.amazon.com/shield/?whats-new-cards.sort-by=item.additionalFields.postDateTime&whats-new-cards.sort-order=desc
And if your pool is using other hosting it probably has some similar mechanism to prevent this.
Additionally if your pool will become target of such attacks, you can try to use hidden relays, just allow well known peers to connect to your relays and etc.
To summarize I would like to add that any service connected to internet can be target for DDoS and in theory can be taken down, even bitcoin network, but I personally think this is definitely not an issue for Cardano and in most cases if you follow best practices for system administrating, you should mitigate most of the risks.
Additionally I strongly disagree that you can easily and cheap DoS 1000 people[probably he meant servers/devices, people do not have yet IP connection, I'm still waiting for neuralink :)]

There are plenty of pools with 1 relay node.

Hi, not sure how that affects my answer... There are more then 6k known relays(and much more hidden) - https://adapools.org/relays. So to take down 6000 single relays or 3000 with double relays, seems for me quite a similar task... In any case, thank you for your comment.

It will take a lot more than 1 system (DoS) to take down Cardano!
But we're also protected well from DDoS attacks, here are a few reasons why:

In terms of the network, the a parameter "collateral" in the transaction fee structure helps prevent someone from flooding the network with useless transactions that can cause congestion etc. They must send along some fixed ADA so that makes a DDoS attack this way very expensive.
Stake pools don't expose their BP (block producer) node to the open Internet. They interface through Relay nodes so identifying and attacking the BP is difficult.
Stake pools often have >1 Relays and to successfully stop block production you would need to attack all Relays registered to that pool. Not to mention private Relays that are not registered for peer discovery.
Stake pool operators can take additional DDoS protection measures. Some include: stricter firewall configurations, private subnets, VPN, ets
The attacker can't know who will be the next pool to produce a block. This is due to the VRF (Verifiable Random Function). It's a really interesting concept, definitely consider a read.

To add to this (and answer OPs question in latest edit):
Basically, the SPO (or owner of the VRF private key) is the only person who can determine the random slot number generated by the VRF and therefore only they know when a block is expected.

While the above answers are both correct, they focus on the practical of how an SPO protects themselves from a DoS and the large number of nodes that would need to be attacked to be successful. The real key is the leadership schedule isn't public. An attacker cannot know when a pool will make a block until that block producer has forged and sent the block on to a relay the attacker is monitoring. At this point, it's too late to DoS the node. There's a bunch of really cool cryptography that if you want to dig into, IOG (formerly IOHK) has written many papers on, but the key point is you need to control the VRF secret key to know a block producers leadership schedule. As long as the operator doesn't share that schedule, they can't be targeted when it's their time to make a block.

Commentary on other answers is a bad idea.  They may be edited in future and their position is dependent on the number of votes they get.  Better to focus on answering the question to the best of your ability.  This comment will need to be deleted if the answer is edited appropriately.

This is just a strategy I've been using, feel free to poke holes in it.

Keep your block producer on a private subnet (it does not need to be on the public IP space).
Give it a relay that is not advertised.

In the event that an attacker decides to slow your pool down, the BP still has the unadvertised relay to propagate in a timely manner.


text:
How can I get a fully built transaction from the PAB
According to the Plutus team, the standard way of generating signed transactions containing smart contracts is to have the off-chain code generate a so called unbalanced transaction that is then, in a second step, balanced and signed by the user's wallet. The newest Nami-demo of the PAB repository follows this spirit and makes the observation that this balanceTx method is currently missing in the Nami API. The demo implements a work around method for balancing and comments that this method could be deleted once Nami implements a proper API analog (see line 71 here).
I asked on the Nami repository if we could expect a method for balancing transactions soon: see-here.
The answer was that such a method would be difficult to implement as smart contract execution costs —which are affected by the balancing— need to be factored into the fees and that this calculation needs the availability of Plutus Core (which I guess is not easily achievable for web extensions).
The only way left for implementing smart contracts is to hand over a fully built transaction to the wallet. When using the PAB, the Contract instance would need to build it using the wallet address (and optionally a pre-defined UTxO for the collateral) of the user. I haven't seen any code showing how to achieve this in the GitHub repository. How can this be done ?

You cannot. If you want to use the PAB, you need to send the necessary information from the wallet (utxos, pkh, whatever your script needs) in the frontend and then yield the unbalancedTx back to the frontend, and then balance it there. Alternatively, you could implement your own balancing function in Haskell and do it there. Aiken, Lucid, and Martify Mesh are all examples of front-end transaction building libraries that support transaction balancing. In-fact, you can use any one of those entirely without using the PAB at all.


text:
Advice on how to save a secure document as an NFT on the blockchain on a secure website
I'm very interested in saving some very important digital documents as an NFT on the Cardano blockchain.  I'm very new to NFT's and have some (probably) basic questions for this forum to help in if what I want to accomplish can be done on Cardano.  Here are my thoughts/requriements:

We have important digital documents we sign and send via email to our clients.
I would like to mint each of these documents as an NFT so this important digital document if ever changed can be proven that it was changed because the minted NFT of the document would be the source of truth.
Where do I save this minted NFT document?  I would prefer to be able to save each document on the blockchain with a secure website access.  What I mean by this is our client would need to login to a secure website and each minted NFT document would be available to the client for download.  Or do I need to mint each document as an NFT and build my own traditional website and have each digital document saved on my own server for availability from my own website?
How does the ownership of the NFT work?  At the point the NFT is created who owns that NFT?  Do we own it because we minted it?  What about the rights of the NFT for our client?  We did work for our client and created a digital document of our work and signed our name to that document.  Then we'll mint that document as an NFT.  Do we need to transfer the NFT ownership of that document to our client? Or do we keep the rights to the NFT document and yet allow our client access to the digital document for their use.

Any advice this team can provide me in helping me understand how NFT's can be used in creating secure digital documents and how I can distribute these NFT's to our clients.
Thank you.

I'll provide some advice based on my own experience. It depends on if you want the documents to be publicly viewable or not.
If they are publicly viewable, you can create an NFT with ipfs links to a document. In this case, you upload the document to IPFS. If you don't want it to be publicly viewable, you can create a hash of the document and mint the nft with metadata that displays that hash. Only the original document will ever match that hash. In this case, you should secure your own copy of the documents and allow the owners to access it. Owners should also be able to check the hash.
Ownership of an NFT is basically whoever controls the wallet the NFT sits in. The NFT can minted in your own wallet or in another wallet that doesn't belong to you. Once an NFT is transferred to someone they own it.


text:
cardano-db-sync error
When following the instruction here
https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/building-running.md
I get an error at the last line
PGPASSFILE=config/pgpass-mainnet db-sync-node/bin/cardano-db-sync \
    --config /home/user/relay/mainnet-config.yaml \
    --socket-path /home/user/relay/node.socket \
    --state-dir /home/user/relay/db \
    --schema-dir schema/

the error is
FatalError {fatalErrorMessage = "readSyncNodeConfig: Error parsing config: AesonException \"Error in $: key \\\"NetworkName\\\" not found\""}

Any any help or direction is appreaciated. Thank you

Make sure you are using the right config file. The error is indicating that the config file you are using does not have the NetworkName parameter.

how do I determine if it is the right one? its the one that comes default with cardano-node latest release repo.

I linked the proper one in my answer. You need the config for db-sync not cardano-node

thank you that was pretty dumb of me for not check for that file name ....

You need to use a db-sync config file, not a cardano-node one. You can get the correct configuration file for mainnet/testnet networks here: https://hydra.iohk.io/build/8111119/download/1/index.html. That link is found in the cardano-node release notes under downloads -> configuration files


text:
Need Help finding error in my endpoint code
I cant seem to figure out whats going on? Ive been trying to create a transaction which sends ADA to a specified wallet address and can't seem to get it to work.
type Schema =
        Endpoint "storeFront" PaymentPubKeyHash

payPubHash :: PaymentPubKeyHash
payPubHash = "3f7846896a48c59359746ff096d63606ceb82e65900d20a9fd2b8a93"

storeFront :: AsContractError e => Promise () Schema e ()
storeFront = endpoint @"storeFront" $ \(payPubHash) -> do
    unspentOutputs <-  utxosAt contractAddress

    let
        tx       = Constraints.mustPayToPubKey payPubHash (singleton adaSymbol adaToken 30000000)
    void $ submitTxConstraintsSpending storeContract unspentOutputs tx

contract :: AsContractError e => Contract () Schema e ()
contract = storeFront

endpoints :: AsContractError e => Contract () Schema e ()
endpoints = contract

mkSchemaDefinitions ''Schema

$(mkKnownCurrencies [])

here's the error
Compilation Error, Line 93, Column 12 (jump)

 error:
    • Couldn't match expected type ‘Contract () Schema e ()’
                  with actual type ‘Promise () Schema e0 ()’
    • In the expression: storeFront
      In an equation for ‘contract’: contract = storeFront
    • Relevant bindings include
        contract :: Contract () Schema e ()
          (bound at /tmp/web-ghc-work-c17f548fe0e3f9c3/Main.hs:93:1)
   |
93 | contract = storeFront
   |            ^^^^^^^^^^

It appears you are trying to assign a type of Promise to a type of Contract
contract :: AsContractError e => Contract () Schema e ()
contract = storeFront

Why not try this, instead:
contract :: AsContractError e => Contract () Schema e ()
contract = awaitPromise storeFront


text:
How to pass TxOutDatumNone when building a script transaction with cardano-cli
I'm trying to consume a UTxO from a script address. When querying the script address with cardano-cli query utxo, I have the following UTxO:
                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
10668bed901733bb0977ec72d1abad481865b34ea1c18302caaaa1eafe5784d2     1        1344798 lovelace + TxOutDatumNone

However, when constructing a transaction, I do not know how to represent TxOutDatumNone:
cardano-cli transaction build \
--alonzo-era \
...
--tx-in 10668bed901733bb0977ec72d1abad481865b34ea1c18302caaaa1eafe5784d2#1 \
--tx-in-datum-value WHAT_TO_PUT_HERE \
...

What I've tried:

Not passing the --tx-in-datum-value altogether results in:

Missing: (--tx-in-datum-file FILE | --tx-in-datum-value JSON VALUE)

Passing --tx-in-datum-value 0 results in:

Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with:
The Plutus script witness for the txin does not have a script datum (according to the UTxO). The txin in question is 10668bed901733bb0977ec72d1abad481865b34ea1c18302caaaa1eafe5784d2#1

Passing --tx-in-datum-value null results in:

option --tx-in-datum-value: JSON schema error within the script data: null
JSON null values are not supported.

I'm afraid that presenting a "none" datum is not possible. This also means that this UtxO is lost (anybody, correct me if I'm wrong)
I don't know the very reason why it is possible to send a UtxO at a script address without datum hash, while at the same time it will not be possible to get it back. Anyway, pay attention to always send a datum hash when sending some value at a script address.

I'm leaning to think that's the case as well. But haven't been able to find a definite reference yet.

Found a confirmation to the statement here: https://github.com/input-output-hk/Alonzo-testnet/blob/0ecd57c14570a92c2f6cd102c12b59c99a01a954/Alonzo-tutorials/Datums_redeemer_tutorial.md?plain=1#L131

The reason for this is that in addition to Plutus scripts, there are also native scripts (which predate Plutus), and those don't require a datum. It's impossible to know, given just an address, whether a script address corresponds to a Plutus script or to a native script. Therefore the node can't enforce that UTxO's at Plutus script addresses always have a datum attached.

Usually when you want to pass empty datum to the script you'd pass an empty list like so
--tx-in-datum-value []

This gives me a similar error as passing 0: Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with:
The Plutus script witness for the txin does not have a script datum (according to the UTxO). The txin in question is 10668bed901733bb0977ec72d1abad481865b34ea1c18302caaaa1eafe5784d2#1

You can ignore it. You do not need to account for TxOutDatumNone in your tx-out or anywhere else. See for yourself by manually sending a TX using cli before you script it.

Do you mean not to pass the --tx-in-datum-value option to the cardano-cli transaction build command? Or did you have something else in mind?

Correct. It's not a required parameter, so if you aren't using it (which it doesn't sound like you are), then ignore it..?
EDIT: I see now that you say you've tried this and are getting an error which baffles me - I send hundreds of CLI transactions a day and have never seen that error come up. Are you able to provide your draft cli command TX?

Correct that I'm not using the datum. It seems to me that either of the datum options still has to be specified because the transaction is consuming a UTxO from a Plutus script address. The full command and accompanying script can be found at: https://gist.github.com/discosultan/c03a1ea29d8b3bec8b2825c8fd879afa


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

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


text:
Good tutorials / resources for PAB (testnet)
Does anyone have good resources on the PAB connecting to the testnet? I know Lars Brünjes explained it in the pioneers program, but, at that time, we still had to rely on the emulator.
I also know we have plutus-apps (with Nami demo) and plutus-starter, which are good resources, but there are not a lot of explanations of what each thing does.
Any videos, blog posts or even well-documented repositories would be of great help.

You should read Plutus starter PAB testnet notes and Hosted PAB setup for Alonzo testnet gist.


text:
How do you populate NFT (images) in-game?
Sushibyte (and other game projects) has users input their wallet and then populates specific NFT's as playable images.
Could someone walk me through the logic that verifies the desired policy ID and pulls the NFT's image onto the application?

For the Dapp connector method, how can we convert the getUxto() method to something readable? i.e. How can we convert the given cbor type to addresses. Would have made this a comment but don't have the rep for it

2 ways:

Blockfrost API (Easy): Query a wallet's address UTXOs. If an NFT is owned by the wallet you can find it here.

https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/~1addresses~1{address}~1utxos/get

Dapp Connector: Ask a User to connect their wallet to your website and use the wallet's getBalance() api to get all UTXOs from the wallets.

https://github.com/cardano-foundation/CIPs/blob/e8f56d95993474a24795c834d33026b6449e1d99/CIP-0030/README.md#apigetbalance-promisecborvalue


text:
Connect to node.socket file
I built a cardano node using docker and I created a volume in my root directory ./cardano-node-ipc:/ipc. However I can't seem to find any information on how to interact with the node.socket file inside cardano-node-ipc. I am a Javascript developer and for learning purposes I'd just like to be able to build a basic app similar to https://explorer.cardano.org where I show transactions as they happen. Could someone give me tips on how to connect to the cardano network a see transactions? To be honest I'm not even sure if I am headed in the right direction.

Sam gives one possible path forward above.
However, since you mention https://explorer.cardano.org I should point out the official explorer (which is written in JS) uses the https://github.com/input-output-hk/cardano-db-sync/ project to follow the chain and populate a Postgresql database. The explorer you are writing could then connect to the database.

this is what I was looking for. Thank you so much!

You need to interact with it using the node to node protocol. This is the protocol that cardano-cli utilizes, as well as a 3rd party tool called cncli. cncli is a rust application that understands the chain sync protocol and can be found here: https://github.com/AndrewWestberg/cncli


text:
Is there an OpenZeppelin like library for Cardano?
Developers on EVM compatible blockchains can make use of battle-tested libraries of smart contracts using https://github.com/OpenZeppelin/openzeppelin-contracts
I'm thinking about having a basic functionality, let's say a base auction contract and then the developer can add/modify whatever he/she needs for his/her specific use case.
Is there something similar on Cardano or a base repo with Plutus Smart Contracts on it for us to take a look?
Thanks

There's no official or adopted standard library in Cardano, yet, as it is on Ethereum.
Anyway, in my opinion the best tools and techniques for Plutus can be found in this repo: https://github.com/Plutonomicon
It belongs to MLabs, a Haskell, Rust, Blockchain and AI consultancy that has built more than 30 projects in Cardano.
There is also more information about their tools here: https://plutonomicon.github.io/plutonomicon/

You can find reference plutus implementations here on github that can be used as a starting point:
https://github.com/input-output-hk/plutus-apps/tree/main/plutus-use-cases/src/Plutus/Contracts
You can also look at the cardano essential list and hopefully there will be more open source projects that you can also reference in the future.
https://github.com/input-output-hk/essential-cardano/blob/main/essential-cardano-list.md


text:
nix installation failure on mac with "curl: (60) SSL certificate problem: certificate has expired"
I'm trying to install nix on my macbook but I had following error message.
How can I fix this certificate expired problem?
macOS : High Sierra 10.13.6
Thanks in advance.
//-- error message ---
~ MyMac$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure.

This is not really Cardano question, but seems your Mac has problem with certificates.
Quick fix will be just to add -k, like this:
sh <(curl -k -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

This will ignore certificate issue.
In longrun you need to dig dipper, maybe you need to reinstall your root certificates, or update your MacOS.
Maybe this will help:
https://www.digicert.com/blog/expired-intermediate-certificate

Thank you for your kind answer. in fact I've tried to add -k option but it is not working as below. MyMac$ sh <(curl -k https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0, I'll dig into more as your help.

You forgot -L in your command. Just copy from here sh <(curl -k -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

Yes, you're right. it seems working. thank you so much!

If it worked, I would appreciate if you will accept my answer as solution. Cheers!

sure, thank you.

I've also up-voted the answer but would caution against having non-Cardano questions here going forward.

I totally agree and I do think that non-Cardano question should not be here. I was tending to help, because OP wanted to install nix what is widely used in Cardano project, at lest per my understanding


text:
Plutus environment set up: pro and cons
I am starting the Pioneer program by setting up the development environment. There are several ways to do that, I think 4!
At the end the two that seems to me more appealing are the one using nix or the one using docker.
The former complex but allows you to create an environment that is more up-to-date.
The latter is more easy (at least for me) and less time consuming.
Is there any real advantage to use the former?
Can we encounter some limitation by following the latter?

I'm afraid that there are more than 4 ways to setup an environment to follow the Plutus Pioneer Program, considering all the combinations of operating systems, virtualization options and application packaging.
The first thing to decide is if we're going to use some kind of virtualization technology to isolate the environment. In my experience this is highly recommended because:

you avoid possible incompatibilities with your host operating system and any already installed software, specially on development systems with many package managers deployed.
it keeps your host clean so you can easily start over from a clean state if things go wrong.
it allows you to choose a base system that is known to work well independently from your host system.
it creates a certain degree of independence from the physical layer (depending on the technology used), to the point where you may decide to setup the exact same environment in the cloud as you don't have the free resources needed in your local computer.

Now, you have two main options to virtualize the environment, a Docker container or a virtual machine.

The Docker option requires that, after installing the software, you run an image that someone has previously built (quick and reproducible option), or that you build it yourself using a Dockerfile. In my opinion it may make sense if someone is maintaining images for each week's environment version, with everything already compiled, aiming to save some time, otherwise a virtual machine can offer more flexibility for this use case, persisting changes without much overhead, and allowing to experiment in a more comfortable way.

The virtual machine option requires that you install a virtualization software, for example Virtualbox, to deploy a local instance, or that you deploy a cloud instance, for example an AWS EC2, and then that you choose/install your preferred operating system, and finally on top of that install the toolset required to compile the Plutus environment. This can be a bit confusing the first time if you're not used to the tools, i.e. nix, cabal, etc...

Be aware that in previous iterations we needed to weekly recompile the environment to make the code samples work, as a consequence of the Playground being under heavy development.
Fortunately the community made an effort to further document the process for a variety of scenarios, and made it available at the website:
https://docs.plutus-community.com/
https://plutus-community.readthedocs.io/
Please consider contributing to the following repository:
https://github.com/input-output-hk/plutus-community
There's an option that in my opinion takes the best of both worlds for this use case, which is to make use of Vagrant to get a running virtual machine but automating all the initial setup process. You can find instructions on the previous links for a Vagrant+Ubuntu setup.
I wanted to use Vagrant+NixOS for its deterministic nature and its native integration with part of the required toolset, so I developed a Vagrant file and a set of scripts to automate the setup process that can be found here:
https://github.com/jmhoms/plutus-pioneer-nixos-vagrant
I plan to follow this third iteration that is about to start, and I'll try to update the scripts as the course moves forward.
I hope this helps.
Cheers!
Josep

I am not familiar with Vagrant, does it have the problem you described for docker of relying on "someone maintaining images for each week's environment version"?

Definetly! For the sake of the learning I will go for an Ubunti virtual box on my windows machine. Then I am gonna use NIX to get the plutus development env and recompile it.
The fact that everithing is under heavy development make things much more exciting!

Mateus, think about Vagrant as a wrapper to easily setup for you (just with a couple of cmd lines) an underlying Virtualbox (or others) virtual machine from a pre made image. At the end, you'll have an operating system with the Plutus toolset compiled. Obviously if some weekly exercise requires a different Playground git commit, you'll need to recompile. For this reason I created a git project with a Vagrantfile that takes care of the initial setup, and some scripts that compile the right commit for each week of iteration 2. I plan to do the same for iteration 3.

So yes, sort of same issue with Vagrant. In my vagrant-nixos scripts, even if nobody takes care of updating them, you should only need to pass the proper commit id (which is specified inside the weekly project file) to the generic script to get the same result. The existent Docker options probably work in a similar way to update the environment, I guess it makes sense to just change the commit id and recreate the image. So in neither case you're really dependant on someone else updating it, but just saving lot of time IF using an image provided by someone else with the environment precompiled.

VirtrualBox is not supported on Apple M1 arm64 architecture. Is it still possible to leverage virtual machines?

Kevin, I'd suggest that you open a new topic for this question, but basically you could use Parallels ( https://www.parallels.com/ ) or maybe a solution based on QEMU. As an alternative, you could run the VM in a cloud provider paying for usage time, or even use a Docker container locally (I think a flag exist to run Intel images on your ARM computer, which would save some time). Cheers!

For those coming now, you can find the new docs website here https://plutus-community.readthedocs.io/

Typically the team loads all new working code to the Nix container. Additionally, it is more compatible with Haskell/Plutus because it is also written under functional paradigm. I tend to suggest everyone using Nix, once you get familiar everything flows smoothly.
You should check at this set up from the First iteration (for your preferred OS):
https://docs.plutus-community.com/docs/setup/Ubuntu.html
Note that the lectures are outdated but the set up is the same

I agree that Nix is the way to go as it will give you the same processes the Plutus educators and devs are working in. Be sure to follow the instructions offered after the webportal went down.
I went with the canonical plutus-apps repo build for the playground. It is the 3rd option off of the document shared after the portal dropped:
**[Plutus Env: Setup Starter Pack].**

BTW, I am using ubuntu 21.04. I have also done the same install on a straight debian build. Sometime over the next couple days I will do the build on my Win10 laptop (dual booting with the Ubuntu).
I hope this helps & Good luck!

Indeed. I would prefer using Linux, Ubuntu. Saves you lots of time. You can run it together with a windows installation. Building the shell with Nix is the way to go. I have set up instructions over here .. also Mac and Windows.
https://drive.google.com/file/d/1u6QDsZCPnZQ_QiV8hBihgfFh82iTFs7M/view

We're a little different from other sites; this isn't a discussion forum but a Q&A site, where we reserve the answer space for answers. Please check out our short [tour]. Could you please [edit] this to more directly address the question? Thanks.


text:
Plutus Playground: error evaluating 'hello, world' example
When I try to evaluate the "Hello, world" example at https://playground.plutus.iohkdev.io/, I get the following error:
DecodingError: An error occurred while decoding a JSON value: Under 'EvaluationResult': At object key 'emulatorLog': Under 'Array': At array index 0: Under 'EmulatorTimeEvent': At object key '_eteEvent': Under 'EmulatorEvent'': At object key 'contents': Under 'ChainEvent': At object key 'contents': At array index 2: Under 'Tx': At object key 'txData': Expected value of type 'Object'.
Please try again or contact support for assistance.
Any idea?

it's a known issue: https://github.com/input-output-hk/plutus-apps/issues/195

since you have the answer you can post it as an answer to your own question here. Perfectly legitimate practice in Stack Exchange, and you get more rep :)

@MatthewCapps, thanks for a hint

This issue is reported at github.com/input-output-hk/plutus-apps/issues/195
Please have a look at Starter Pack (https://docs.google.com/document/d/13112LHG9vVvNUs40oZSqZ-DF6_yFiT_SJZ2NaEmjMM4) for the steps to set up a local instance of Plutus Playground.


text:
How to start plutus pioneers course on canvas
Today is the course start date for pioneers program.
But when i login to canvas, i am not getting any content.
I checked the announcement board and it just shows me up course syllabus and the teacher's bio.
how am i supposed to start learning within the canvas?
thanks!

This is to confirm that I see the same thing, and it seems there is no info on how to proceed.

Hi Shimelis! The first module will be posted on Thursday, but in the meantime pioneers are working on dev env setup-- discussions occurring in Discord. NOTE-- Generally avoid posting questions about how the course is run here in CSE, as such questions tend to have short term utility. I realize initial Canvas setup was confusing, a recent update there + getting into discord should make things clear.

The first lesson will be released on Thursday 13 as mentioned in the communication on Discord. In the meantime you can start with the setup of the Plutus environment.

Yes today is the beginning of the Plutus Pioneer 3rd version. However, there are some technical set ups to go through before the first lecture is published, which will occur on Thursday 13th. Some news will come up soon, but I suggest you have a look at
https://docs.plutus-community.com/docs/setup/Ubuntu.html
Where you can sort your set up for your preferred OS (lectures are outdated but the set up should be the same)

Thanks @Igodlab and @Antonio - CSP.
I am thinking to continue with with playground setup.
I didn't want a local setup on my machine.
What do you suggest on this?
pros and cons kind of advice.