text:
Will ERC-20 converter support the legacy ERC-20 token itself?
I recently learned that Cardano is about to launch the Erc20 tokens swapping functionalities. This makes me really happy for multiple reasons since ETH had disappointed me in many aspects over the years (Been in crypto since 2013 and dealing with Eth since '15 - '16) So I'd like to get out of it as much as I can.
I'm currently wondering, if I'll be able to swap the Erc20s themselves?
Meaning; not any particular tokens that are built on Erc20 but the Erc20 standard token itself.
The reason I'm asking for is that I obtained some amounts of Erc20s around 2016 and was willing to forget about them for the long term, thinking that they were a good investment since it was pushed out to be a "standard", little did I know and I learned years after, that they ended up changing/updating the standard itself and not only there are now various more standards as well, but there is this old Erc20 and the new Erc20 now. This is one of the biggest let downs for me from the ETH ecosystem as I feel somewhat duped on the subject.
I've been researching the web for months now, on how to convert these old ones to the current version but the closest I got requires large amounts of gas / transaction fees. Feels almost not worth it, so I'm stuck with them like this.
So I am wondering (and hoping) if there will be an automated contract solution from Cardano to swap/convert/update these in relatively cheaper costs if not cost free?
The honest reasoning I have behind this, is I would assume that the developers would still need these tokens for various applications and perhaps some contracts would still be requiring the old versions of this ERC20 standard. So may be not exchanging or swapping them for their current value but perhaps fueling some backwards compatible smart contracts etc. I tend to refuse that this is not the case because otherwise the whole Ethereum ecosystem seems like an everchanging, evergrowing and evolving scam.
I know Cardano is relatively beyond this but having it's roots based on ETH I trust people here, would have some knowledge and guidance about this. Keeping in mind that ADA community seem mostly focused on solving these very issues which hurt the users and the investors.
I apologize for the lengthy post and  I thank everyone so much in advance to those who'd be willing to enlighten me on the subject.

This is a good question but I think converting is more for the developer converting their token(Smart Contract) to run on Cardano without requiring a full code rewrite as ERC20 contract is based on Solidity and wouid not be able to run on Cardano network so if you have a ERC20 smart contract project it can be converted to run on Cardano.

Thank you for your reply. I agree that this issue should concern the developers and not the user. That's why and where I feel betrayed by the ecosystem.
This whole issue shouldn't have been my problem and as an investor/user, I shouldn't have had to deal with this. That's why I'm counting on the Cardano team to save the day.

I had a similar user experience with the Golem project on ETH. I got lucky when the fee to convert the old to new for about $50 bucks. At times the price was as high as $400.
There isn't any talk about this particular issue with projects having a split ERC-20 token before moving to Cardano. That being said it should be possible to fix this however no matter the solution, anything on the ETH network will have to pay ETH fees.

ERC20 Price is currently at $0.04621 and ERC(OLD) is around 0.000039$
I invested in ERC20 and seeing this really scars me.
I wouldn't mind paying a fee for swapping this token for another, but paying a fee to "update" it just doesn't seem fair. Since it is "imposed" by the developers.
Isn't there some sort of a treasury like Cardano has, where the user's costs for "updating" their token contract is covered by the network automatically?
I just hope that the Cardano team comes along with a solution and saves people in this situation like myself.
Thank you for your reply by the way.


text:
Can I use a custom word list for my wallet recovery phrase?
Is it possible to use a custom list of words to generate my Cardano wallet recovery phrase?
The reason I think this would be useful is, that one could use words from other languages.
As far as I know the recovery phrase has a checksum (the last word), so it's not possible to just replace some words with random other words in an existing recovery phrase.

According to CIP3: Wallet key generation, Cardano is using seed words from BIP39, therefore you can use words included in BIP39 only.

As an architect/developer of your own crypto-wallet for personal use, you can declare your own list of 2048 words (although it's highly undesirable). However, if we talk about it in the sense of already existing products, such as Daedalus or Yoroi, it's impossible, because BIP39 wordlist is deeply integrated there.

source: Stack Exchange

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

sort: votes


text:
Is the metadata limit on testnet transactions the same as mainnet?
I was wondering if there was a difference in the byte limit in metadata added to test-net transactions versus being done on the main-net.

The transaction metadata limit is the same on both networks, as they share the same ledger rules.

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


text:
What randomness algorithm does Yoroi use for wallet generation?
What randomness algo does Yoroi use for the wallet generation? Interested in seeing how secure it is.

Yoroi is using the bip39 JavaScript library to generate the mnemonic.
When we look at its code, we can discover the generation is actually pretty simple:
function generateMnemonic(strength, rng, wordlist) {
    strength = strength || 128;
    if (strength % 32 !== 0) {
        throw new TypeError(INVALID_ENTROPY);
    }
    rng = rng || randomBytes;
    return entropyToMnemonic(rng(strength / 8), wordlist);
}

We see that as no random number generator (rnd) is defined, it uses the randombytes library by default, which is in place using the Crypto.getRandomValues() function that is provided from your browser.
To sum this up, Yoroi is using randomness algorithm of your browser, which - depending on the browser - is your system-level entropy source.


text:
Does Yoroi support the gateway-like features of Metamask?
A really powerful feature of Metamask is that websites can easily use it to connect your wallet - i.e. uniswap, sushiswap, and so on. Does Yoroi support a similar feature?
If not, are there other tools that do?

No, Yoroi doesn't interact with Metamask. However, Yoroi does have this functionality in development-as I understand it.
Here is a clip of one its developers speaking on this matter.


text:
How can i generate new wallet address using cardano-wallet cli and cardano wallet api after created my wallet?
yoroi and daedalus provide UI to generate new wallet address, how can i use cardano-wallet cli and cardano rest api to generate new address?

Once you have your cardano-wallet runnig, you can create a new wallet using CLI with the following command:
$ cardano-wallet wallet create from-recovery-phrase "My Wallet"
Please enter a 15–24 word recovery-phrase sentence: <enter generated recovery-phrase words here>
(Enter a blank line if you do not wish to use a second factor.)
Please enter a 9–12 word recovery-phrase second factor: <skip or enter new recovery-phrase words here>
Please enter a passphrase: ****************
Enter the passphrase a second time: ****************
$

See more cardano-wallet cli commands.

To create a new wallet using cardano-wallet REST API, you can use the following command:
$ curl -vX POST http://localhost:8090/v2/wallets \
   -H "Content-Type: application/json; charset=utf-8" \
   -d '{
        "name": "Shelley",
        "mnemonic_sentence": ["identify", "screen", "lock", "bargain", "inch", "drop", "canyon", "flock", "dry", "zone", "wash", "argue", "system", "glory", "light"],
        "passphrase": "Secure Passphrase",
        "address_pool_gap": 20
        }'

See REST API documentation for more information about this call.

I know how to create wallet, I have already read the documentation. I want to know how to generate new address when you created your own wallet, there is 20 address in your wallet after created, I want to generate more.

This is what address_pool_gap is for, you can specify more than 20 address, but be careful!  Using values other than 20 automatically makes your wallet invalid with regards to BIP-44 address discovery (https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki). It means that you will not be able to fully restore your wallet in a different software which is strictly following BIP-44.

Do you mean something like that?
# generate keys
cardano-cli address key-gen --verification-key-file payment.vkey --signing-key-file payment.skey
# build address from pubkey
cardano-cli address build --payment-verification-key-file payment.vkey --out-file payment.addr --mainnet

yeah, but instead of using cardano-cli, i'm using cardano-wallet cli and wallet backend restful api.


text:
Using cardano-node installed by Daedalus as CLI?
I want to do some transaction with custom metadata and was wondering if I have to install another instance of cardano-node or if it's possible to use the already installed version by Daedalus.

Yes, it is possible.
First, you need to install cardano-cli binary (you can find it in the Hydra build system, depending on your OS which might be Linux, Windows or Mac OS.
After you have your cardano-cli installed, you now need to set your CARDANO_NODE_SOCKET_PATH environmental variable to the location of your cardano-node socket file that is being run by Daedalus.
This code snippet will do just that, extract the path to the socket file from the cardano-wallet instance.
Depending on the network, you will execute the following for testnet:
export CARDANO_NODE_SOCKET_PATH=$(ps ax | grep -v grep | grep cardano-wallet | grep testnet | sed -r 's/(.*)node-socket //')

# Check var it must be path for file of node socket and not empty
echo $CARDANO_NODE_SOCKET_PATH

Or the following for mainnet:
# Create var CARDANO_NODE_SOCKET_PATH
export CARDANO_NODE_SOCKET_PATH=$(ps ax | grep -v grep | grep cardano-wallet | grep mainnet | sed -r 's/(.*)node-socket //')

# Check var it must be path for file of node socket and not empty
echo $CARDANO_NODE_SOCKET_PATH

After you have done that, you can now try to query the network using your cardano-cli, for testnet:
$ cardano-cli get-tip --testnet-magic 1097911063

Or for mainnet:
$ cardano-cli get-tip --mainnet

Source: this useful gist

Could you expand some more on how to use this? It's not immediately clear to me from just looking at the Gist.

@ValentinWalter can you check now? I tried to elaborate it a little bit more.

I found on Mac OS that the sed -r option doesn't work, but using -E does.


text:
Why do we need TxOutRef in addition to TxOut?
I'm sorry if it feels like an odd question.
In Plutus.V1.Ledger.Contexts module I see that TxOut is a transaction output and TxOutRef is a reference to a transaction output.
In code, we use it often to

check some statements about txInputs
to describe a transaction's constrains

But what was the reason behind the introduction of this abstraction? What would be a correct analogy?
Thank you

Welcome to the site!

A TxOut cannot be used to uniquely identify an UTxO, as it is just an address and a value.
TxOutRef is unique as it is the transaction id and the output index within that transaction.


text:
How to send ADA to Daedalus Mainnet wallet?
I downloaded Daedalus Mainnet 4.0.5.  I created a wallet, but I don't see an address where I can send my ADA from an exchange.

Go to the Receive tab to select an address.

Click on Wallet icon and then Receive tab. Choose one of twenty addresses and click it. Now you're able to copy an address or scan a QR code to send your funds from exchange.
Besides, Cardano uses the EUTxO accounting model on the mainnet. According to this, user-friendly Daedalus wallet automatically choose a new address to send change to it, if you send a part of funds back to exchange.


text:
Why is a separate Catalyst Registration Transaction required before voting?
According to Cardano Improvement proposal 15 CIP15, Catalyst voting happens on a side chain and one needs to "register" to participate on this side chain by submitting a registration transaction on the mainnet chain. The registration metadata contains following

"voting key" to be included in the side chain.
Associates mainnet ADA to this voting key
Declare an address to receive Catalyst rewards

Out of these three parameters, the staking mechanism provides two parameters for every wallet staked. The amount of staked ADA and reward receiving address.
If the voting key is also made part while wallet is staked, then there is no requirement for a separate "Registration for Voting" process.
What is wrong with this approach, why is a separate registration process being followed?

You seem to have answered your own question here (a very good answer).  I think you could put most of the text in an answer and replace the current text with a short explanation of the registration transaction that is required.  This also helps get the site out of beta.

Your approach is mostly correct.
We need at least one transaction including your Catalyst key in the metadata and associating it with your staking account. There is no other way to do this since your Catalyst key is derived from your wallet private key and requires a signing step. After that happens, it is possible to not require any additional registration transactions in future Catalyst rounds, since your wallet balance can always be inferred from your staking account. But while this is technically possible, it's something that the community should agree upon first, so that all involved entities adapt to this new registration process.

I do not get it. You do not need to make a transaction to sign something.

You need a transaction to commit that signed message. You can create a message with your registration data and sign it without submitting it to the blockchain., and instead just submit this message directly to the Catalyst app. But then there is no way to prove that you registered.


text:
What is Alonzo?
I have heard about the Alonzo update, but I was not able to understand exactly what this will change for cardano. It is said it is a step toward Goguen, but that is not very explicit. How many steps do remain to get there? What will it achieve?

Cardano's Gougen era, which is the era that will enable what is generally understood as smart contract capabilities comparable to Ethereum's, consists of three major Hard Fork Combinator (HFC) events:

Allegra – Transaction metadata capabilities
Mary – Native assets (the Cardano pendant to ERC tokens on Ethereum)
Alonzo – Smart contract capabilities

The original Cardano roadmap defines 5 main Eras: Byron, Shelley, Goguen, Basho and Voltaire. Each of these include several milestones, usually in the form of a hard-fork that changes some of the underlying ledger rules in order to enable some new features and functionalities.
We are currently in the Goguen era. The transition from the Shelley era to the Mary era was enabled by the Mary hard-fork. But the main hard-fork that will bring smart-contract functionality to Cardano is Alonzo. There are a few other steps to get there, like a multi-stage testnet roll out, but essentially there should be only one single hard-fork involved.

Yes but what will Alonzo achieve exactly?

Alonzo will give programmable blockchain, by the way of smart contract functionality. It will provide Plutus language support to write smart contract.

@raghu and so what remains to do to get to goguen era? I thought Goguen era was just that.

The Goguen era is complete, only if smart contract (Alonzo) is in place. Smart Contract is still not in mainnet. We can only say that we are in full Goguen era.

@raghu So you mean that Alonzo is the final step of Goguen era?

@Distic that's what he meant, yes.

@vaz But in your answer you wrote "there are a few other steps to get there", so if you could just elaborate a bit on what will be possible after Alonzo and what will remain to do, I would be able to accept your answer.


text:
Is there a way to calculate the intrinsic value of the ADA token?
I've been trying to wrap my mind around this problem.
How would one be able to semi-accurately (I know it's impossible to accurately do this) find the intrinsic value of a crypto asset. The only thing I can come up with is its utility.
Assets like bitcoin have the most basic utility of transferring perceived value from A to B not matter where A or B are via the internet, no middlemen involved, totally permissionless.
But then assets like ada must have more value than that because they can do the same transfer of value, faster and cheaper, and they are also required to access an ecosystem of dapps and virtually limitless applications.
How can we valuate such a token?
Has anyone been able to come up with a formula that's somewhat objective?

It is not a cardano question, or even a cryptocurrency question, but actually a question about economics. It seems to me that the idea of an intrinsic value is baseless. Value, like beauty, is in the eye of people and not in the things themselves.

Agreed, it's not specific to Cardano but it applies to it as much as to any other thing people consider valuable.

Agreed, not a Cardano question but an economics question, voting to close it.

Personally I don't see a problem with us allowing questions that are not "directly" related to Cardano (most SE sites will allow tangentially related questions too), but the community seems to have decided on this one and I'm outnumbered. I recommend you consider asking this on Economics.SE or PersonalFInance.SE or one of the many other sites (first check if it's in scope and check for a "duplicate" question).

Thanks, appreciate you trying anyway.


text:
Is there a ready to go (boilerplate) project to make request/rpcs to my daedalus (cardano-node)?
Since cardano-rest is deprecated not sure if cardano-graphql is the way to go just to get data from the blockchain. It seems like the setup to start with is very complex for newbies.
I've never used Docker or Graphql, but I have nodejs/JavaScript/JSON/HTTP/RPC skills. What is the lightest set-up to communicate with the Cardano blockchain?

You can use dandeliona APIs as available here provided by Gimbalabs or BlackFrost in case you wanted hosted services. Running docker image for Cardano-graphql is not that involved.

It is if you don't have docker installed. Plus is getting complicated when you start getting errors like this one: https://github.com/input-output-hk/cardano-graphql/issues/508


text:
Does txInfoValidRange adjust as time continues on?
Given that the function A contains B is true when all of B is contained in A, and false otherwise, wouldn't that mean that the txInfoValidRange info would have to move its "start point" in order to return true? Below is my thinking :)
checkDeadline = from (deadline p) `contains` txInfoValidRange info
In this code, from (deadline p) contains all of the slots from some deadline to pos infinity.
---Below is where I think I am wrong---
txInfoValidRange info is just a SlotRange from the creation of the transaction to pos infinity.
So how then can the deadline p contain the txInfoValidRange info without the txInfoValidRange info adjusting its starting point?
Thanks!

I hope I understood your question correctly. No, we don't move anything.
I think that the naming is confusing. It shouldn't be called deadline because in my opinion deadline is when something ends. In our case, it's the other way around. We allow taking funds only AFTER the deadline.
Please take a look at the picture. We shouldn't allow Tx1, only Tx2.

In our case [deadline, infinity] doesn't contain Tx1.validRange contains Tx2.validRange.

Thanks for the response! I think my confusion stems from the txInfoValidRange. Where does the valid range of a transaction start? And more importantly, what factors decide the valid range of a transaction?

From my understanding you should specify validRange yourself during transaction construction. It could be done with mustValidateIn function from Ledger.Contrains module. You can find an example here https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week01/src/Week01/EnglishAuction.hs#L325

Seems to me like this deadline thing is redundant then. If you can simply specify the range when a transaction should validate, you can just set the start of that somewhere in the future. Lars is trolling us!

@IsaacPadberg Hmm, I don't think that you can put totally random valid ranges. From my understanding current slot should be a member of validRange. Check out this function https://alpha.plutus.iohkdev.io/doc/haddock/plutus-ledger/html/src/Ledger.Index.html#checkSlotRange

I failed to keep in mind the structure of validation scripts and transactions. Simply by constructing a transaction after the deadline, the validRange of the transaction will be contained in the deadline->Infinity. So obvious! Thanks for the help Yanis :)


text:
Is it possible to access spent transaction output of a PKH with Plutus?
As stated in the title, I would like to be able to acess the already spent Tx Outputs of a particular Public Key.
How might one go about it?

Plutus newbie here. From my understanding, you need to hash PubKey to receive PubKeyHash, then construct an Address from PubKeyHash, and then use utxoAt function.

When you say access, do you want to consume it or simply view it? Consuming an already consumed UTxO is not allowed because that would enable double spending:) If you just want to view it I think Yanis had a sufficient answer.


text:
Will Daedalus have a Fiat payment gateway?
I am a rookie at cryptocurrencies: I would like to know if Daedalus will have a Fiat payment gateway. Thank you very much in advance.

I would love for this to happen. It will go a very long way for adoption and ease of use.

There is nothing specific apart from the fact that in one of Charles' interviews (I cannot find it at the moment) he mentioned that after there are DEXs and other components it will be very easy to add additional functionalities including easier ways to pay and convert crypto for fiat and vise versa.
Charles also spoke in 2020 about adding the functionality which now is available to get the current price from CoinGecko.

I believe I've heard rumors for just this; although I'm not turning up anything now. However, according to this the Yoroi Chrome extension provides this functionality. But I wouldn't know, I don't use in-browser Yoroi.


text:
How is a transaction output's address generated?
In Week 6 of PP Lars finds an oracle input with the following code:
oracleInput :: TxOut
    oracleInput =
      let
        ins = [ o
              | i <- txInfoInputs info
              , let o = txInInfoResolved i
              -- addr = oracle's address
              , txOutAddress o == addr
              ]
      in
        case ins of
            [o] -> o
            _   -> traceError "expected exactly one oracle input"

Does it imply that if a script creates a transaction then transaction outputs will reference the script address through txOutAddress field?
Thank you :)

Here is the code in question: https://github.com/input-output-hk/plutus-pioneer-program/blob/36084859defd87c6f13eb166ec64f0d6c6db1242/code/week06/src/Week06/Oracle/Swap.hs#L57

I am not sure I understand the question...
First of all, scripts do not "generate transactions", but validate transactions. Transactions are generated by wallets (and off-chain wallet code).
Now, what is the output of a transaction? In the EUTxO-model, it is given by three "things":

an address
a *value' and
a datum.

The txOutAddress function simply extracts the first component of this triple.
So in my example, I am looking for inputs who try to unlock outputs that "sit" at the oracle address. Since the oracle address is a script address, the corresponding oracle validator script will be executed to determine whether the transaction I am looking at is allowed to consume this input.


text:
On-chain and off-chain for Plutus SCs
Hi I am currently at lecture 5 of the Plutus Pioneers Programm and I was wondering which part of the code is on chain and which is offchain. I know that the valididation script is onchain but the whole code is in one file, so how can later on some of that run offchain? And can maybe someone explain how this is handled in Ethereum?

I'm noob when it comes to plutus but i was curious to one thing: Where is the off-chain code stored? is this stored on-chain to be executed off-chain? or does it not work in that way?

I know that the valididation script is onchain but the whole code is in one file, so how can later on some of that run offchain?

Technically, everything you see in the file is off-chain code.
It is specifically the code that gets compiled into Plutus code that will be executed on-chain. And, yes this includes Validators and Policies. You can see how the monetary policy is compiled in the NFT code for lesson 5 here.
Everything else is used to either

Submit the compiled code on-chain, or
Interact with the submitted code

It's worth noting, people could write whatever off-chain code they want to interact with the on-chain code as long as the hashed policy address is the same here. It's the job of the policy writer to keep people from abusing that freedom.
It's nice having everything in one file/project so things can share types. It all starts as Haskell after all :).

The on chain part is basically every piece of code that runs when the nodes perform validations on whether you have the rights to spend UTOXs or you can mint or burn currencies (validator script and monetary policies). The term "On chain" I guess refers to the execution context of said code and since this validations are performed by the blockchain, that "on chain code" term was coined.
However, if I understand it correctly, these scripts do not actually live on the blockchain, but only the hash of the validator script does (along with the value and the current Datum of the UTXO), and is the spending transaction the one that must provide the right script for the nodes to validate (along with the new Datum and the Redeemer). Of course this script must match the script hash on the UTXO.
It works similar to the pay to script hash transactions in bitcoin, but adds the concepts of Datum and Redeemer and provide access to all inputs and outputs of the transaction so more sophisticated validations can be made.
So to summarize:
On chain code: All code that is executed by the nodes at validation time (UTXO validator script or monetary policy).
Off chain code: All code that is run by the wallet before sending the transaction. This code will construct the valid (or invalid) transaction to be send.

Thanks I think this helps

Mitchel Turner is right but for myself in the beginning i tried to think of things a little "simpler"
The validators basically run "on chain"
and the contracts (everything that result in the type -> Contract) runs in your(the users wallet) wallet.
So what that i took away from that.

the contracts just create/build a transaction from ground up in your wallet or "hidden" in the user interface that you create ... and will the be submitted to the chain

"the chain" will then use your validator to well validate this created transaction

the offchain code does the "heavy lifting" in setting every thing up ...

the validator is just there to say okay this transaction is okay or not

this "mindset" helped me in the beginning to start understand things ... and im still in the process of getting the whole picture ;)

On-chain part refers to all things compiled to the plutus core. This compilation is driven by haskell template engine and the code is wrapped in a haskell data structure.
Off-chain part interacts indireclty with the ledger. In fact this part runs in a sandbox called PAB (plutus application backend) which is capable of interacting with the cardano passive node (entry point to the cardano blockchain)
Off-chain part can lock (e)utxos or spend them.
When it comes to spending the transaction created by the off-chain part besides providing inputs and outputs needs only to provide hashes (hash for script and hash for datum). Those hashes can be computed by taking before compiled plutus script (wrapped by some haskell data structure) and performing some computation (calling function)
For spending however the transction being submited needs to contain the script, all required datum and of course redeemers as a wittneses.
To summarize the whole code related to the smart contract is sitting in a PAB. The offchain part is generated during compilation by haskell template engine and wrapped in haskell data structue. Off-chain part when needed  unwraps the plutus from underlying data structure and submit it as a part of a transaction.


text:
Is it possible to generate your own Cardano ADA private keys and public addresses externally and import it later for use into a wallet?
For ETH and BTH you can generate a private/public keys (secp256k1 Elliptical curve) and SHA-3 (Keccak) hashed public wallet address via code (Python, Java or what ever language) via an pure math algorithm externally then use that address in wallets for payment to cold storage.
Is it possible to generate keys/addresses for Cardano ADA this way in code externally without any interaction from any 3rd party wallet application (Daedalus, Yoroi), then import it later into a wallet when needed to be used for payment or redeeming from cold address storage?

There are a variety of projects within the IOHK Github repository that may give the correct level of interaction you desire. After some digging I think the cardano-addresses project would fulfill your needs.

The answer is: definitely yes.
You can generate those keys offline and off-sync using cardano-wallet utility. Please read my medium stories to find out how to do that: Wallet Command Line Interface.

As others stated above, yes you can. You will need the cardano-wallet or CLI from iohk but I wouldn't consider that 3rd party. There is actually an easy way to do it following Coin Cashew's How to Build a Cardano Stake Pool Guide
Go to Section 10. Setup Payment and Stake Keys. Then skip down and choose the Mnemonic Method. This will walk you through doing this.


text:
How to calculate the current reward of a pool at current Epoch using graphql
Having this Graphql query I know how many blocks this pool has produced on this epoch.
query stakePoolById($poolId: StakePoolID!) #$epochId: Int
{
  stakePools(where: { id: { _eq: $poolId } }) {
    url
    margin
    fixedCost
    blocks {
      epoch {
        number
        fees
      }
    }
  }
}

The problem is that I don't know how much a pool get for each block produced. I guess that knowing that constant I can sum all the blocks produced and subtract the margin and the fixedCost.
Is this the right approach?

Where can one find the schema you're querying? To me, this comes out of nowhere.

I'm using https://graphql-api.mainnet.dandelion.link/ and https://input-output-hk.github.io/cardano-graphql/

It is not a per-block constant. Reward calculation certainly is based on the number of blocks a pool makes, but along with a set of parameters and complex algorithm.
The reward calculation is done based on the below params,

the monetary expansion ratio
fees collected during an epoch
TAU - the percentage of rewards to go into the treasury
slot-co-eff and number of slots per epoch
total number of blocks minted by all pools in an epoch
total stake in the epoch by all pools
total stake controlled by a pool
pledge of the stake pool

Plus, the calculation also includes all these parameters based on epoch snapshots. The full calculation is quite big. But I hope I could give you a path to start with. You can find the documentation regarding the same at the below link,
https://docs.cardano.org/en/latest/explore-cardano/understanding-pledging-and-rewards.html
Also, these parameters and snapshots are not available in graphQL, you can use ledger state dump for rewards calculation.

Would you say that all those params can be extracted from the blockchain using Graphql to make the perfect calculation. Or am I losing my time?

You can get all the details you need from the ledger state dump. Graphql does not provide enough information for rewards calculation.

Do you have any idea on how to make a good estimation instead of the perfect calculation?

you can look at the previous epoch rewards data for a pool at cardanoscan.io, and consider the per block reward by dividing total rewards by the number of blocks it minted. NOTE that this is a very very high-level estimation.

The link in the answer is currently broken, does anyone knows where it has been moved to?


text:
Alonzo being a hard fork, will Daedalus support it automatically?
How should the users prepare for the upcoming Alonzo hard fork?
Will it be as simple as just updating the Daedalus wallet when it's out, or are there some precautious actions that we have to take (Like undelagating from the pools etc) ?

Users of Cardano will have nothing they need to do.
Cardano uses the Hard Fork Combinator which allows upgrades to the protocol while keeping all previous blocks from the previous eras.
https://docs.cardano.org/en/latest/explore-cardano/what-is-a-hard-fork-combinator.html#what-is-a-hard-fork-combinator
This process has taken place last year with Shelly that turned on the delegating system today.

Thank you so much.
It is relieving to know.


text:
How are staking rewards stored?
In another question Andrew Westberg mentions that staking rewards are not stored as UTxOs to save space on the blockchain.
My question is: how exactly are those rewards associated with one's stake address? How can the blockchain store something that is not a UTxO and how does this save space?

Cardano is using what we call a chimeric ledger, which means it uses both account (similar to Ethereum) and UTxO (similar to Bitcoin) style accounting systems.
This enables the ledger to take advantages of the UTxO system but at the same time be storage efficient where it comes to specific aspects of the ledger, such as rewards.
I highly recommend a video of Sebastien going thought the paper in question to learn more.


text:
Detailed Minting policy documentation?
I found several Articles which deal with Minting Policy's for native tokens as:

https://cardano-ledger.readthedocs.io/en/latest/explanations/policies.html#minting-policy
https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md
https://docs.cardano.org/en/latest/native-tokens/getting-started-with-native-tokens.html#token-minting-policies

But none of them has a detailed desciption of syntax and functions provided in smartcontracts as of today (mary era).
Any hints are welcome.

You were almost there, the token policy scripts are actually the multisig/nativescripts. As you know token policy's are not turing complete contracts, for that you should be looking at Plutus. Here's the documentation regarding the NativeScripts as scripts to use as token policy with all syntax and features.
https://docs.cardano.org/projects/cardano-node/en/latest/reference/simple-scripts.html

thnx Ashish that was the pointer I was looking for.

The link doesn't work anymore. Here's the archived page: https://web.archive.org/web/20210601112403/https://docs.cardano.org/projects/cardano-node/en/latest/reference/simple-scripts.html

Whoever decided to change the above URL and dumb-down the whole website and make it flashy is a horrible person


text:
Will there ever be a fiat on-off ramp in the official wallets?
Will we ever have to and from fiat conversion available in the wallet? This would go a very long way in adopting and using Cardano. Currently, using exchanges is a rip-off in fees and  a headache in KYC-AML rules, plus maximum daily/weekly withdrawal limits are the worst.
If we could easily convert ADA to/from USD and EUR, that would be a game changer for many people.
I suppose second best thing would be a trusted, high liquidity DEX that offers fiat on/off ramps.

Please refer to this question: Will Daedalus have a Fiat payment gateway?
In short: There's no official information on the topic yet, but a DEX related solution might be implemented some time in the future.


text:
Is it safe to point cardano-wallet at Daedalus "wallets" directory?
I'm running an instance of cardano-wallet which is already pointed at my Daedalus node socket. Would it be safe/possible to point to the wallets directory of Deadalus via the --database argument?

I've tried a couple times now and it seems this is not possible. It does not corrupt Daedalus's database but throws errors instead.
Unexpected error following the chain:
user error (restoreBlocks: given chain isn't a valid continuation.
Wallet is at: [...] but the given chain continues starting from: [...])

As long as you have your recovery phrase backed up in a secure place, you can always restore your wallet in case the Daedolus directory gets corrupted. So there's no problem with using cardano-wallet with your Daedolus files.


text:
what is the ADA (Cardano crypto-currency) SDK?
I'am very new to the blockchain community and I have a new project that i'am starting to work on using the Cardano Blockchain and its crypto ADA.
I stumbeled upon the name "ADA SDK" and I tried to dig deeper and research it more but i can't find any clear information on what do you use it for exactly.
I know what is an SDK in general but what is an ADA SDK ?
Is it the development Kit you have to download to start working with ADA ? or what exactly ?
The few information that I found are that there an android/ios ada SDK that is used for a chatbot or something and I don't think it's the same thing i'm talking about or is it ?
I'm so sorry but I'am really confused is there anyone who could help me ? thank you !!

From my understanding, Cardano SDK is a set of libraries for different languages which should make it easier to integrate with Cardano. You can take a look here https://github.com/input-output-hk/adrestia


text:
What does it mean to "burn" a token?
I'm guessing it means remove the token from circulation, permanently. In a real-world example that would be akin to literally throwing cash into a fire? What are the technical details involved in the process?
Furthermore, how does this all work in token conversion?
Edit: will ask above as a separate question.

One way in which Tokens/ADA can be burned is by sending them to a contract which has a deadline for extracting them. Once the deadline is passed, the validation script will never be able to validate and thus burning them. It would be wise to make the deadline the current slot so that there would be no chance of Tokens/ADA being extracted before the deadline passed. This can be done as soon as smart contracts are available on the Cardano mainnet.
If you want to burn a token in the current state of the mainnet, there is also the option to send the tokens to a "burner-wallet", a wallet that nobody has access to (anymore). However, you can never be 100% sure that nobody has the private key to this wallet, so the first option would be better in most cases.

Ah, clever, I understand with the dead-end contract. Any thoughts on how this correlates with token conversion? I can't quite wrap my head around how, as if by magic, you convert ETH into ADA. The token converter demo appears to conjure ADA out of thin air. Or is there really a 3rd-party exchange that has the ADA reserves to issue?

I don't know much about token conversions :/ Maybe ask this as its own question?

Dig it. Thanks!

Can't you just send it to a standard address like the null address or something like that? If you choose an address randomly and someone has the key of this address, then cardano is not secure at all (because it is basically the same as the probability that you have the same public key as someone else). Or am I missing something?

I am not sure what a null address is so I cannot answer that :D I think that sending tokens to a standard address with no private key holder is just bad practice which adds up over time if that is the commonly used method.

Another way to burn is to send it to script which validator always returns an error like it is presented at Week 2 Plutus pioneer program https://plutus-pioneer-program.readthedocs.io/en/latest/week2.html#example-2-burn

One way to burn a token would be to send it to a script address where the validator always fails. One of the simplest validators in Plutus would look something like this...
  mkValidator :: Data -> Data -> Data -> ()
  mkValidator _ _ _ = error ()

Since any UTxO belonging to a script address can only be used as an input to another transaction if its validator passes, then no UTxO at an address with such a validator can ever be spent.
You could still see all UTxOs sitting "inside" the script, including which tokens or Ada they contained, but they would not be retrievable.

I have not reviewed the specification for Cardano private keys, but in many crypto-currencies a private key must have some specific characteristics, for example so many Bytes in size.
Because of the mechanisms used for generating addresses from private keys (usually at least one cryptographic hash function is used) even an invalid private key that does not have the right attributes (perhaps not containing enough Bytes) can be made to generate an apparently valid address.
This invalid private key to valid address cant be created in a standard wallet, but recreating address generation in some custom code, and just feeding it invalid private keys will give burn addresses.
Coins can be sent to a burn address, but because the private key is invalid, no valid signature can be created to spend the coins, and so they become impossible to move and are "burned".
An address can be proven to be a burn address by simply publishing the invalid private key with the address, and then anyone can validate the address is a genuine burn address.

I see. Makes a lot of sense. Thanks for providing a clear example.

In the world of Native Assets in Cardano, one can perform a negative mint procedure a.k.a. DESTROY on tokens as long as the Policy behind it is still open. This essentially takes it completely out of circulation. It’s like throwing an item into lava in Minecraft. This can all be done through the Cardano-CLI even in the absence of Smart Contracts on Cardano. Note that this process isn’t like what other networks do by simply locking tokens away in addresses and hope the private keys will never be found/used. I consider this to be a rather transparent and ultimate approach

If someone wants to achieve a cryptocurrency's deflationary effect – then he/she burns a token. This process reduces the overall number of tokens in circulation, therefore boosts the cryptocurrency's value. So if you wanna burn a token/crypto, just create a new wallet, send there some tokens/cryptos to burn, and then delete this wallet and its recovery phrase.
Or, if you wanna burn a token using smart contract, there will be a simple way to do it –  make a validator always evaluate to false, so script address' UTXOs will always be locked.
mkValidator :: () -> () -> ScriptContext -> Bool
mkValidator _ _ _ = False


text:
Create a Native token for voting & burn afterwards
I am looking to issue voting Tokens.
The basic idea is that I will send something like 100 tokens to 10 people. Then there will be three wallets that act as ballot box.
In order to incentivise the people to vote within a certain timeframe I wan’t to burn the tokens after a certain period of time.
Am I right that I can do so by burning the tokens as token issuer?
And when burning, what will happen to the ADA used during token minting?

First of all, there might be better ways to build a voting system than to use native assets as "votes" in the future when we have smart contracts on Cardano. But of course your proposal would be possible.
Once the tokens have left your wallet, you won't be able to burn them. That can only be done by the owners of the tokens. There is this question where you can find more info on how token burning works: What does it mean to "burn" a token?
The ADA used to mint the tokens is used to "pay" for the minting process. This has nothing to do with the burning of tokens.

OK thnx.
I am aware that this way of voting is suboptimal, but I'am looking for a voting mechanism which works prior to smart contracts release.


text:
Using Plutus PAB for development instead of Playground
trying to migrate away from the playground and seems like PAB is the way to go. The plutus starter repository orignally seems to be the best place to start but it seems to be outdated (i.e. still using ValidatorCtx instead of ScriptCtx). So Im looking the plutus-pab in the main plutus repo. I ran the all-servers script and tried activating the in built plutus game contract using the HTTP api of the webserver but encounted an error in the json object stating that the caID shld be a binary instead of a string. How do I overcome this? Thanks.

Hi Shannon, could you please provide some more information? Links to the repositories you're using, the exact steps you did and the full error message would be helpful.

caID is part of ContractActivationArgs - are you sure the error message is telling you that this should be a binary (and not maybe a ByteString - which is different than String)?

Added a screenshot of what I see with the latest code as of now. I remembered the error being a binary but now it shows an object; I'll just take it that I remembered wrongly. Where do I find the caID for the built-in contracts? Thanks.


text:
When actually a validator is deployed to the blockchain?
I'm re-watching the Plutus Pioneer Program and in the video #2 I don't exactly get it here: https://youtu.be/E5KRk5y9KjQ?t=1782
There's the same contract code used by Wallet1 and Wallet2. Each of them submits a transaction calling give() and both of them land in the same block. Both script hashes are identical, well, because the validators are so. (And I understand that script hash is actually a hash of the deployed validator).
How is/are the validator deployed to the blockchain in that scenario?

Does each of the wallets deploy their own copy?
If so, wouldn't the hash clash become a problem?
If both deploy a copy, when Wallet3 refers to the same contract, by calling grab(), which of the validators is being run? Both?

The validator script sits inside the EUTxO. Its job is to permit or deny the consumption of the EUTxO.
So, in the example from the lecture, when wallet1 gives, it actually produces an EUTxO that has our validator script inside it. When wallet2 gives, it produces another EUTxO which has the same validator script inside it.
When wallet3 wants to grab, it finds those two EUTxOs and wants to consume them. When wallet3 wants to consume the first EUTxO, the validator inside
that EUTxO runs and permits its consumption. When wallet3 wants to consume the second EUTxO, the validator inside that EUTxO runs and permits its consumption. Now that wallet3 is allowed to consume those two EUTxOs, it consumes them and produces its own output.


text:
Daedalus wallet not syncing and cardano node not responding
I just updated the daedalus wallets to the 4.1.0 version. When I launch it, it says Verifying the blockchain (50%), once it completes it resets and starts from 0% again. Also, it says: Cardano is not responding and Cardano node is not syncing. I attached a screenshot.
I already tried restarting my computer. Does anyone know another solution? Do I have to uninstall and download again?
I've been using daedalus wallet for a while, and this is the first time I have an issue.

i have the same problem.
Did u solve it? U write u letting it run, for how long?
Thank you very much!

This kind of problem seems to be popping up sporadically and without apparent reason. Usually it fixes itself – just keep the node running for several hours. Also restarting the router sometimes helps.
Check here for reference:
https://iohk.zendesk.com/hc/en-us/articles/360010522913--Connecting-to-Network-message

I had the same issue once where it was stuck on 99.9% for hours on end. I would first suggest simply restarting the Daedalus node to see if it solves it. In my case, that did not work and it got stuck at the same point every time.
What did help was nuking the local chain database, thereby triggering a full re-sync (will take a couple of hours):

Turn Daedalus on
Go to Help -> Daedalus Diagnostics
Find the Daedalus State Directory under Core Info -> open that path
Shut down Daedalus
Inside the directory, you should see a chain subdirectory, enter it
Inside the chain directory, you should see a directory named immutable
Delete everything inside the immutable directory (around 10GB at the moment)
Re-launch Daedalus and wait for the full re-sync

EDIT: This approach will not necessarily work for you - check the comment below for more options.
This worked for me.

This answer didn't fix my problem, but it got me on the right track. Here's what I did: instead of deleting everything inside immutable, I deleted just the latest 2 months of files. In addition, I had to delete everything inside the volatile and ledger folders. Once I did that, my daedalus client finally got unstuck.

@crypdick cool, I'll update the answer for folks to check out your comment as well if they run into the same issue! Thanks for the update.

There was an issue in cardano-node 1.26.1 at least that caused an issue in startup time if the last shutdown did not complete correctly:
https://github.com/input-output-hk/cardano-node/issues/2564
I have generally found leaving the cardano-node alone to do its thing, resolves most startup issues.

Yes, I ended up letting it run for a long time, and that solved the issue.

Try restarting the node from the wallet Help -> Daedalus Diagnostics -> Restart Cardano Node. Then leave it there for awhile and check on it again in a few hours. The connections are still centralized and you could just have to wait in line essentially for a bit.
As a side note this should be much better in the future with the decentralized P2P that will be in test net soon.


text:
Plutus Pioneer Program - Lecture #1- Cabal Build error
I started following the lectures on youtube and got this error when I try to build the English Auction
Warning: The build command is a part of the legacy v1 style of cabal usage.
Please switch to using either the new project style and the new-build command
or the legacy v1-build alias as new-style projects will become the default in
the next version of cabal-install. Please file a bug if you cannot replicate a
working v1- use case with the new-style commands.
For more information, see: https://wiki.haskell.org/Cabal/NewBuild
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
[__0] trying: plutus-pioneer-program-week01-0.1.0.0 (user goal)
[__1] next goal: base (dependency of plutus-pioneer-program-week01)
[__1] rejecting: base-4.12.0.0/installed-4.1... (conflict:
plutus-pioneer-program-week01 => base^>=4.14.1.0)
[__1] fail (backjumping, conflict set: base, plutus-pioneer-program-week01)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: plutus-pioneer-program-week01, base
Trying configure anyway.
Configuring plutus-pioneer-program-week01-0.1.0.0...
cabal: Encountered missing dependencies:
aeson -any,
base >=4.14.1.0 && <4.15,
playground-common -any,
plutus-contract -any,
plutus-ledger -any,
plutus-tx -any,
plutus-tx-plugin -any
tried to run nix-shell at the top-level directory of the plutus-repository but I couldn't. Got
Error: getting status of '/home/test/plutus/plutus-pioneer-program/default.nix': No such file or directory

I had a similar issue and solved it by running nix-shell in the plutus library, then navigating to the plutus-pioneer/code/week01 and running cabal update. I hope this helps!

I could run cabal update and cabal build. When I try to execute cabal run an error message saying that 'Cannot run the target '' which refers to the package plutus-pioneer-program-week01-0.1.0.0 because it does not contain any executables.' shows.

Ahh, I think you should be using cabal repl in the week01 folder. **note the lowercase w in week01. This folder should contain these files: cabal.project  hie.yaml  LICENSE  plutus-pioneer-program-week01.cabal  src

Hello Isaac, could you please tell me how can i get to the plutus library?

You can us "cd /nameofdirectory" in the terminal on linux. I would familiarize yourself with terminal commands and Vim :)

I had the similar problem, this recipe works for me:
Run nix-shell inside plutus project and move to plutus-pioneer-program/code/week01 directory from nix shell, then start cabal build.
UPD:
plutus-pioneer-program repo contains README with steps how to run plutus-playground, one of steps is to clone Plutus repo and to checkout it to the specific commit. Inside that Plutus directory you can run nix-shell and then go to pioneer directory.

How can i do that? when i try to run nix-shell  i get Error: getting status of '/home/test/plutus/plutus-pioneer-program/default.nix': No such file or directory ,  where is the plutus project? is it a file or a location? sry if it seems tooo silly !!!

Plutus repo it is mentioned in the Week #1 homework in the plutus-pioneer-program repo.

Thank you , so I must install this library using nix, as well as cabal before running cabal - build ?

Not exactly, you should just clone plutus repo, and every time when you want to run some code from pioneer program you should firstly run nix shell from plutus and go to desired project in that shell to run cabal commands.

I am new to nix, but my understanding is as follows:
Both the plutus and plutus-pioneer-program repos need to be extracted on disk. Check out the plutus commit of the coding week you want to work on (in cabal.project in root of week code folder).
Start all the nix-shell instances you require in the root of the plutus repository. I start 3: one each for playground server and client, and programming in Hashkell (cabal repl). For each shell you have to cd to the correct folder. This way all components are in sync.
Don't forget to set up the cache at the start.
I am really impressed how nix make this so easy.


text:
Why does my test of Plutus contract crash?
I tried to equip the EnglishAuction.hs contract from Plutus Pioneer Program week 01 with test routine designed according to what Lars presented in later lectures:
doTest :: IO()
doTest = runEmulatorTraceIO $ do
    let startParams = StartParams{spDeadline = 10, spMinBid = 5, spCurrency = "Token", spToken = myTokenName}
    h1 <- activateContractWallet (Wallet 1) endpoints
--    h2 <- activateContractWallet (Wallet 2) endpoints
    callEndpoint @"start" h1 startParams
    void $ Emulator.waitNSlots 1

Then, however, I get a strange error which is caused by a line calling activateContractWallet. The message is mysterious and to me it carries no information:
Prelude Week01.EnglishAuction> Week01.EnglishAuction.doTest
*** Exception: not a hexit: 'T'
CallStack (from HasCallStack):
  error, called at src/Data/Either/Extras.hs:6:34 in plutus-ledger-api-0.1.0.0-307e91a82e48dc52f16a2602ae259f767995000a894e765e9c2a3c51ae53abfc:Data.Either.Extras

The full source of my modifications is here: https://gist.github.com/emesik/82f185dad3ecec6ec811530db4c51ff1
edit: I see the error is caused by "Token" used as spCurrency. Haskell expects hexadecimal there, perhaps the ID of minting policy? How can I fix it?

Plutus is still in development. So while the Plutus Pioneer Program is taking place, things were expected to break. I think the first three weeks or so will not run with the updated Plutus Playground. There may be community contributions that modify the source to work with the current Plutus implementation.

Currency symbols can't be arbitrary byte strings, they must consist of hexadecimal digits. So you can't use Token, and the error message is complaining about the T. Use something like ff instead.


text:
Mallet IELE Compiler crashes without Uncaught Error
I was able to get mallet running with the command ./mallet iele -d .
I created a simple contract that works in Remix but when I try to compile the contract using iele I get a Uncaught 'Compiler error: 0\nundefined'
The contract below
pragma solidity ^0.4.0;

contract Inbox {

    string public message;

    function Inbox(string initialMessage) public {
        message = initialMessage;
    }

    function setMessage(string newMessage) public returns(string) {
        message = newMessage;
    }

}

Just a guess: Your setMessage function should return a string but it doesn't return anything.

I tried to get it running  as well, but I IELE its still in R&D.
I recommend following this tutorial instead.
https://youtu.be/p3ee19mJUOA


text:
What does two consecutive apostrophes mean in Haskell and Plutus?
I have noticed the frequent appearance of two consecutive apostrophes in Haskell code.
Like this:
newtype Date = Date Integer
data EndDate = Fixed Integer | Never
unstableMakeIsData ''Date
unstableMakeIsData ''EndDate

What does '' mean in haskell?

The apostrophe(s) in Haskell (and thus Plutus) are part of the name; they do not hold any specific meaning.
Haskell as a functional programming language borrows from mathematical notation. An apostrophe on a variable name conveys that it is somewhat related to another variable (without or with more apostrophes).
Imagine a simple function that adds three values. You could write these several ways.
addThreeNumbers a b c = a + b + c
addThreeNumbers' a b c = b + c + a
addThreeNumbers'' a b c = b + a + c
addThreeNumbers''' a b c = c + a + b

and so on. The result will always be the same.

The apostrophes in your example are, however, not of the same type as the prefix data types. This is an indicator that template haskell is being used.

but in my case, unstableMakeIsData is a function name and ''Date is not defined before. The apostrophe(s) is a prefix not suffix, I think It might be different.

I found your example in this commit: https://github.com/input-output-hk/plutus/commit/01f14933a8fc35e02aaec4cedfeac6dc5396b382 -- take a look at the Instances.hs

I apologize for the confusion. The apostrophes in front of the type hint at template haskell

Thank you a lot!


text:
Staking Key a Privacy risk?
So I just realized today that the staking key for a wallet is persistent, namely that every public key of that wallet will generate the same staking key. This appears to undercut the technique to use different public keys every transaction, since they can be verified to be connected through their staking key. Can staking keys be generated on the curve like public addresses are to preserve privacy?

Can staking keys be generated on the curve like public addresses are
to preserve privacy?

While it is possible to create enterprise addresses or additional base addresses with new staking keys using cardano-cli, the official wallets at present will re-use the same staking key for all addresses of the same wallet if you choose to stake.
Instructions on how you can create enterprise addresses or base addresses with different staking keys can be found on the Lovelace Academy documentation on the basics of keys and addresses.
Note: Using multiple staking keys to stake will incur a deposit fee of 2 ADA each (at time of writing)

The staking key is part of the address, so creating a new wallet and not staking it will not help. You can use enterprise addresses via CLI ehich have no staking key or you should be able to use old Byron type addresses.

You're right @Xiaofei, I assumed incorrectly that the wallets did not append staking keys unless the users chose to stake but it does make sense all existing ADA should be staked. Removing option a)! :)


text:
Writing basic validator scripts
I need someone to explain to me line by line. The code is from plutu tutorials. https://docs.cardano.org/projects/plutus/en/latest/plutus/tutorials/basic-validators.html
All the code in that page I can understand. Except the last one. I don't really get it. the code that I don't understand:
dateInstance :: ScriptInstance DateValidator
dateInstance = validator @DateValidator
    -- The first argument is the compiled validator.
    $$(compile [|| validateDateTyped ||])
    -- The second argument is a compiled wrapper.
    -- Unfortunately we can't just inline wrapValidator here for technical reasons.
    $$(compile [|| wrap ||])
    where
        wrap = wrapValidator

dateValidatorHash :: ValidatorHash
dateValidatorHash = scriptHash dateInstance

dateValidator :: Validator
dateValidator = validatorScript dateInstance

Tbh I'm not sure that this example is up to date (from my understanding we don't need to compute ValidatorHash anymore). I would suggest you check Plutus Pioneer lectures on Youtube and plutus repository with example on GitHub (https://github.com/input-output-hk/plutus/tree/master/plutus-use-cases/src/Plutus/Contracts)

Although there may have been changes, this remains a valid question.
The code shown in the question is the boilerplate code that accompanies a validator implementation for on-chain execution. A simple validator implementation can be seen below. It is the recent 42 redeemer validator code of Pioneer (before switch from Data to BuildinData).
-- This is the validator implementation
-- It must be inlinable so it can be compiled into Plutus code
{-# INLINABLE mkValidator #-}
mkValidator :: Data -> Data -> Data -> ()
mkValidator _ r _
    | r == I 42 = ()
    | otherwise = traceError "wrong redeemer"

-- boilerplate: compiles validator to Plutus code
validator :: Validator
validator = mkValidatorScript $$(PlutusTx.compile [|| mkValidator ||])

-- boilerplate: get the hash of the validator script
valHash :: Ledger.ValidatorHash
valHash = Scripts.validatorHash validator

-- boilerplate: get the script address of the validator
scrAddress :: Ledger.Address
scrAddress = scriptAddress validator

The first code block is the validator implementation in Haskell, here named mkValidator.
The actual question refers to the next three code blocks marked as boilerplate.
validator inlines the mkValidator implementation and compiles it to Plutus code. This is necessary so the validator can be executed on-chain.
valHash and scrAddress are auxiliary functions that return hash and address of the the validator script.
One can see them used in the off-chain code to construct the transactions.
The reason for this roundabout way of implementing the validator is to enable code sharing between on-chain and off-chain executed code.
More complex validator implementations will result in a more complex Plutus code compiler code block, but the principle remains the same.


text:
plutus pioneer week01 src code explain
I'm a little confused about the following code（from EnglishAuction.hs）:
auctionInstance :: Scripts.ScriptInstance Auctioning
auctionInstance = Scripts.validator @Auctioning
    $$(PlutusTx.compile [|| mkAuctionValidator ||])
    $$(PlutusTx.compile [|| wrap ||])
  where
    wrap = Scripts.wrapValidator @AuctionDatum @AuctionAction

What does "@" means? and what does Scripts.validator do? Why did it use two $$ instead of one?

If you want to learn more about Haskell (which Plutus is based on) you can have a look here: http://learnyouahaskell.com/

I have already learned Haskell from learnyouahaskell.com. But it doesn't include template haskell.

This is part of Template Haskell. It is the way to have Haskell compiled at runtime basically.
This link may help https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_guide/template-haskell.html
$$ is considered a typed expression splice.  It also talks about [|| ... ||] which is a typed expression quotation.

The purpose of the code is to produce compiled Plutus-Core code which can be used as a validator.  It is (more-or-less) boilerplate, so nearly the same for every program.
@ means we are giving types, not values
$$ is completely different to $ and it is used here to "splice" code into the program i.e. it inserts the compiled code 'syntax' into the program at this point.
See docs here : https://plutus.readthedocs.io/en/latest/plutus/tutorials/plutus-tx.html


text:
Can I safely reinstall Daedalus wallet when hardware wallet already exists?
I have a hardware wallet. I have decided to reinstall the Daedalus wallet and link it to my hardware wallet. Does anyone know of a tutorial?
When I reinstall the Daedalus wallet and connect my hardware wallet to my computer, will Daedalus recognize that my hardware wallet had already been set up?

Yes, you can re-install Daedalus and re-connect your hardware wallet. As long as you have your seed phrase for the hardware wallet, all is good.

The "and/or" might be misleading. You only and always need the hardware wallet recovery seed and your chosen passphrase(s) (if you're using the passphrase feature). Those are the fails safes in case you wipe/lose your hardware wallet or forget the PIN.
Also, you can use the same hardware wallet to recover your Cardano wallets on multiple computers and differnt software wallet programs like Daedalus and Yoroi in parallel.

Thanks. edited the answer.


text:
When are the snapshots for the active stake in an epoch taken?
A stake pool always has an "active stake" and a "live stake". "Active stake" refers to the amount of ADA that is used for rewards calculation in the current epoch. "Live stake" is all ADA that is delegated to the pool, also counting ADA that was delegated/undelegated after the "active stake" snapshot for the current epoch.
At which point is the snapshot for the "active stake" taken? Is it right when the new epoch starts? And will this happen at the exact same moment for all stake pools?

I suggest you break this into two separate questions:  "When are staking snapshots performed?" and "How are staking snapshots performed?"

@gRebel I removed the "how" part from the question.

Staking snapshots are taken at the beginning of each epoch and a stakepool's active stake is whatever was delegated to it at the beginning of the prior epoch or during the epoch before that.
Any new or changed stakepool delegations take effect at the beginning of the next (1st) epoch after they are made (they become part of a stakepool's live stake).
In the (2nd) epoch after that the delegation is used to determine the stakepool's probability of rewards and is part of the stakepool's active stake.
In the next (3rd) epoch since delegation rewards are calculated based on the number of times the pool became a slot leader.
In the last (4th) epoch rewards are distributed to the delegator.
In summary

Delegation changed
Snapshot taken
Slot leaders chosen based on delegation
Rewards calculated
Rewards distributed

"Cardano Staking: Practical Information" provides a more detailed explanation

Great article you linked, thanks!

That linked article[1] is really clear!
[1] https://cardanians-io.medium.com/cardano-staking-practical-information-3c86cbc73bd4


text:
How is the active stake of a stake pool calculated?
This question is related to my previous question: When are the snapshots for the active stake in an epoch taken?
The active stake of a pool is used to calculate the rewards. What kind of system calculates the active stake of a stake pool? Is this done by the Cardano nodes or by the stake pools themselves or some other part of the Cardano ecosystem?

Data captured by the snapshot is stored on-chain as a part of the ledger state, so all fully synchronized cardano-node instances have access to it. So, for example, when you run the cardano-cli query stake-distribution --mainnet --out-file stakeDist.out command the cardano-cli queries and outputs the current active stake data for each pool.

I think this answer is (partly) wrong: ledger state is not stored on-chain and nor are the stake snapshots that are part of it. Ledger state is kept in memory by the nodes and it is a result of folding (reducing) the blockchain.

Just a minor correction. These snapshots are part of ledger state and are not actually stored on the blockchain (They are too big. There is a new snapshot every 5 days and over 1 million stake addresses.). The are part of ledger state that can be recreated by replaying the block chain from genesis.

From my understanding, the active stake is calculated as a sum of all coins that were delegated to a particular pool. You can take a look here.

So is this part of the nodes? Or is this shelly-spec-ledger part of some other system running in parallel? And if it's part of the nodes, which nodes are running this code? And who initiates the transactions/reward payouts?


text:
Where can I find Cardano Dapp code and demo examples?
I am checking Cardano documentation to develop Cardano POC for my Dapp, found some good examples to create contracts using online application i.e. Plutus (https://playground.plutus.iohkdev.io/).
However, there are no examples given to create end-to-end applications like those provided in Ethereum documentation i.e. Ethereum has provided web3 applications examples to create Dapps using Web3 / React/ Solidity contracts connecting the dapp to Ethereum testnet/mainnet - many examples are available on internet and ethereum documentation website for reference.
I have not found demo examples of how Dapps can be built using Cardano.
Please can someone share some code and demo examples or links to them?

You can find a number of dApps demo examples in the Plutus Pioneer Program repository.

I have recently finished transcribing lecture 6 from the Plutus Pioneer Program which runs through the process of creating a swap dApp that uses an oracle for exchange rate data. It consists of two clients - one for the oracle provider, and one for participants who want to offer swaps and accept swaps. The week 6 lecture can be seen here.

Well done. Your explanations are spot on for a topic most people are largely in the dark about.

You can find a lot of examples in the official Plutus repository https://github.com/input-output-hk/plutus/tree/master/plutus-use-cases/src/Plutus/Contracts


text:
What is the difference between an active, relay and passive stake pool node?
I have seen three types of stake pool nodes mentioned.

Active
Relay
Passive

How do they differ in purpose and function?

The term active node is often used to describe a node with the purpose of minting new blocks.

The term relay node is used to describe a node that is run by the stake pool operator to relay the newly minted blocks from their block producer (active node) to the rest of the Cardano network. See What are relay nodes?

A passive node is a node within the Cardano network that is receiving blocks and transactions from their peers (and in the future, will share these with its peers). A good example of an passive node is the Daedalus full node wallet.

Note that all type of nodes connected to the Cardano network can be used to submit a valid transaction to the network.


text:
How does smCheck work?
In the PPP lecture 7 state machines are introduced. They are used to make the guessing game more concise.
One of the situations is where the first player has won and needs to prove their guess by providing the nonce they originally used to hash the guess. A function was written for this named check
check :: ByteString -> ByteString -> GameDatum -> GameRedeemer -> ScriptContext -> Bool
check bsZero' bsOne' (GameDatum bs (Just c)) (Reveal nonce) _ =
    sha2_256 (nonce `concatenate` if c == Zero then bsZero' else bsOne') == bs
check _       _      _                       _              _ = True

This function is then assigned in the StateMachine definition as the smCheck.
Is this function then used as a sort of predicate on every attempted transition to a new state?
Additionally, is this an example of pattern matching to the specific case where the transaction includes a redeemer and nonce?
Thanks!

Is this function then used as a sort of predicate on every attempted
transition to a new state?

Yes, this is why we include the following line
check _ _ _ _ _ = True

You can find docs for smCheck here https://playground.plutus.iohkdev.io/tutorial/haddock/plutus-contract/html/Language-Plutus-Contract-StateMachine-OnChain.html#v:smCheck

Additionally, is this an example of pattern matching to the specific case where the transaction includes a redeemer and nonce?

Yes, the logic will be run only if both players made their moves (1st player put hashed version of his move, 2nd player Zero or One) and if the first player wants to prove that he can withdraw the money.


text:
Does the rewards on the pledge stake address count toward the stake pool pledge?
The pledge is just a delegation to the stake pool signed with the owner key. My question about the pledge amount, are the stake address' rewards counting towards the stake pool pledge as well or just the UTxO funds on their associated addresses?

Normally, (UTxO + stake rewards) constitute the total stake. So the rewards are part of the pledge. One confirmation would be nice !

it should count, but can someone confirm that?


text:
What's better for cloud Virtual Private Server stake pool operations, persistent disk or local ssd?
I'm comparing various cloud server providers and I'm trying to understand the best storage options to run a stake pool in the cloud.
Is a persistent disk better than an attached SSD? A persistent disk can be replicated across zones and the data on it can be saved when the VM is deleted. I assume it has higher latency.
The locally attached SSD is obviously faster but it is deleted if the VM is deleted.

Might help to expand VPS in the text or remove it from the title.  It's not a common abbreviation.

Apparently I haven’t been around long enough to edit my own questions. Lol.

The members with more reputation get prompted to edit first posts and a number of other categories.  Welcome aboard, I hope I did your intent justice.  There are not too many places you get free proof-readers and editors.   :-)

You should run some tests to check throughput for both of them.
However, from my experience of running a Monero node I can tell you that persistent storage generated a lot of problems with responsiveness and overall uptime. Switching to SSD removed most of them. And keep in mind that Monero is a PoW coin with 2 minute block time. There are no time-critical operations even close to Cardano's getting a slot or missing it.
I'd say definitely SSD, but do your tests to be sure.

Do you mean attached SSD or persistence storage SSD? I wonder if it matters which cloud provider is used. I heard anecdotally that google cloud compute was much faster than digital ocean for storage access.

There are multiple factors that I would consider important here:

Cost: What's the difference in cost? If one is significantly less expensive, this can be a big factor if you're an SPO.
Ability to replicate: You should have a backup of all important keys somewhere else. So if you delete the VM or the disk, it should be no problem to create a new node and restore your keys from the backup. Creating a new node can take some time though, so replicating a disk might be useful. However, this could also be solved by using containerization (e.g. Docker).
Speed: The case where you delete a VM and then want to use the same disk on a new VM is probably quite rare, so this would speak for the attached SSD. Besides that, an SSD is definitely faster than a persistent disk but you'd have to test if you run into problems with the persistent disk speed.

In the end it comes down to your preference, both options work.

SSD all the way.
The reason for this is simple: a stake pool needs to be able to perform creating a block fast. That's it. Storing and replicating data is of little concern since its a public blockchain-it can always be re-synced. I realize you wouldn't want to wait for a node to sync from scratch if you spin up a new one, but there's other ways to speed that up. Also, there should be nothing sensitive (e.g., cold keys and spending keys) or critical (e.g., the only copy of your run script). In short, a node doesn't host critical data, it makes blocks.


text:
Can immutable data on Daedalus be backed up and restored for quicker wallet installation/update?
How about just backup and restore chain/immutable directory for Daedalus installation or updates, even across machines. Can that avoid the wallet downloading it again after the installation?
Also, are there other directories with just immutable data that can be handled so?
PS: The dir is as seen in Windows machine.

Yes.
The biggest time requirement with a fresh install of Daedalus is syncing the node from scratch since Daedalus run a full cardano-node under the hood. You can install Daedalus, let it start, quit, copy over the node database, and then let it run again. Now, if the database was made with an older version, the node may have to re-run through the whole thing but then you are CPU bound and not network bound (download speed) so it will probably still be faster depending on hardware and network specs.

If you just update Daedalus, you don't need to re-download the full blockchain.
I haven't tested copy pasting the data from one Daedalus installation to another, but I'd expect that this should work.
In case you wonder why it takes long to initialize the blockchain after the latest 4.1.0 update:

After upgrading, you will need to wait at least 30 minutes for Daedalus to start. This is due to changes in the block storage mechanism which requires a full verification of the locally-stored copy of the Cardano blockchain.

For most updates, this should not be the necessary and you can just use the already downloaded blockchain data.
Source: https://iohk.zendesk.com/hc/en-us/articles/900006759746-Daedalus-4-1-0-release-notes


text:
How is a slot leader actually selected to make a block?
As far as I can tell, once some blockchain data is fed into a hash, this creates an epoch nonce that is used to define the slot leaders in that epoch.
How is the nonce used to select slot leaders, and what is slot leadership evaluated against to deliver a block on average every 20 slots?  Why can some slot leaders create a block, and why cant others?
Are inputs like transaction hashes part of the block proposal and acceptance process?  Is there some kind of difficulty/target like in regular PoS?

1.) epoch nonce
2.) pool's vrf key
3.) pool's percentage of overall staked ada
4.) active slots coefficient
All four of these determine if a pool is allowed to mint a block in a given slot (happens once per-second on mainnet). The activeSlotsCoefficient protocol parameter is what determines that we make on average 1 block every 20 seconds. Sometimes more, sometimes less, but on average, 1 every 20 seconds.
See my video about this topic to learn more: https://youtu.be/M3Xq1qz3ljU

Thanks, it would be best if the answer was written here, what is evaluated against what, is there a hash with a number of leading zeros like classic PoS?


text:
Extract the bech32 stake address from a shelly address in javascript
I am looking to get the bech32 stake address from a bech32 shelley address. I think I have to decode the shelley address, take the stake address part and encode it again.
I looked here: https://github.com/cardano-foundation/CIPs/blob/master/CIP-0019/CIP-0019.md#shelley-addresses
But I did not find enough details to do this. Can anyone give me more exact information?
I am using the javascript bech32 library: https://www.npmjs.com/package/bech32

Did you manage to solve this problem? I'm trying to extract the stake address from shelley address using java. any tips would be appreciated tks

Please comment in the comment area only

I do not think it is possible to achive this in plain bech32, you need to convert it to hex and than back to bech32 to get retrieve the bech32 stake address.
First you decode the bech32 shelley address
For example converting the address addr1qxdvcswn0exwc2vjfr6u6f6qndfhmk94xjrt5tztpelyk4yg83zn9d4vrrtzs98lcl5u5q6mv7ngmg829xxvy3g5ydls7c76wu
gives us
019acc41d37e4cec299248f5cd27409b537dd8b53486ba2c4b0e7e4b54883c4532b6ac18d62814ffc7e9ca035b67a68da0ea298cc24514237f
Now, the Stake part of the address is the last 56 bytes of it, which gives us 883c4532b6ac18d62814ffc7e9ca035b67a68da0ea298cc24514237f.
Converting this to a bech32, we will retrieve the associated stake key stake1uxyrc3fjk6kp343gznlu06w2qddk0f5d5r4znrxzg52zxlclk0hlq.
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.

Thanks this is what I tried. The problem I had was that the bech32 library I am using restricts the length of the encoded data to 90 characters. I found the limit can be changed so I can decode the address now.

Just a side-note to Marek's answer, don't forget to append the prefix to the stake part!
In this case e1:
e1883c4532b6ac18d62814ffc7e9ca035b67a68da0ea298cc24514237f

See: Bech32 encoding stake address from Shelley address in JavaScript returning wrong value


text:
Time required to build node OSX/Cabal
I'm setting up a node on my mac. It's been stuck on "Building     network-3.1.2.1 (all, legacy fallback)" for a couple of hours now.
Is this normal, or have I got something wrong?
Thanks

Could you please give some more details on what you're doing? How did you set up your node (Daedalus, built from source, IOHK binaries...)? And maybe a screenshot would be helpful too.

Hi - Thanks for the response. I'm installing the node from source https://docs.cardano.org/projects/cardano-node/en/latest/getting-started/install.html - I'll add a screenshot to the original post. - Thanks again.

Building the node can take a while, but from my experience it shouldn't take hours even on a less powerful system. If you just want to start a node, you can also try to use the pre-built binaries from https://hydra.iohk.io/job/Cardano/cardano-node/cardano-node-macos/latest-finished

@eddex- Thanks again for your help. I've tried to use the prebuilt binary but it's returning the error bash: command ‘?? is not installed; please install it and try again"

I'd advise to head over to https://t.me/CardanoStakePoolWorkgroup on Telegram and ask for help there, maybe mention what sort of machine spec (e.g. how much memory you have) you're dealing with and what version of ghc / cabal you're trying to build the cardano-node code with. FYI Mac binaries for latest stable release can be found here: https://hydra.iohk.io/build/6263000/download/1/cardano-node-1.27.0-macos.tar.gz

Hi @HomerJ - Thanks for the response. I've tried building using the binary and am getting error: path '/var/folders/yy/bd1g3c_53z1_hf67hnb5j7n40000gn/T/' has a trailing slash

I strongly urge you to consider building using nix. I apologize if this wasn't the answer you were asking for, but it is probably the best solution for building the Cardano node.
I went through so many issues when trying to build from source it would make this issue seem trivial. Also, would like to note that by adding the binaries in step 2, I shaved 4hrs off the build time, and that is on a machine with a AMD 3900XT with 12 cores. Building without binaries on an average machine could take upwards of 12hrs.
https://docs.cardano.org/projects/cardano-node/en/latest/getting-started/building-the-node-using-nix.html
By using nix to build the Cardano node, you really only have 3 steps to follow:
1.
curl -L https://nixos.org/nix/install > install-nix.sh
chmod +x install nix.sh
./install-nix.sh

sudo mkdir -p /etc/nix
cat <<EOF | sudo tee /etc/nix/nix.conf
substituters = https://cache.nixos.org https://hydra.iohk.io
trusted-public-keys = iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
EOF

git clone https://github.com/input-output-hk/cardano-node
cd cardano-node
nix-build -A scripts.mainnet.node -o mainnet-node-local
./mainnet-node-local

Again, sorry if this wasn't the solution to build the cardano node using but I had nothing but problems using Cabal during the Plutus Pioneer Program.
Good luck!

Only to confirm that the first times I built cardano-node without the IOHK binary cache set for nix, it was taking more than 10 hours.

Thanks for coming back to me. Unfortunately still no joy. I got all the way through the installation using the method you stated above and still was unable to access the CLI. Am I being thick or is there something I'm missing here?

Could you please elaborate a little? Was nix successfully installed via step 1? If so, did you add the binaries in step 2 properly?

Something definitely wrong. I can build node from scratch (with a clean cabal cache) in about an hour (on Linux x86_64). Not sure how long this would take on an M1 Mac.
I also disagree with /u/intrinsic-values on the Nix issue. IMO, Nix solves some problems that I do not have and creates a bunch of new problems.


text:
NFT Image not Displaying in Pool.pm after using the 721 Metadata Standard
I am not seeing the image of the NFT I minted a couple of hours ago on pool.pm.  I used the standard recommended by Alessandro Konrad and Smaug in https://github.com/Berry-Pool/CIPs/blob/master/CIP-NFTMetadataStandard.md.
The gif in question is 15mb and it displays perfectly in IPFS using the Brave browser and in the Blockfrost IPFS web gateway.
Here is the metadata file:
{
  "721": {
    "4a2ba87b606a0aeb40916e906670a346c4b915840a755ddf109af709": {
    "cardanollama001": {
    "name": "Cardano Llama 001",
    "image": "ipfs://QmSahUdK9RTNDBGEq6xHWHZXRFwyQv8wBAtRgpxFCkNvqz",
    "description": "1bit aestethic, 256 colors, 90 hand-glitched frame loop",
    "size": "1000x666",
    "rarity": "225 of 250"
     }
    }
  }
}

Here is the link to the pool.pm link:
https://pool.pm/77a6f71a13e82794409d06c7486a59bb7a6af38e223b646c07e3262e.cardanollama001
I think I followed the standard to a tee, but I am stumped at this issue, and I can't figure out a solution.
Any help is very much appreciated!

I'm facing the same problem mate, do you found any solution rather than reducing the image size?

Hey @Anis If you give me the minting transaction hash I can try to help.

The metadata in your mint transaction looks good, it follows the standard correctly.
The only thing that kind of violates that standard is the size of your image (see chapter "Structure"):

The image and name property are marked as required. image should be an URI pointing to a resource with mime type image/* used as thumbnail or as actual link if the NFT is an image (ideally <= 1MB).

I assume that the creator of pool.pm has set a limit for the size of the images to prevent long loading times of the website. So your 15MB image is probably just too big. Unfortunately the source code of pool.pm is not available, so I can't check if my guess is correct.
To fix this, you can upload a smaller version as image and the full resolution version of your image as source. Or you can try to optimize the size of the existing image.

The type and src properties are optional. If type is defined, src will be an URI pointing to a resource of this mime type. If the mime type is image/*, src points to the same image in an higher resolution.

EDIT: Looking at the pool.pm page of your asset, it looks like the JSON metadata is not parsed correctly:

Usually, the properties should be shown like that:

This could be caused by the commas you used in the description property. So it's likely a bug on pool.pm. You could create an issue on their GitHub repo: https://github.com/SmaugPool/pool.pm/issues

Looking at the minting transaction, there seems to be a mismatch between the policy ID in the minting transaction and the metadata policy ID field:
https://cardanoscan.io/transaction/8be04d6a8e22c40f2b3970b0be893b5757d0f237efba997346cb145ccc60b7b3?tab=tokenmint
Minting policy ID: 77a6f71a13e82794409d06c7486a59bb7a6af38e223b646c07e3262e
Metadata policy ID: 4a2ba87b606a0aeb40916e906670a346c4b915840a755ddf109af709


text:
When I switch to another stake pool, do I need to withdraw my rewards first?
I'm using Yoroi and want to switch to another stake pool. I never withdrew my rewards from the current pool. What happens to my rewards when I switch pools? Do I need to withdraw them before I switch to another pool?

No, you do not need to withdraw rewards before moving stake pools.
Cardano wallets use two accounts: one for spending ADA and one for collecting rewards. While this may sound strange, it actually has many benefits (which I won't get into here). In order for earned rewards to be spent, they must be moved from the rewards account to the spending account (become an UTxO) which requires a transaction fee. Until the funds are needed it is fine for them to stay in the rewards account since they are still in your wallet (the pool doesn't have your funds) and they count towards your wallet balance and earn compound rewards. The main take away here is that the rewards are in your wallet and go with you wherever you stake your wallet.

Great explanation, thanks!

Your rewards are not on the pool, they are in an address owned by you. You don't need to withdraw them before redelegating.

I found a similar question on reddit & an answer references the shelley specification which could be interesting

Please be careful with "link only" answers. They are often subject to link decay, and can become dead links, in which case sch answers become useless. Even if you are sure that the link won't die, it is consider good practice on StackExchange sites to avoid link only answers, by providing an overview, a sum-up, or an slight overview of what the links are describing related to the OP question.


text:
What is meant by 'address is not spendable'?
The Cardano native token documentation explains how the the native tokens can be transacted and that a fee in ada is required for the transaction (min-ada-value). They continue with 'If the address is not spendable by the user that is sending the tokens, the ada sent alongside the tokens no longer belongs to the sender'. (link to documentation)
I don't fully understand this. Does it mean that when the 'min-ada-value' is not sufficient, the amount of ada that was included in the output does not belong to sender anymore? And are the custom tokens transferred to receiving party? Why is this transaction not 'canceled /rejected' when 'min-ada-value' is not sufficient?
Best regards,
Gijs

The text says "address is not spendable by the user sending the tokens" rather than "address is not spendable". This basically means an address you do not control.
My understanding is that this is just highlighting that the minimum ADA you need to include is going with the token to the recipient. If you're sending it to someone else (eg. not another of your own addresses) then you can no longer spend that ADA (eg., it went to the other address along with the token).
There's a box underneath that says:

Before transferring custom tokens, users may choose to use off-chain communication to negotiate who supplies the ada to cover the min-ada-value in the output made by the transferring transaction.

So in the case that I'm sending you some tokens, we might want to agree who is going to cover the ADA that I need to also send with them.

thanks for clearing that up!


text:
What's the difference between `unstableMakeIsData` and `makeIsDataIndexed`?
In the docs about validators a function named unstableMakeIsData is used, but has the following comment:
-- 'unstableMakeIsData' is a TemplateHaskell function that takes a type name and
-- generates an 'IsData' instance definition for it. It should work for most
-- types, including newtypes and sum types. For production usage use 'makeIsDataIndexed'
-- which ensures that the output is stable across time.
unstableMakeIsData ''Date

It seems inconvenient to have code that needs to be changed for production so I'm curious why this is required. For example, why not just use makeIsDataIndexed in development too? What benefit does unstableMakeIsData have?
I tried searching for both function names across the docs, but the only instances are in two different comments along these same lines.

The URL is now broken. 404

@Elrond_EGLDer I've updated it to what seems to be the same page hosted on another domain. Thanks!

If you take a look at the code you can see that makeIsDataIndexed takes 2 arguments (datatype and mapping) but unstableMakeIsData takes only 1 argument, so it's faster to use (that's why it's used in examples)

Usage example:
PlutusTx.makeIsDataIndexed ''Action [('Deposit,0),('Choice,1),('Notify,2)]

With unstableMakeIsData it would look like this:
PlutusTx.unstableMakeIsData ''Action

You can find more context in this commit as well. Note, that unsafeMakeIsData was later renamed to unstableMakeIsData.
The old `makeIsData` would encode/decode based on the ordering of the
constructors, which isn't stable. We *need* this to be stable across
time, since tools other than our Haskell programs might be producing
datums/redeemers (e.g. CBOR tools in other languages), so we really
don't want this to change unexpectedly.

So we avoid it everywhere. The exception is the usecases: they're just
examples so it's fine for them to be unstable.

Marlowe is probably the most annoying, but I think we *do* care about
the Marlowe types being stable!

Aha, perfect! I didn't see any examples using makeIsData so didn't realise it took this extra data. Makes sense now, thank you!

Great answer, I will award the bounty on Monday just in case somebody can come up with a better answer.  But a better answer seems unlikely. :-)

makeIsDataIndexed take 2 values and we use it when we are working with stable data and we don't them to be changing in the future so we index them explicitly to ensure.
Example: makeIsDataIndexed ''Bool [('False,0),('True,1)] so if we refer 1 we will get True and 0 False.
unstableMakeIsData only takes one value and this value won't be changing in the future which mean that there is no need to index it it is only one value.
unstableMakeIsData ''()
Hope it helps


text:
Smart contract datum encryption
Is there any way to make datum data only visible to a smart contract that owns the UTXO?
For example, lets say I wanted to make a guessing game. In this game, person A selects a number and creates an output at the smart contract with a prize (some amount of ADA) and a number in the datum of the UTXO. A second player B can then try to guess the number. For each guess, the player has to pay a certain amount of ADA to the contract. If he is right, all the ADA in the contract is given to him. If he is wrong, the ADA he provided is added to the prize pool. In order for the contract to determine if the guess is correct, it should evaluate the number provided by player B to the number stored in the datum UTXO, provided by player A.
However, datum data is public. It can be retrieved by everyone which means player B can look at the datum of the UTXO at the contract, see what number it holds and guarantee a win. Is there a way (in the smart contract) to enshure the number at the UTXO can only be evaluated under the pre-determined conditions of the smart contract code?
For example, could player A encrypt the number using the public key of the smart contract address, where the smart contract could decrypt the data using its private key on evaluation? This isn't possible since a smart contract doesn't have a private key, therefore, is there another way to achieve this?

Perhaps you could store a hash of the number instead of the number directly, then in the script check that the hash of the guess matches?

If its just a hash of a number, user B could check a lot of numbers and look for a corresponding hash. What could work is letting user A pick a nonce which is added to the number before hashing. After user B shows his guess user A could then provide the nonce to prove that the guess of user B was incorrect. This is the same as what is done in plutus pioneer lesson 7 but it adds extra transactions. Also, once player A reveals the nonce, the game has to stop since it again becomes possible to brute force a matching hash.

The game could continue if player A changes the hash to a new hash where the new hash is generated using the old hash and a new nonce. This enshures that the original number is still the same while preventing a brute force attack.

"If its just a hash of a number, user B could check a lot of numbers and look for a corresponding hash". Isn't this mostly true for the encryption too? The script could easily be run without needing to submit a real transaction to the blockchain, so it could be brute forced?

That depends on the "encryption". Hashing a number using sha will result in the same hash every time, the hash only changes if the content that is hashed changes. This way, if player A only hashes the number, player B could hash all the numbers that are supported by the 64? bit representation of the number and search for a matching hash. When you talk about encryption you probably mean public-key encryption which takes a know public key and uses it to encrypt some data. The data can then only be decrypted with the matching private key.

Right, but if all the code is available to the guesser (which I believe it has to be because every node has to run it to validate the transaction), they could do the same thing (try every int) though the encryption route too?

No, this is not possible right now without verifying just the hash.
Also, an attack vector that comes in mind is that someone will see the tx, validate it before it is included in the blockchain and make the block with the correct response first.

Though it is far from finished and a bit overkill for the guessing game (see the comments on the question), have a look at (1). For a more involved research paper, see (1).