text:
How secure is Ouroboros Proof of Stake compared to Bitcoin Proof of Work?
It is generally thought of that Proof of Work is more secure than competing consensus algorithms.
What security guarantees does using a Bitcoin PoW provide, and how does Ouroboros Praos compare? Will future versions of Ouroboros improve the security of the network?

There are several implementations of Ouroboros. Are you referring to any particular one? cardano docs.

I suppose I'm referring to the one in place today (Ouroboros Praos), but I'm interested in what future versions may contribute to this question. Question updated.

This IOHK blog post addresses security in the various versions of Ouroboros at a high level, but doesn't really answer the question asked

I think that's one of the subtle things that Ergo's PoW will be able to help since both share the same EUTxO model.

Initially, consensus protocols using Proof of Stake for sybil resistance faced several technical problems that needed to be addressed in order to provide sufficient security properties in a trustless environment. Among the most important we have:

The nothing at stake problem
Long range attacks
The need for a decentralised and robust source of randomness

The fact that "stake" is not tightly coupled with a physical resource (like energy in PoW) means that when a fork of the chain occurs, there is no direct incentive for a node to pick only one chain. With PoW, validating an additional chain has a significant energy cost for a node. In PoS, it's just some marginal disk, computation and bandwidth usage. Similarly, a malicious node can create an alternative chain from genesis and present it to the network as the legitimate chain, since there is no much cost involved in doing so. These two problems I just described correspond to the nothing at stake and the long range problems, respectively, and for a time were considered unsolvable.
Problem 3. was relatively easy to solve. Ouroboros classic introduced publicly verifiable secret sharing (PVSS), but it was not robust to adaptive attacks (see more details in the linked paper). Then Ouroboros Praos introduced a much more robust mechanism based on Verifiable Random Functions (VRF). In short, with VRFs the pieces of data required to compute the random beacon are computed locally by each node, and are not broadcasted to the network. This way, an attacker cannot know who the next block proposer will be.
The long range problem, also known as the bootstrapping problem, was perhaps one of the most difficult. In simple terms, it is about how to guarantee that a new node joining the network can actually reconstruct the whole blockchain history of the legitimate chain. PoW chains solve this issue with the simple and elegant longest chain rule, and that's probably one of the main reasons why they were considered superior in terms of security. As far as I know, Ouroboros Genesis was the first PoS-based protocol that solved this analytically.
Finally, every blockchain design needs to meet properties such as guaranteed finality and liveness. All the Ouroboros family of protocols provide analytically proven finality and liveness properties under certain theoretical conditions. It is important to make this distinction because the theoretical models might not always take into account all the possible attacks and disruptions that may happen in real world conditions. Also, research results from different blockchains are typically presented over a different set of theoretical assumptions, so it's important to understand them before comparing them.
That being said, recent versions of Ouroboros have been studied under a rather relaxed set of conditions, and according to the results presented in the papers, their security properties are comparable to those of Bitcoin.

I take it that problem 1 is no longer considered unsolvable, but has it actually been solved?  Does any of the Ouroboros variants you cited solve it?

@kjo yes, essentially solving 1. is equivalent to guaranteeing persistence/finality. All ouroboros protocols provide a solution for this, but under different system models.

good explanation but problems #1 and #2 solutions are not that explicit, however #3 you address explicitly.  I would recommend editing for a more concise and explicit answer.


text:
Unclear error during Plutus ScriptContext construction (force headList [])
I ran into an error while trying to autobalance a transaction body:
module Foo.Offchain where
import Plutus.V1.Ledger.Scripts (MintingPolicy)
import Plutus.V1.Ledger.Address (Address)

import Hydra.Cardano.API
import Hydra.Prelude
import Test.Hydra.Prelude
import Cardano.Api.UTxO qualified as UTxO

import Foo.Onchain(fooPolicy)

userAddress :: Address ShelleyAddr
...

txFoo = do
  let policyScript = fromPlutusScript @PlutusScriptV2
        $ getMintingPolicy fooPolicy
      policyId = PolicyId $ hashScript $ PlutusScript policyScript
      mintingWitness = BuildTxWith . Map.singleton policyId
        $ mkScriptWitness policyScript NoScriptDatumForMint (toScriptData ())
      mintingValue = valueFromList [(AssetId policyId "", 1)]
  ...
  pparams <- queryProtocolParameters networkId nodeSocket QueryTip
  systemStart <- querySystemStart networkId nodeSocket QueryTip
  eraHistory <- queryEraHistory networkId nodeSocket QueryTip
  stakePools <- queryStakePools networkId nodeSocket QueryTip
  utxoSet <- ...
  someUtxo <- ...
  someTxOut <- ...
  ...
  let unbalancedBody =
        TxBodyContent
          (withWitness <$> toList (UTxO.inputSet utxoSet))
          (TxInsCollateral [someUtxo])
          TxInsReferenceNone
          [someTxOut]
          TxTotalCollateralNone
          TxReturnCollateralNone
          (TxFeeExplicit 0)
          (TxValidityNoLowerBound, TxValidityNoUpperBound)
          TxMetadataNone
          TxAuxScriptsNone
          TxExtraKeyWitnessesNone
          (BuildTxWith $ Just pparams)
          TxWithdrawalsNone
          TxCertificatesNone
          TxUpdateProposalNone
          (TxMintValue mintingValue mintingWitness)
          TxScriptValidityNone
  let balancedBody = either (error . show) balancedTxBody $
        makeTransactionBodyAutoBalance
          BabbageEraInCardanoMode
          systemStart
          eraHistory
          pparams
          stakePools
          (UTxO.toApi utxoSet)
          preBody
          (ShelleyAddressInEra userAddress)
          Nothing

I got the following error:
TxBodyScriptExecutionError
  [ ( ScriptWitnessIndexMint 0
    , ScriptErrorEvaluationFailed
        (CekError An error has occurred:
           User error:
             The machine terminated because of an error, either from a built-in
             function or from an explicit use of 'error'.
           Caused by: (force headList [])
        )
        []
    )
  ]

The strange thing is that I still get this error even if I reduce fooPolicy
down to a trivial check that depends only the ScriptContext:
module Foo.Onchain where

import PlutusTx.Prelude
import Plutus.V1.Ledger.Api (BuiltinData(..), Data(..), MintingPolicy, ScriptContext, UnsafeFromData (unsafeFromBuiltinData), mkMintingPolicyScript)
import Plutus.V1.Ledger.Contexts (ScriptPurpose(..), scriptContextPurpose)
import PlutusTx qualified

{-# INLINEABLE fooPolicyValidator #-}
fooPolicyValidator :: BuiltinData -> BuiltinData -> ScriptContext -> Bool
fooPolicyValidator _ _ ctx =
  case scriptContextPurpose ctx of
    Minting _cSymbol ->
      traceIfTrue "Here" True
    _other ->
      traceIfTrue "There" True

fooPolicy :: MintingPolicy
fooPolicy =
  mkMintingPolicyScript $
    $$(PlutusTx.compile
      [||\y z -> checkBool
        (fooPolicyValidator
          (BuiltinData (I 0))
          (BuiltinData (I 0))
          (unsafeFromBuiltinData z)
        )||])

{-# INLINEABLE checkBool #-}
checkBool :: Bool -> ()
checkBool True = ()
checkBool False = traceError "Check error"

How can it be possible to get an on-chain script execution error when all that my on-chain code does is look at the script context?

The import is wrong, you likely were using Hydra.Cardano.Api from hydra-cardano-api package. Cardano.Hydra.API does not exist to my knowledge.

Yup, that was a typo

The problem was that I was mixing on-chain code written in Plutus V1 with off-chain code that expects Plutus V2. In particular, the off-chain code utilities in the hydra-cardano-api library assume that all scripts are written in Plutus V2.
The strange error manifests because:

The Plutus V1 on-chain code compiles and serializes just fine.
The Plutus V2 off-chain code is happy to put the Plutus V1 compiled on-chain code into a transaction if you tag it as Plutus V2 code (i.e. fromPlutusScript @PlutusScriptV2)
When the Cardano node tries to validate your transaction, it fails at constructing the ScriptContext because of a mismatch between Plutus V1 and V2.
Unfortunately, when ScriptContext construction fails, the library is not able to give a more informative error than Caused by: (force headList []).

Solution: make sure that your on-chain code and off-chain code match on the Plutus version. For hydra-cardano-api, use Plutus V2 for all on-chain code.

Yes. The documentation of hydra-cardano-api was not explicit about this. We will add it to the package README and the module documentation of Hydra.Cardano.API.

Thanks! That would be helpful

Another hint to let you know you are mixing V1 and V2 code is looking at the serialised version of the on-chain code - the .plutus file.
If the file has "type": "PlutusScriptV1", then the on-chain code complied as V1 code. Modify the imports.

source: Stack Exchange

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

sort: votes


text:
Plutus Contracts Delegation
Is there or will there be such a thing where delegators can stake to a smart contract itself, rather than a pool?

No, as the smart contract cannot produce blocks.
However, funds within a smart contact can be delegated to a pool.

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


text:
Can I always imply that **if** a transaction was successful, all validators from all inputs were successful?
I have a transaction with many validators and I want to rule out a possible error.

If I got you right, you are asking if both of the following statements are true:

Transaction is successful -> all validators were successful,
and also
All validators were successful -> transaction is successful

Statement 1) is clearly true. Statement 2) is also true as all other conditions that need to be met are checked before the validators are run, which means that when the validators are run, only their failure can make the transaction invalid.
An article from Polina Vinogradova on www.iohk.io explains the validation process in a very good way. Quoting:

Transaction validation on Cardano is divided into two phases. The main reason for introducing two-phase validation is to limit the amount of uncompensated validation work by nodes. Each phase serves a purpose in achieving this goal. Roughly speaking, the first phase checks whether the transaction is constructed correctly and can pay its processing fee. The second phase runs the scripts included in the transaction. If the transaction is phase-1 valid, phase-2 scripts run. If phase-1 fails, no scripts run, and the transaction is immediately discarded.

(see: https://iohk.io/en/blog/posts/2021/09/07/no-surprises-transaction-validation-part-2/)

Yes. The transaction will be treated as atomic. If one of the inputs are unspendable, the tx will fail.


text:
How are Staking rewards calculated?
I remember that initially the percentage of rewards for delegators was around 5.12% visiting Cardano Calculator. Now they are approximately 4.6083%.
How this is calculated?
Will the percentage decrease over the years?

As explained in the docs, rewards come from:

Transaction fees (increases in time if adoption and network traffic increases)
Monetary expansion (decreases in time)

The sum of these is denoted by R and the share of rewards that a given pool gets is given by:

where: R - total available rewards for this epoch
a0 - pledge influence factor (can be between 0 and infinity)
z0 - relative pool saturation size, i.e. 0.5% based on a number of
desired pools (k=200)
σ - stake delegated to the pool (including stake pledged by the owners
and stake delegated by others)
σ’ = min(σ, z0) - as σ, but capped at z0
s - stake pledged by the owners
s’ = min(s, z0) - as s, but capped at z0

About monetary expansion and issuance, you may check this section of the docs.
Essentially, every epoch, a fixed fraction ρ is taken from the ADA reserves and is added into R. From the docs:

Calculating the ‘reserve half life’ (that is, the time that it takes for half of the reserve to be used up) visualizes the impact of choosing a specific value of ρ over another. This was the subject of much discussion, and eventually, the value assigned was 0.3%. The reason why is that mathematical projections showed that a ρ (the fixed percentage of ada going into the virtual pot every epoch) value of 0.3% would mean a reserve half-life of four to five years. In simple terms, just half of the remaining reserve would be used every four to five years.

Based on that information can we say that this percentage of 4.6% annual return will be approximately the same or over the years this can decrease substantially?
I am asking because based on that information I will be able to better plan the future of a foundation which will funded from the rewards.

At best, you can define different scenarios under different assumptions. Perhaps a simple lower bound could be established assuming that R is mainly given by monetary expansion and ignore transaction fees. In that case, rewards should decrease by 50% every 4-5 years. But a more general analysis should also consider projections on network growth. I'll leave that work to you ;)

Charles mentioned that over the time the idea is the rewards to be ensured by the transactions fees when we have billion of transactions.
I just wanted to see if there is something else to this question (like the formula above).

That's correct. By network growth I mean more transactions and hence more fees. You would need to evaluate different scenarios to get a better idea.

The link to the formula is not available anymore. It can now be found here:
https://testnets.cardano.org/en/testnets/cardano/get-started/pledging-and-rewards/


text:
What is an Initial Stake-pool Offering (ISO)?
The decentralized exchange Sundaeswap is planning an initial stake pool offering (ISO) on Cardano.
How does it work and what are the differences/advantages over an ICO?

There is a blog post that describes it quite well: https://sundaeswap-finance.medium.com/sundaeswaps-upcoming-initial-stake-pool-offering-iso-48fade1900a
Basically they will create a Cardano stake pool and you can delegate your ADA to this pool from your Yoroi or Daedalus wallet. The pool will take 50% - 100% margin fee (to fund the SundaeSwap developers). This means you will get less ADA as rewards from the pool. To compensate for this, they will send you some of their new SundaeSwap tokens.

EDIT: There is a more in depth blog post here.

EDIT 2: On 11-JUL-2021 there was an update from the SundaeSwap team.
You can read it here: https://www.sundaeswap.finance/posts/iso-update-3
They changed it to a 0% margin fee model that only lasts for 5 epochs. It will be launched together with the DEX shortly after the Alonzo launch on mainnet.

"...the ISO funding model is distinct, and does not represent the sale of a security." do they have a layer backing up this claim? I see that people will do this because they think that their tokens will be more valuable in the future and that will be treated as security. Or am I missing something?
--- edit
Or the "trick" is that one is paying in the future rewards and not "money" that one has "at the moment". Sill would be nice to see some layer opinion about it :)

Looks like they are planing to show this legal framework: https://www.sundaeswap.finance/posts/iso-update-3


text:
How is wallet balance over epoch computed to calculate staking rewards?
Let's say I have two wallets, each delegated to a different stake pool.
At some point within an epoch I transfer some Ada from one wallet to the other.  What will be the applicable balance which is considered staked by each wallet/pool for that epoch?

At the end of epoch N the balance in your wallet becomes the staked balance for epoch N + 2 and the staking rewards for epoch N + 2 are paid at the start of epoch N + 4.
This avoids the need to lock ADA up for staking and also gives the code enough time to do the required calculations before they are needed.

OK so if I understand correctly, a snapshot approach is used, not an average, and there is also a delay (same delay as per re-delegation).

Above answer is correct, please accept it. Yes, snapshot of stake is always taken on epoch boundary, and is used for block production epoch after snapshot.


text:
How would a 51% Attack on the Cardano blockchain be started and overcome?

What exactly is the 51% Attack?

How hard would it be to accomplish this attack?

How easy is it to overcome the attack should it actually occur?

I gave you +1 but your question body is almost exactly the same as the question title. If you don't have anything else to write, maybe you could tell us what research you've done on the topic so far and where you've tried to look? The question body is usually meant to have more than just a repeat of the title!

The 51% attack is used by an attacker to take over the blockchain. Usually, the community of a blockchain has to reach consensus, which means that once someone mints a new block, other nodes validate it. The majority has to agree that the new block is valid and thus the blockchain has grown one block. All other nodes accept the new block and all it's content (transactions) as valid and "follow" it, as in using is as a starting point to calculate the next block.
For a proof of work blockchain like Bitcoin, this would mean to have more hashing power than anyone else on the blockchain. This would even allow to you overwrite existing blocks. To regain control, the "honest minority" had to increase their hashing power.
For a proof of stake blockchain like cardano, an attacker would require more than half of all staked ada. An attacker would have to buy 22.5 billion ada of the currently circulating supply of ~33bn ada or control enough pools to which this amount of ada had to be delegated to. Buying ada would drive the price up, depending on how fast he wants to buy and how much he agrees to pay per ada and would be very difficult, same goes for running enough pools that attract enough delegators as well.
The attacker could then dictate the content of the minted blocks. To regain control in a scenario where the adversary bought the ada, the "honest minority" would have to buy his coins, which the attacker would have to agree to. In theory, this could be very difficult. However, it is almost impossible for an attacker to obtain that many ada in the first place.
If the attacker controls enough pools thus has enough control over more than half of all staked ada, the honest owners of the coins could simply switch to honest pools.
As for all 51%: with a growing number of honest users participating in a healthy network, an attacker will have a harder time to take it over, until it becomes basically impossible.

I'd like to add, that the attacker only needs control of the majority of ada; this means he doesn't have to buy it, but could simply offer other incentives for delegators. (think of exchanges or big pools).

Thank you! I added this to my answer as well. He has to control the staked ada, it does not has to be his own.

The 51% number would imply the attacker controlled 51% of the STAKED ADA.  Not necessarily 51% of all ADA. Of course the closer we get to 100% of all ADA staked the closer those two numbers get to each other.


text:
How can I send ADA to a Yoroi wallet?
I have created a new Yoroi wallet and I want to send ADA to the newly created Yoroi wallet, but I don't know how.

You can refer to the Yorio FAQ for this: https://yoroi-wallet.com/#/faq/2

To receive Ada go to the Receive tab in your wallet and generate an address. Use a button in the user interface to copy it to the clipboard and then share it with the person who is going to send you Ada.


text:
How to transfer ADA from Daedalus wallet to Yoroi wallet?
I have created a new Yoroi wallet but I want to transfer ADA from Daedalus wallet, but I don't know how.
For example:
I have 20 ADA that I want to send to a Yoroi wallet and I want to send them from a Daedalus wallet.

Get your Yoroi wallet address. See How to send ADA to Yoroi wallet?
In Daedalus send some ADA to this address.

Alternatively, you can also restore the Daedalus wallet in Yoroi if you just want to switch the wallet applocation. To do this you can use the restore function in Yoroi. Then you'll see the 20 ADA from Daedolus in Yoroi. This is not a transaction, you just imported the wallet in Yoroi. Yoroi and Daedalus are just different tools to manage your wallet.


text:
Why am I prompted to recover Yoroi Wallet every time on startup?
Every time I start the app, despite it logging in, I can not see my wallet.
I can see the two options to add a wallet. After that, I can choose between creating, restoring, and connecting to a ledger.
How can I recover the wallet upon startup?

Just to double check: have you created a wallet first?

Not sure which platform (iOS/Android) you're using or which version of Yoroi wallet. And, I'm a bit confused about the two options. In my Yoroi application (Android, Yoroi v4.0.2, Commit ea5c1120) I see the option to access my wallets (saved) or, at the bottom,

ADD WALLET (SHELLY-ERA)
ADD WALLET (BYRON-ERA DEPRECATED)

So, if you don't see your wallet(s) listed under (My wallets) then you'll need to either:

A. CREATE WALLET (which will create a new wallet that will be saved in the application in the future)

B. RESTORE WALLET (which requires you to have already created a wallet and have your 12/24 word recovery phrase, your private key)

C. CONNECT TO LEDGER NANO (which requires you to have a Ledger Nano hardware wallet)

You'll need to decide which path makes the most sense for you, but my guess is you'll want to do 1. -> A.

As you said I will try option A as it is the simplest option here as I am beginner .. but really thanks for great answer ...

There is currently a bug in version v4.0.2 affecting a few users in the way you describe. As a workaround, you can try to restore your wallet again and then delete it. The first wallet should now appear in the initial wallet list screen.
See https://twitter.com/lordb_rocks/status/1384565929665720323


text:
bech32 in Shelley addresses
I'm trying to write address validation in Python. According to the docs, Shelley addresses are encoded with bech32 and the first byte of the payload consists of header_type (4 bits) and network_tag (4 bits).
So, let's consider the following address:
addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx
In [2]: bech32.bech32_decode("addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx")
Out[2]:
('addr',
 [14,
  7,
  1,
  23,
  22,
  6,
[...]

The first byte of the payload is 14, which would mean network_tag = 14 and header_type = 0. However, (a) the HRP doesn't contain the _test suffix and (b) cardano-address reports different network tag than my result does:
$ echo addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx | cardano-address address inspect
{
    "spending_shared_hash": "c37b1b5dc0669f1d3c61a6fddb2e8fde96be87b881c60bce8e8d542f",
    "stake_shared_hash_bech32": "stake_shared_vkh1cda3khwqv60360rp5m7akt50m6ttapacs8rqhn5w342z7p6v69g",
    "address_style": "Shelley",
    "network_tag": 1,
    "spending_shared_hash_bech32": "addr_shared_vkh1cda3khwqv60360rp5m7akt50m6ttapacs8rqhn5w342z70dxhec",
    "stake_reference": "none",
    "stake_shared_hash": "c37b1b5dc0669f1d3c61a6fddb2e8fde96be87b881c60bce8e8d542f"
}

I guess I'm making some stupid mistake, but where?

The problem stems from bech32 being a base5 encoding, which means that one character of address representation encodes only 5 bits of the actual address data.
The bech32_decode function from Python Reference Implementation leaves the decoded data as it is: every byte may have only 5 youngest bits used. Meanwhile the Cardano tools use converted notation, where bits are shifted left and "packed".
In the PRI you may add another step to get the packed data into payload var:
hrp, _payload32 = bech32_decode(address)
payload = convertbits(_payload32, 5, 8, False)

I would use the bech32 decoder tool available here:
https://github.com/input-output-hk/bech32
You can also find it in Daedalus in the binaries folder for your platform.
$ bech32 <<< addr1w8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gtcyjy7wx
71c37b1b5dc0669f1d3c61a6fddb2e8fde96be87b881c60bce8e8d542f

This outputs the address in a hex format which is easier to understand as each 2 hex characters are one byte.
7# at the start means that it's a smart contract address, I believe. The 1 in 71 means a mainnet address. 70 would be a testnet address.
More info about addresses can be found here:
https://github.com/cardano-foundation/CIPs/blob/master/CIP-0019/CIP-0019.md

OK, it seems the bech32 implementations differ. Thank you for pointing out the IOHK source. Somehow I missed it.


text:
Did the token fingerprint hash algorithm change?
I have an question about the asset fingerprint.
For example here:
https://pool.pm/333427e94971f530653bb945f34f914252ad570c0b84dfd8c8e8c97b.ExtraHate067
it shows asset1yjj6l5ude4gf274ya0exk4vymaaj0464yxmnvm
here it shows the same: https://cardano-tools.io/latest?q=ExtraHate067
but the explorer
https://explorer.cardano.org/en/transaction?id=0d560535733237eaafa4f3c25e648d147dc93a048e3dc66e5199cd86986b5a2c
shows asset1q7c0qhulpty4tcdp3cwt8eg5edws9c8lqyldlr did they change the hash algorithm?

Yes, it's really strange. I managed to find a transaction where fingerprints are equal. Necromancer 003 https://cardano-tools.io/latest?q=f4988f549728dc76b58d7677849443caf6e5385dc67e6c25f6aa901e https://explorer.cardano.org/en/transaction?id=a4b4c4c637bf297af7ece2079bdbf6af8bbbcb6611603ae8a6109a47ea804de7

Wow, good catch. You can see fingerPrint function here. It's located in cardano-graphql project.
export const assetFingerprint = (asset: Pick<Asset, 'assetName' | 'policyId'>) =>
  new AssetFingerprint(
    Buffer.from(asset.policyId, 'hex'),
    asset.assetName !== '' ? Buffer.from(asset.assetName, 'hex') : undefined)
    .fingerprint()

After running this code
const fingerPrint = ({ policyId, assetName }) => {
  const af = new AssetFingerprint(
    Buffer.from(policyId, 'hex'),
    Buffer.from(assetName, 'hex'),
  ).fingerprint()

  return af
}

const combinations = [
  {policyId:'333427e94971f530653bb945f34f914252ad570c0b84dfd8c8e8c97b',
   assetName:'457874726148617465303637'},
  {policyId: "",
   assetName:'457874726148617465303637'},
  {policyId: '333427e94971f530653bb945f34f914252ad570c0b84dfd8c8e8c97b',
   assetName: ""},
]

combinations.map(fingerPrint)

I got
[
  'asset1yjj6l5ude4gf274ya0exk4vymaaj0464yxmnvm',
  'asset1q7c0qhulpty4tcdp3cwt8eg5edws9c8lqyldlr',
  'asset19nqnahcv54krdv8mcc0ne60wlkealw5qaztzvp'
]

Which means that policyId is missing in the explorer but the fingerprint function is the same.
You can rerun my code in replit.
I also created an issue for cardano-explorer-app.

This looks like a bug in explorer.cardano.org.
You can use the JS package @emurgo/cip14-js to check for yourself.
import AssetFingerprint from '@emurgo/cip14-js'

const assetFingerprint = new AssetFingerprint(
    Buffer.from('333427e94971f530653bb945f34f914252ad570c0b84dfd8c8e8c97b', 'hex'),
    Buffer.from('457874726148617465303637', 'hex'),
  )
assetFingerprint.fingerprint()
// returns asset1yjj6l5ude4gf274ya0exk4vymaaj0464yxmnvm

Fixed in https://github.com/input-output-hk/cardano-graphql/pull/526. Thanks for the investigation.
Edit: Released in 5.0.0, adopted by cardano-explorer-app in 1.6.0


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:
How can you check if a local node is running properly?
I am running a Cardano node using docker, on the testnet, and now I need to check if it works properly and accepts cardano-cli arguments like querying and what not.
Is there a convenient way to do it?

What happens when you enter cardano-cli into the terminal of the docker container running the Cardano node?

Resolving it, as I reached success with connecting to the docker container and running the queries from there, and everything works fine.

The correct way to do that was to docker exec into the container, and cardano-cli works just fine from there.

To run cardano-cli in the container:
docker exec -it  -e CARDANO_NODE_SOCKET_PATH=/path/to/node.sock cardano-node cardano-cli
So to check the tip:
docker exec -it  -e CARDANO_NODE_SOCKET_PATH=/path/to/node.sock cardano-node cardano-cli query tip --mainnet
I put cardano-cli as an alias:
alias cardano-cli='docker exec -it  -e CARDANO_NODE_SOCKET_PATH=/path/to/node.sock cardano-node cardano-cli'. That way you can just invoke the cli as if the cardano-cli was in your PATH.


text:
Where does the `mustPayToTheScript` function gets the script address from?
On the plutus pioneer program, lesson 02, Lars shows the parameterized contracts and on the off-chain code he makes use of the mustPayToTheScript function to create the transaction. Different from other similar functions, this one doesn't take the hash of the script as an input. Therefore, how does it know what is the script address to use?

It doesn't need the script address in this case because later he uses:
ledgerTx <- submitTxConstraints typedValidator tx

where typedValidator is the script.

Why didn't you give the OP an upvote?

Yeah, good point. Done


text:
Blockfrost assets api issues
We are developing an app that must get the asset id and get its details from metadata, right now we are using blockfrost.io. It works very good for policy Id's, we can use the pool.pm website and get the information regarding all the assets the policy has.
Unfortunately, it doesn't work very well for the asset id... The blockfrost only accepts the concatenation of policy id and the hex encoded asset name. I can't determine the hex encoded asset name. If any of you know how to do that let me know.
Thanks in advance.
this is the endpoint:
https://cardano-mainnet.blockfrost.io/api/v0/assets/{asset}
some valid id's I found using postman:
0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04756e7369673236383531

Meta comment. Why would you use a centralized, single point of failure component in a service whose main goal is to create decentralized ecosystem? So, instead of calling blockchain wrapped with web api you should be querying the blockchain yourself. Web api for blockchain does not make much sense.

@matcheek makes a lot of sense, I don't have the resources to build an API like this for my project, I can focus on whatever my project needs and use their api. this is industry standard development. The JSON web api is used in several types of frameworks and libraries, do I need to create everything from scratch just for purism and never delivers my app? That doesnt make sense, if the point of failure happens we can fix the app but never develop anything with premature optimizations its amateurism approach.

Let's take this asset as an example: https://pool.pm/0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04.unsig26071

Policy ID: 0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04
Asset name: unsig26071

To request this asset from the blockfrost.io API, you have to convert the name to HEX and then concatenate them (without a . in between).
How you do this depends on the programming language you use. You need to find a way to convert a string to its HEX representation.
Here's an example in C#:
using System;
using System.Text;

string assetName = "unsig26071";
byte[] bytes = Encoding.UTF8.GetBytes(assetName);
string hexAssetName = Convert.ToHexString(bytes); // 756e7369673236303731

To verify that you convert the names correctly, you can use a page like this one: http://string-functions.com/string-hex.aspx
Here's the converted example on cardanoscan:
https://cardanoscan.io/token/0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04.756e7369673236303731
Your blockfrost.io request would look like this:
https://cardano-mainnet.blockfrost.io/api/v0/assets/0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04756e7369673236303731

thanks this is the accepted


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 correct Plutus repo tag for Plutus Pioneer Program week01?
I'm starting out with the Plutus Pioneer Program at https://github.com/input-output-hk/plutus-pioneer-program. One of the first steps is to clone the Plutus repo https://github.com/input-output-hk/plutus.git from the tag specified in the cabal.project
tag: 3746610e53654a1167aeb4c6294c6096d16b0502.
This doesn't appear to be a tag on the Plutus repo. Is it still possible to get the correct Plutus version for the Pioneer Program code?

With tag: 3746610e53654a1167aeb4c6294c6096d16b0502 in cabal.project they refer to a commit, not a git tag.
You can find it here: https://github.com/input-output-hk/plutus/commit/3746610e53654a1167aeb4c6294c6096d16b0502
So to get the correct version of the repo, you can check out the git commit:
git checkout 3746610e53654a1167aeb4c6294c6096d16b0502

I don't think I have configured anything special in git, but I can git checkout with a shortened hash:  git checkout 3746610e  - less frightening :-)


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

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


text:
How to get all NFTs of a wallet address?
I'm trying to retrieve all assets which are located at the specific wallet address, I queried through the docs but couldn't find anything suitable.
Can anybody provide me some help regarding this please?
What I'm trying to do is, let the user enter his wallet address and showcase him his NFTs in the web. If something like this is not doable please correct me.

Try pool.pm/address

@Distic im trying to do it through an official api, and i dont think its okay to fetch their html data and grawl it

Sorry I read it too fast

You can try using cardano-wallet package on a running node & then using this endpoint to list all assets on a wallet.
There are several ways to run cardano-wallet either a docker container or just installing the compiled binary on a running node which is what I did. You can find the binary here as well as the documentation under the note section.

Try the /accounts/{stake_address}/addresses/assets call using Blockfrost.

There is a tutorial/examples on how to achieve it using blockfrost.
Nft tutorial on Cardano


text:
Plutus-Start for Windows - Cannot get the docker repository to run (A mount config is invalid.)
I am following :
https://github.com/input-output-hk/plutus-starter
I have downloaded VSCode and Docker. I downloaded the Remote Development extension in VSCode. I then ran "mkdir -p ~/.cabal/packages" in the terminal per the tutorial. All is well.
When I try to clone the repository to container it runs for a good bit and then displays this error:

A mount config is invalid. Make sure it has the right format and a
source folder that exists on the machine where the Docker daemon is running.

I can then select "Open devcontainer.json in Recovery Container". Is there some setting I can tweak in this file that fixes the problem? Im on Windows 10, 64-bit, with fresh installs of Docker and VSCode.
My devcontainer.json file looks like this:
{
"name": "Plutus Starter Project",
"image": "docker.io/inputoutput/plutus-starter-devcontainer:v1.0.8",
"remoteUser": "plutus",

"mounts": [
    // This shares cabal's remote repository state with the host. We don't mount the whole of '.cabal', because
    // 1. '.cabal/config' contains absolute paths that will only make sense on the host, and
    // 2. '.cabal/store' is not necessarily portable to different version of cabal etc.
    "source=${localEnv:HOME}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached",
],

"settings": {
    // Note: don't change from bash so it runs .bashrc
    "terminal.integrated.shell.linux": "/bin/bash"
},

// IDs of extensions inside container
"extensions": [
    "haskell.haskell"
],

}
Edit: In the .devcontainer/devcontainer.json file, there is a reference to your source folder for cabal/packages. When I replaced the default path with my specific path, I was able to get it to work.

can you please show your full line "source=$...." in your devcontainer.json ? I would like to see exactly how you referred to your source folder in this line .. struggling with this .. Thanks a lot & kind regards,
Pieter

I have the same issue here and can't work out the solution based on the Edit above. Please give an example of a working source folder reference! Thanks!


text:
How to get Wallet ID from an address?
I'm trying to use the cardano-wallet API, but most of the endpoints I want to use are based on WALLET_ID parameter.
How can I find out the WALLET ID when all I have is the addr, for example addr1qyxwlgeux7f8t7552p8uh3de8yfakftt3lwmceuzs9jcw0gw3el5uu8gpznfcsthyvuf558epvsmjl2gmmkvax535tjsaglpn2?

Think of cardano-wallet as Daedalus, it can only manage locally created wallets and their addresses and transactions.
If you want to interact with the blockchain as a whole you should be using cardano-cli (I used Lars' Lobster Challenge address as an example instead to have some outputs):

Get some tech info:

$ cardano-cli address info --address addr1w8433zk2shufk42hn4x7zznjjuqwwyfmxffcjszw5l2ulesdt3jff
{
    "address": "addr1w8433zk2shufk42hn4x7zznjjuqwwyfmxffcjszw5l2ulesdt3jff",
    "base16": "71eb188aca85f89b55579d4de10a729700e7113b325389404ea7d5cfe6",
    "type": "payment",
    "encoding": "bech32",
    "era": "shelley"
}

Get ADA/tokens balance and Plutus stuff

$ cardano-cli query utxo --mainnet --address addr1w8433zk2shufk42hn4x7zznjjuqwwyfmxffcjszw5l2ulesdt3jff
                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
319752b414804415988fb1165358e69f46095a9e9b1c01ef0830c182dc57f78b     0        1000000 lovelace + TxOutDatumHashNone
4c34feb07e32aa4855a494306aefcf16743356811914d680e112a6ec12214455     0        1000000 lovelace + TxOutDatumHashNone
63091c70aa6f8b402faffd24909d93c7721cbdced7094b62e52d157da8fb44e4     0        5000000 lovelace + TxOutDatumHashNone
67d318fabdd9905033bfe6156c6595716c952d496cabb9d98773c948974780ec     0        1000000 lovelace + TxOutDatumHashNone
cb7b44500fc9145cf5b13a533bc7616eb219b7a080bc49d7ce6204c06b351733     0        1000000 lovelace + TxOutDatumHashNone
cf944108d7130a8d53925ff9903a254d5133d5978b7e69e04c67d5b8776a6fb2     1        2034438 lovelace + 1 cc7888851f0f5aa64c136e0c8fb251e9702f3f6c9efcf3a60a54f419.LobsterNFT + 522 fda1b6b487bee2e7f64ecf24d24b1224342484c0195ee1b7b943db50.LobsterCounter + 501 fda1b6b487bee2e7f64ecf24d24b1224342484c0195ee1b7b943db50.LobsterVotes + TxOutDatumHash ScriptDataInAlonzoEra "45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0"
db250ed5eb4454843af19dea7ca84a8adda170fc88284e7e5e2381b41dab5f9b     1        30768137 lovelace + TxOutDatumHashNone

Would be helpful to see an example output of these commands.

Thank you for the answer!
Any idea why the cardano-cli query utxo --mainnet --address would return no utxos, when, for example, pool.pm shows 5?
(cardano-node is fully synced)

I'm not sure but it's like if pool.pm is showing everything regarding the wallet associated with the searched address. Your address shows 522 ADA and 2 NFTs, but if you see the NFTS's info they belong to two completely different addresses. Maybe those 522 ADA are shared among other addresses too because Cardano Explore shows no results neither https://explorer.cardano.org/en/address?address=addr1qyxwlgeux7f8t7552p8uh3de8yfakftt3lwmceuzs9jcw0gw3el5uu8gpznfcsthyvuf558epvsmjl2gmmkvax535tjsaglpn2

Although it's nice that you put some examples of getting info, there are no examples of how to get the wallet id from a receive address, regardless of what tool you're using.

@melchoir55 A "wallet id" only has sense in the cardano-wallet local environment context. On the blockchain the equivalent would be the private key, and it'd be very bad if you can find it from the address. All you can have is the address, i.e. (one of) the wallet's public key(s).

In JavaScript, from the Nami Wallet PAB demo:
exports.getWalletIdImpl = () => {
  return Promise.all([window.cardano.getUsedAddresses(), window.cardano.getUnusedAddresses()])
    .then(([walletUsedAddresses, walletUnusedAddresses]) => {
      const addresses = walletUnusedAddresses.concat(walletUsedAddresses)
      return require('blake2b')(20)
        .update(Buffer.from(addresses.map(a => a.to_bech32).join('')))
        .digest('hex')
    })
}


text:
What's the equivalent to ownPubKey in the newer version of Plutus?
In lesson 5 that they use a built in function called ownPubKey to access the wallet pubKey in the transaction on the plutus playground.
This function seems to be non-existent in the newer versions of plutus what is a good replacement for this?

You should use ownPaymentPubKeyHash here is the source code.
It will work by just replacing ownPubKeyHash with ownPaymentPubKeyHash and return type PubKeyHash to PaymentPubKeyHash.

Here is: How to reference material written by others

Interesting, I haven't found one either. If you need the PubKey to compute the hash you can use ownPaymentPubKeyHash


text:
How can I configure Ale so it finds Plutus libraries?
I'm using nvim with Ale, no particular config other than:
Plug 'w0rp/ale'
let g:ale_sign_error = '●'
let g:ale_sign_warning = '●'

It looks like works out of the box for Haskell, but cannot find Plutus libraries:
$ nvim src/Week02/Gift.hs

:messages

Could not find module ‘Plutus.Contract’ Use -v (or `:set -v` in ghci) to see a list of the files searched for. |16 | import           Plutus.Contract | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Could not find module ‘PlutusTx’ Use -v (or `:set -v` in ghci) to see a list of the files searched for. |17 | import           PlutusTx            (Data (..)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Could not find module ‘PlutusTx’ Use -v (or `:set -v` in ghci) to see a list of the files searched for. |18 | import qualified PlutusTx | ^^^^^^^^^^^^^^^^^^^^^^^^^
Could not find module ‘PlutusTx.Builtins’ Use -v (or `:set -v` in ghci) to see a list of the files searched for. |19 | import qualified PlutusTx.Builtins   as Builtins | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Could not find module ‘PlutusTx.Prelude’ Use -v (or `:set -v` in ghci) to see a list of the files searched for. |20 | import           PlutusTx.Prelude    hiding (Semigroup(..), unless) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Could not find module ‘Ledger’ Perhaps you meant Lexer (needs flag -package-key ghc-8.10.4.20210212) Use -v (or `:set -v` in ghci) to see a list of the files searched for. |21 | import           Ledger              hiding (singleton) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^
...

Any idea how to configure Ale so it finds Plutus libraries?

Does this answer your question? Vim setup of Lars

Not really, no reference to Ale at all in there.


text:
How can I secure a Datum value in a smart contract?
I am trying to figure out how to write a script where you can make sure the datum value doesn't change each time an output gets consumed. For example, in the auction script in the pioneer program each step along the way someone wants to consume a previous output to up the bid. Suppose you wanted to store some meta deta in the datum and have it carried on the block chain, like a secondary beneficiary, imagine an auction house fee that gets set when the action is created.
Each end point supplies the the datum to be set as the output of the transaction. The endpoint code runs off chain. So it seems that there is no way to set a static datum value, especially for any script which allows the public to access, like an auction.
Is my understanding correct and this is just a limitation of the cardano smart contract?
Thank you in advance

I have a very similar question that could be answered by answering your question. I would be keen to see an answer to your question.

In the on-chain validator script, you can inspect the transaction outputs through the ScriptContext. An output has a datum hash field available. You can then assert that the hash is equal to the hash of the input datum. Ref: https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Contexts.html#t:TxOut

There are multiple ways to do that.
Option 1:
If you have "script-wide" constants, like your mentioned example of an auction house fee, I suggest parameterizing your contract like it is done in Lecture #3 instead of storing that value in each output's datum.
Option 2:
If you really want to ensure some or all of the datum fields are recreated when it is consumed you can do that too. By default for any spending transaction from a script, Plutus expects you to provide the datum value/file whose hash matches the one stored on-chain for the UTxO you're trying to spend in your transaction.
Your validator can check for an output recreated at its own address with a certain value and datum. If the datum shall be the exact same as previously you can simply check if the hash of the newly created output equals the one you're consuming.
Otherwise, you can also provide the datum (not the hash) of the newly created output in the transaction and validate it within the script. You can do that via the CLI by using:
--tx-out ADDRESS VALUE
[--tx-out-datum-embed-file FILE | --tx-out-datum-embed-value JSON VALUE]

or using CSL:
[...]
TransactionOutputBuilder.new()
    .with_address(yourScriptAddress)
    .with_data_hash(hashOfYourNewDatum) // does not include the datum value
    .next()
    .with_value(Value.new(someOutputValueOrMinADA))
    .build()

// Adding transaction datum values
// Must at least include a datum value for every script output that is being
// spent + optionally any additional datums necessary for the script validation
const datums = PlutusList.new();
datums.add(datumBuilder(1));
datums.add(datumBuilder(2));

const transactionWitnessSet = TransactionWitnessSet.new();
transactionWitnessSet.set_plutus_data(datums);
[...]

export const datumBuilder(n: number): PlutusData {
    const fields = PlutusList.new();
      fields.add(PlutusData.new_integer(BigInt.from_str(`${n}`)));
      return PlutusData.new_constr_plutus_data(
          ConstrPlutusData.new(
            BigNum.from_str('0'),
            fields
          )
        );
}

Once, you've added the datum value of the newly created script output to the transaction you can retrieve it in your Plutus code like similarly to any other datum:
[...]
where
    -- returns new outputs of this script
    ownOutputs :: [TxOut]
    ownOutputs = getContinuingOutputs ctx

    -- returns Datum value for a tx output if it is provided
    outputDatum :: TxOut -> Maybe Datum
    outputDatum o = txOutDatumHash o >>= flip findDatum info

Related answers to that topic:

Post 1


text:
Where is the Datum stored in PAB?
In utxo we store only the hash of the datum, so whenever you work with the Cardano cli to run a transaction - you should provide datum or its hash via tx-out-datum-embed-file, tx-in-datum-file, etc.
What about the PAB?
Did I understand correctly that original datum is stored in chainindex?
At what step is original Datum sent from PAB to the chainindex?
If the datum is stored in chaindex - does it mean that all PAB apps should be connected to the same chainindex in order to share datum with each other?
Are we going to have a global chainindex available for all PABs?
What if two PABs are connected to different chainindex servers, does it mean that the datum will not be shared between them?

Datum and redeemer (all required data for script execution) are stored on-chain as well so the node can optionally verify the script execution outcome when replaying the chain.
Since chainindex follows a chain using connection to cardano-node it receives all the executed scripts, datums and redeemers after they get committed on-chain.
Which means that even different chain-index servers will see the same script data.


text:
VSCode + Docker setup problems on Windows
I'm trying to setup the local enviroment by the VSCode + Docker way, because i find it easier for a newbie like me.
I open the cloned repository on VSCode but when y click on the button to reopen it in the Docker container y get this error:

I think that the problem is in the devcontainer.json file, exactly for this setting:
"settings": {
    // Note: don't change from bash so it runs .bashrc
    "terminal.integrated.shell.linux": "/bin/bash"
},

I think this is an incorrect property because i'm on Windows, not Linux, but i have no idea of what i should put in there to replace it.
I wil appreciate any help because i'm a total newbie to all this environment.

I think it will help if you actually describe how you are running the installation. Question: Have you installed the Remote Development extension pack for VS?

I had the same problem. Look at line 11 of devcontainer.json:
"source=${localEnv:HOME}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached"

Believe it or not, I solved this error by going into my environment variables and creating a variable name HOME that points to my user directory C:\Users\$username.
This is also mentioned in an answer to another Windows-specific issue: Problem starting a plutus devcontainer in windows where the solution is to change the variable from HOME to USERPROFILE.


text:
Nix build error: experimental Nix feature 'nix-command' is disabled
I have this error when I try to build plutus
:~/code/plutus$ nix build -f default.nix plutus.haskell.packages.plutus-core
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override

I also tried this, but I am still getting errors
:~/code/plutus$ nix --extra-experimental-features nix-command build -f default.nix plutus-apps.haskell.packages.plutus-core.components.library
error: executing SQLite statement 'pragma synchronous = normal': unable to open database file (in '/nix/var/nix/db/db.sqlite')

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

It seems like this is a single user installation. Are you running the nix command as the same user that installed nix? That would explain the unable to open database file error. You could validate this looking at the permissions/ownership of the sqlite file in question.
To allow nix-command and flakes, you can create /etc/nix/nix.conf with the contents:
experimental-features = nix-command flakes

I'd also recommend adding the binary caches in that file as well.

Thanks this error got cleared.Thanks


text:
Plutus function TxSIgnedBy - transaction build Error: The Plutus script evaluation failed
I'm trying to use Plutus function txSignedBy with a transaction involving the usage of cardano-cli
I first sent some UtxO to my script address, with a datum whose structure is like this:
data TradeDetail = TradeDetail
    { tradeOwner        :: !PubKeyHash
    } deriving (Generic, ToJSON, FromJSON)

data TradeDatum = TradeDatum TradeDetail
    deriving (Generic, ToJSON, FromJSON)

To build the datum,

I first generated the public key hash from my verificaiton key like this:
cardano-cli address key-hash --payment-verification-key-file mykey.vkey
and got 59b07e6d2500c82f6325ac18d7624cfbdb83a92e061c31068e6b03f9

Then I created the Datum JSON file encapsulating the public key hash

{
   "fields":[
      {
         "fields":[
            {
               "bytes":"59b07e6d2500c82f6325ac18d7624cfbdb83a92e061c31068e6b03f9"
            }
         ],
         "constructor":0
      }
   ],
   "constructor":0
}

My problem happens when I try to retrieve the UtxO from the script, providing the datum.
The validator sub-function where the error happens, in the ON-chain code, is like this:
{-# INLINABLE getback #-}
getback :: ContractInfo -> TradeDetail -> ScriptContext -> Bool
getback ci details context =

    traceIfFalse message $
        (scriptContextTxInfo context) `txSignedBy` (tradeOwner details)

    where

        message :: BuiltinString
        message = "Tx has to be signed by the item owner " `appendString` decodeUtf8 (getPubKeyHash (tradeOwner details))

When using cardano-cli to get back the UtxO, signing with mykey.skey,  I get the error:
Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with:
The Plutus script evaluation failed: An error has occurred:  User error:
The provided Plutus code called 'error'.
Caused by: [
  (builtin decodeUtf8)
  (con bytestring #59b07e6d2500c82f6325ac18d7624cfbdb83a92e061c31068e6b03f9)
]

I don't know why my error message is not well formatted, but at least the public key hash is correctly displayed.
This shows that, at the minimum, the datum is unpacked correctly and the public key hash is extracted.
But the question is, why function txSignedBy returns false ?

I finally found the answer myself. It is kind of obvious but easy to forget :-)
When using the command cardano-cli transaction build, the script gets executed although the transaction has not been signed yet. So the Plutus function txSignedBy is doomed to fail.
The trick simply consists in specifying that you will sign it later on with the required key, thanks to the option --required-signer-hash.
As usual, the problem was where I didn't expected to be...


text:
Auction example: How does Bob know the redeemer of the UTXO sitting at the script address?
When Bob places a bid...

He places a transaction/bid that takes in his UTXO (for which he has the private key as he is the owner) and the UTXO sitting at the script address.,

It outputs a new UTXO to a script address and potentially other UTXOs to individual.

To do that Bob needs to provide the redeemer and the actual datum associated with the script.
Where does he get that information from?

Finding transactions
Bob (the person) doesn't have to necessarily know that there's an auction going in the blockchain, but he can launch a transaction and look for UTXOs of this type of contract. If the off-chain code finds these specific type of UTXOs, then he can fetch the datum associated to it, and therefore he can place a bid.
If you look in the EnglishAuction.hs file, line 334:
findAuction :: CurrencySymbol
            -> TokenName
            -> Contract w s Text (TxOutRef, ChainIndexTxOut, AuctionDatum)
findAuction cs tn = do
    utxos <- utxosAt $ scriptHashAddress auctionHash
    ...

This is the function responsible for this. This happens when bidding (line 277):
(oref, o, d@AuctionDatum{..}) <- findAuction bpCurrency bpToken
...

...or closing the auction (line 309), or with any other endpoint the contract opens to the public.
UTxOs, scripts and redeemers

Scripts are not "giving" different types of UTxOs, rather, scripts
are attached, linked to UTxOs.
UTxOs contain the hash of the
datum attached to them.
They are not stored in any database, the
blockchain is the "database" itself for these UTxOs, scripts, etc...

The Cardano node in charge of processing the transaction or the script will reach the UTxOs via the script address, or vice-versa, if needed, and then validate according to its logic, evaluate the script, and create new resulting UTxOs.
On the other hand, the script will know about the redeemer because the person who sends a transaction to the blockchain for this concrete script will attach it. The redeemer is the data the user provides to the smart contract.
References
You can learn more about datums and redeemers in the Cardano docs: Working with datums and redeemers.
Other interesting Cardano SE questions:

What exactly is a Redeemer?
What does it mean that a UTxO sits at script address?

Thanks for your answer! This generates more questions though... I understand different scripts give different types of UTXOs and have different script hashes. Are all the scripts public? This is the only way I can see for identifying specific types of UTXOs. When you say "fetch" you mean there is a database somewhere where the datum for each type of UTXO is stored? Also, say we are looking at a different example, not the Auction, how do I know the redeemer? Is it a completely off-chain process?

I've updated my answer, trying to explain more about scripts and redeemers.


text:
TransactionBuilder and add_from_inputs
Looking through the cardano-serialization-lib I see a TransactionBuilderConfig and a TransactionBuilder constructor that looks like it takes the Config and exposes add_from_inputs that maybe does the coinSelection that is in a separate module in projects like Nami.
I don't however see how that's exposed in the javascript. Am I missing and/or misunderstanding these things or how they could or should be used??

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

It should be right there just as you say. The add_inputs_from function on the TransactionBuilder takes the strategy as the second parameter.
So in Javascript if your using this (https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser or https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs), you can import from it the CoinSelectionStrategyCIP2 and pass a strategy to the tx builder like this:
txBuilder.add_inputs_from(utxos, CoinSelectionStrategyCIP2.LargestFirst)

The implementation of the strategies is here: https://github.com/Emurgo/cardano-serialization-lib/blob/6a8c67a0fdb2ac6d72132d9693b87a6734f3fed5/rust/src/tx_builder.rs#L329

Ok cool thanks I'll try it out maybe I was looking at it wrong


text:
What is a library stanza?
I deduce what stanza definitions are but I was struggling to find an exact definition and explanation why this is used in Haskell/Plutus.

What exactly is a stanza?
Can you compile code Haskell/Plutus code
without using them?

I recommend you this article:
https://vrom911.github.io/blog/common-stanzas
Take into account that stanzas is a cabal thing (not Haskell, not Plutus). However Plutus projects can be created using cabal. Basically, it's the way a cabal file is organized: Libraries, executables, test-suites, etc.

If you answer someone's question, shouldn't you automatically vote for it?  It had 0 votes when I made this comment :-)

@gRebel, done. Thanks you for the reminder.


text:
new type and JSON
Working on Week 2 Homework 1, I tried to define a new type DuBool. The following is the relevant portion of the code, with the more traditional version commented out immediately above each line that uses DuBool.
newtype DuBool = DuBool (Bool,Bool)
PlutusTx.unstableMakeIsData ''DuBool
--
--
{-# INLINABLE mkValidator #-}
-- This should validate if and only if the two Booleans in the redeemer are equal!
-- mkValidator :: () -> (Bool, Bool) -> ScriptContext -> Bool
mkValidator :: () -> DuBool -> ScriptContext -> Bool
-- mkValidator _ _ _ = True -- FIX ME!
-- mkValidator _ (a,b) _ = traceIfFalse "Bools no match" $ a == b
mkValidator _ (DuBool d) _
    | a==b = True
    | otherwise = traceIfFalse "Bools no match" $ False
  where (a,b) = d
--
--
data Typed
instance Scripts.ValidatorTypes Typed where
-- Implement the instance!
    type instance DatumType Typed = ()
--    type instance RedeemerType Typed = (Bool,Bool)
    type instance RedeemerType Typed = DuBool
--
--
typedValidator :: Scripts.TypedValidator Typed
-- typedValidator = undefined -- FIX ME!
typedValidator = Scripts.mkTypedValidator @Typed
    $$(PlutusTx.compile [|| mkValidator ||])
    $$(PlutusTx.compile [|| wrap ||])
  where
--    wrap = Scripts.wrapValidator @() @(Bool,Bool)
    wrap = Scripts.wrapValidator @() @DuBool

This does compile in the repl error-free, and does compile and run in the playground simulator, but failure occurs with evaluation when the grab validation step occurs in the simulator, with

, Slot 2: 00000000-0000-4000-8000-000000000000 {Wallet W7ce8}:
            Contract instance stopped with error: "WalletError (ValidationError (ScriptFailure (EvaluationError [\"PT1\"] \"CekEvaluationFailure\")))" ]

I went back and attempted to edit the "type GiftSchema =" section to use DuBool, as follows:
type GiftSchema =
            Endpoint "give" Integer
--      .\/ Endpoint "grab" (Bool, Bool)
        .\/ Endpoint "grab" DuBool

and then the grab definition...
-- grab :: forall w s e. AsContractError e => (Bool, Bool) -> Contract w s e ()
grab :: forall w s e. AsContractError e => DuBool -> Contract w s e ()

But now compilation in the repl fails (sorry that the color and alignment here does not match what I see in the repl).

Prelude Ledger.Scripts PlutusTx> :l src/Week02/Homework1c_jwb.hs
[1 of 1] Compiling Week02.Homework1 ( src/Week02/Homework1c_jwb.hs, /Users/jwb/plutus/plutus-pioneer-program/code/week02/dist-newstyle/build/x86_64-osx/ghc-8.10.4.20210212/plutus-pioneer-program-week02-0.1.0.0/build/Week02/Homework1.o )
src/Week02/Homework1c_jwb.hs:117:13: error:
• No instance for (aeson-1.5.6.0:Data.Aeson.Types.FromJSON.FromJSON
DuBool)
arising from a use of ‘endpoint’
• In the expression: endpoint @"grab" grab
In an equation for ‘grab'’: grab' = endpoint @"grab" grab
In an equation for ‘endpoints’:
endpoints
= awaitPromise (give' select grab') >> endpoints
where
give' = endpoint @"give" give
grab' = endpoint @"grab" grab
|
117 |     grab' = endpoint @"grab" grab
|             ^^^^^^^^^^^^^^^^^^^^^
src/Week02/Homework1c_jwb.hs:119:1: error:
• No instance for (Schema.ToSchema DuBool)
arising from a use of ‘Playground.Schema.endpointsToSchemas’
• In the expression:
Playground.Schema.endpointsToSchemas
@((./) (Endpoint "give" Integer) (Endpoint "grab" DuBool))
In an equation for ‘schemas’:
schemas
= Playground.Schema.endpointsToSchemas
@((./) (Endpoint "give" Integer) (Endpoint "grab" DuBool))
|
119 | mkSchemaDefinitions ''GiftSchema
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.
Prelude Ledger.Scripts PlutusTx>

It appears that the entire code as written (including what I am leaving out for brevity) can convert (Bool,Bool) to JSON, but not DuBool. I am wondering if there is a simple change, perhaps to the imports, {-# LANGUAGE ... #-}, instantiation, etc. that would incorporate this functionality?
Clearly this is not needed to "solve" homework 1 of week 2, but I do believe it is a valid programmatic approach that will be useful going forward. And I think I am very close. Thanks in advance!
=============================================================
Kurt Sys provided an extremely helpful partial answer. A few rounds of trial and error in the repl led me to this compiling and working-in-the-simulator solution. I've left a comment trail to help anyone else following along.

-- import           Playground.Contract  (printJson, printSchemas, ensureKnownCurrencies, stage)
import           Playground.Contract  (printJson, printSchemas, ensureKnownCurrencies, stage, Generic, FromJSON, ToJSON, ToSchema)
--
-- newtype DuBool = DuBool (Bool,Bool)
data DuBool = DuBool
  {
    b1 :: Bool
   ,b2 :: Bool
  } deriving (Generic, FromJSON, ToJSON, ToSchema)
PlutusTx.unstableMakeIsData ''DuBool
--
{-# INLINABLE mkValidator #-}
-- This should validate if and only if the two Booleans in the redeemer are equal!
-- mkValidator :: () -> (Bool, Bool) -> ScriptContext -> Bool
mkValidator :: () -> DuBool -> ScriptContext -> Bool
-- mkValidator _ _ _ = True -- FIX ME!
-- mkValidator _ (DuBool (a,b)) _ = traceIfFalse "Bools no match" $ a == b
-- mkValidator _ (a,b) _ = traceIfFalse "Bools no match" $ a == b
-- mkValidator _ (DuBool d) _
mkValidator _ (DuBool a b) _
    | a==b = True
    | otherwise = traceIfFalse "Bools no match" $ False
--  where (a,b) = d

Now I need to understand the difference between "data" and "newtype".

I believe this should be broken up into multiple questions given the guidelines in [ask] and [help/dont-ask]

For homework1, you don't need to define a new type. That's what's done in homework2 :). Now, for defining a new data type (which is what you want):
data DuBool = DuBool
  {
    b1 :: bool ,
    b2 :: bool
  }

adding some type classes (implementing functions of some type classes) to it:
data DuBool = DuBool
  {
    b1 :: bool ,
    b2 :: bool
  } deriving (Generic, FromJSON, ToJSON, ToSchema)

I think that should work fine.

VERY helpful. Thank you. See my edit to the original question. If you can somehow incorporate what I produced into your answer I will consider this "answered" but as it stands yours is incomplete. But still very helpful as it led me to the solution.

I swear on MyRedeemer that I had not looked at homework 2 until now : D

@XiTouch the answer should be accepted as it was sufficient to lead you to an answer and Kurt has spent the time and effort to understand your long question(s).  If a better answer is provided in future, it can be voted up higher than the current one.

A little too brief, would benefit from a little more "why" explanation


text:
Haskell Language Server - linker error: symbol sqlite3_fts3_may_be_corrupt
When I run haskell-language-server in nix-shell in plutus-pioneer-progam i get this error.
   sqlite3_fts3_may_be_corrupt
whilst processing object file
   /nix/store/jmhwwzn1yfjzlxavz16afkf1r4shmp8z-persistent-sqlite-lib-persistent-sqlite-2.13.0.3/lib/x86_64-linux-ghc-8.10.4.20210212/persistent-sqlite-2.13.0.3-8rnIaulr0SMFWDeiU7TZN4/HSpersistent-sqlite-2.13.0.3-8rnIaulr0SMFWDeiU7TZN4.o
The symbol was previously defined in
   /nix/store/si95pc9hb5hr1yiyj7b2s75hl4bkn9g2-direct-sqlite-lib-direct-sqlite-2.3.26/lib/x86_64-linux-ghc-8.10.4.20210212/direct-sqlite-2.3.26-Gg0YVBPVrMk3LDxZxB2Bzf/HSdirect-sqlite-2.3.26-Gg0YVBPVrMk3LDxZxB2Bzf.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
     loaded twice.```

Are you on macos?

I've found out that the issue comes from the playground stuff. (don't ask me why...)
Commenting the lines [360 .. 365], 24 and 28, the problem goes away.
Note that doing this, the old friend GHC Core to PLC plugin; E043:Error comes up, but at least you can navigate the code and look at the documentation.

What is the file that needs to be edited ?

https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week01/src/Week01/EnglishAuction.hs


text:
Difference in the commit chosen between Plutus Pioneers lecture and given documents
When building plutus-apps locally I encountered a difference between the document that was shared a few days ago and the first lecture of Plutus Pioneers.
The document says the following:
git checkout 41149926c108c71831cfe8d244c83b0ee4bf5c8a

In the first lecture of plutus pioneers we have the following:
git checkout 41149926c108c71831cfe8d244c83b0ee4bf5c8a

Should I build plutus-apps again with the commit version specified on the video or the version described in the documents is fine?

As I don't have enough reputation to comment yet, I'll post my comments here. In your question you have used the same commit number from both sources (document and video). I assume that's a typo. The commit listed in the video https://www.youtube.com/watch?v=zPaDp4R9X7o&list=PLNEK_Ejlx3x2nLM4fAck2JS6KhFQlXq2N&index=3 (time 4:24) is 41149926c108c71831cfe8d244c83b0ee4bf5c8a and that matches what's in plutus-pioneer-program/cabal-project. What was the commit in the document (I can't determine which source you used)?

@SteveMason Welcome aboard!  Please follow the guidelines in the help center and accept the limitations that your account has.  I know it is frustrating but they are there for the benefit of the community and the quality of the site.  We all benefit in the long run.

@SteveMason Here's how to build up your reputation so that you can comment: What is reputation?

Each week there will be a new id/tag for the git checkout, as Plutus is under constant development. Use the one from the lecture this week, and then next week use the one from next week's lecture.
Here's a video which helps explain commits and checking out. I'm new to this stuff as well so it helped me understand a bit better.
https://www.youtube.com/watch?v=7y_htm0sw-I

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

The commit in the lecture, which is the one in the cabal file of the first week code works fine and I would recommend using that to be in line with the lecturer.

I used git checkout 7f53f18dfc788bf6aa929f47d840efa1247e11fd and it worked. It's a bit more recent.


text:
Building PAB error: attribute 'plutus-pab' in selection path 'plutus-pab' not found
I am following https://docs.plutus-community.com/docs/setup/MacOS.html
I know the plutus-apps repo is newer than those docs and have downloaded it but it seems I can't build plutus-pab.
When I run
$ nix-build -A plutus-pab
I get:
error: attribute 'plutus-pab' in selection path 'plutus-pab' not found
I thought I had built everything but when I tried to run $ npm run start in plutus-playground-client I got this:
sh: line 1: plutus-playground-generate-purs: command not found

I may need to build https://github.com/input-output-hk/plutus-apps/tree/main/plutus-pab-executables but when i try $ nix-build ../default.nix -A plutus-apps.haskell.packages.plutus-pab I get Segmentation fault: 11

Was able to run $nix-build default.nix -A plutus-apps.haskell.packages.plutus-pab from within nix-shell. Seems like it worked, but main problem still not resolved.

After a reboot, this issue seems to have resolved itself. Unfortunately I'm not sure what I did. Playground client now runs, though I cannot compile the hello world sample. On to tackling next error...

To build needed:
$ nix-build ../default.nix -A plutus-apps.haskell.packages.plutus-pab
in top level of plutus-apps folder.
in plutus-apps/plutus-pab-executables


text:
nix-shell : getting error "Index state found was 2021-10-20T00:00:00Z and no `index-sha256` was provided."
I'm having issues starting nix-shell from the plutus-apps directory.
I have followed the steps provided here: https://docs.plutus-community.com/docs/setup/WindowsCohort2.html.
Below is the full output of what I see when I try to start nix-shell with the --show-trace flag:
/mnt/c/dev/workspace/plutus-apps$ nix-shell --show-trace
error: Index state found was 2021-10-20T00:00:00Z and no `index-sha256` was provided.

       … while evaluating anonymous lambda

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/lib/call-cabal-project-to-nix.nix:9:1:

            8| in
            9| { name          ? src.name or null # optional name for better error messages
             | ^
           10| , src

       … from call site

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:487:36:

          486|               args = { caller = "cabalProject'"; } // args';
          487|               callProjectResults = callCabalProjectToNix args;
             |                                    ^
          488|               plan-pkgs = importAndFilterProject {

       … while evaluating anonymous lambda

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/lib/import-and-filter-project.nix:5:1:

            4| { pkgs, haskellLib }:
            5| { projectNix, sourceRepos, src }:
             | ^
            6| let

       … from call site

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:488:27:

          487|               callProjectResults = callCabalProjectToNix args;
          488|               plan-pkgs = importAndFilterProject {
             |                           ^
          489|                 inherit (callProjectResults) projectNix sourceRepos src;

       … while evaluating the attribute 'hsPkgs.shellFor'

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:510:43:

          509|               project = addProjectAndPackageAttrs rec {
          510|                   inherit (pkg-set.config) hsPkgs;
             |                                           ^
          511|                   inherit pkg-set;

       … while evaluating 'shellFor'

       at /nix/store/8n76c1c3nz2wl6dzxmxdz2y5xrx70flw-source/overlays/haskell.nix:612:24:

          611|             #
          612|             shellFor = shellArgs:
             |                        ^
          613|               let

       … from call site

       at /mnt/c/dev/workspace/plutus-apps/shell.nix:115:1:

          114| in
          115| haskell.project.shellFor {
             | ^
          116|   nativeBuildInputs = nixpkgsInputs ++ localInputs ++ [ sphinxTools ];

       … while evaluating anonymous lambda

       at /mnt/c/dev/workspace/plutus-apps/shell.nix:1:1:

            1| { system ? builtins.currentSystem
             | ^
            2| , enableHaskellProfiling ? false

       … from call site

I am using Windows 11 wsl2 with Debian distro

This very much looks like your plutus-apps checkout is corrupted? Can you provide the git rev of your plutus-apps checkout (e.g. git rev-parse HEAD) and what ever git status lists?

With some help from a few fellow plutus pioneers that also ran into this issue, it has been resolved.
This was the solution:
For Windows users who encounter the following error in Docker or wsl:
 "Index state found was 2021-02-24T00:00:00Z and no index-sha256 was provided."
It turns out, you have to git clone Plutus with autocrlf disabled:
git config --global core.autocrlf false
prior to cloning.

Another option is to clone using git inside wsl or Docker, which implicitly checks out with Linux line endings.

The automatic eol conversion seems to mess something up. No clue what exactly. See [here](https://github.com/input-output-hk/plutus/issues/2983) for details.

As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

The proposed solution works.


text:
Week 4 issue with Cabal build: Not in scope: type constructor or class 'JWT.EncodeSigner'
When running cabal build or cabal repl in the core/week04 folder I get the following error message when building the playground-common-0.1.0.0 package:
src/Auth.hs:130:41: error:
    Not in scope: type constructor or class 'JWT.EncodeSigner'
    Module 'Web.JWT' does not export 'EncodeSigner'
    |
130 |         { _configJWTSignature       :: !JWT.EncodeSigner
    |                                         ^^^^^^^^^^^^^^^^

I am in the correct branch in the plutus-apps repo as per the cabl.project file in code/week04. I've run cabal update and it was successful.
Does anyone have any ideas how to resolve this?

Do you run cabal from nix-shell?

yes, I do. It appears the issue was that I ran nix-shell under an old commit (for week 3) and restarting the shell after the commit was changed allowed cabal build to run

Be sure to do a git pull for both 'plutus-master' and 'plutus-pioneer-program'.
Then set the right git-checkout tag (of the week's cabal project file)
Restart nix-shell so it builds the 'plutus-master', after that you can do the following to resolve missing dependencies in the 'week' folder:

cabal clean
cabal update
cabal build
cabal repl

This should work

Thanks, the key here for me was to restart the nix-shell. Once I did this everything flowed as expected.


text:
Error running plutus-playground-client in Linux
I have successfully installed nix, cabal and have setup the IOHK binary cache. I cloned the plutus-app repository and successfully built the Haskell packages and other artifacts with nix. Then running nix-shell successfully I get into the nix-shell prompt:
[nix-shell:/home/datapool/plutus-apps]$

I then issue the following commands:
[nix-shell:/home/datapool/plutus-apps]$ cd plutus-playground-client
[nix-shell:/home/datapool/plutus-apps/plutus-playground-client]$ npm run start

I then get this output:
> plutus-playground-client@1.0.0 start /home/datapool/plutus-apps/plutus-playground-client
> plutus-playground-generate-purs && npm install && npm run install:spago && npm run build:webpack:dev

 /nix/store/ry2hywgh6cmmm9d5b9566nxdskd752yc-plutus-playground-generate-purs/bin/plutus-playground-generate-purs: line 6: /bin/plutus-playground-server: No such file or directory
 npm ERR! code ELIFECYCLE
 npm ERR! syscall spawn
 npm ERR! file sh
 npm ERR! errno ENOENT
 npm ERR! plutus-playground-client@1.0.0 start: `plutus-playground-generate-purs &&
 npm install && npm run install:spago && npm run build:webpack:dev`
 npm ERR! spawn ENOENT
 npm ERR!
 npm ERR! Failed at the plutus-playground-client@1.0.0 start script.
 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

 npm ERR! A complete log of this run can be found in:
 npm ERR!     /home/brightchip/.npm/_logs/2022-01-12T13_05_31_245Z-debug.log

As the output says, it seems to be looking for a non-existent /bin/plutus-playground-server.
Same problem when I run the server:
[nix-shell:/home/datapool/plutus-apps/plutus-playground-client]$ plutus-playground-server
plutus-playground-server: for development use only
/nix/store/fm77y43lzpgnay4pyc48jwpln0lnmrk3-plutus-playground-server/bin/plutus-playground-server: line 10: /bin/plutus-playground-server: No such file or directory

Any idea what I might be missing or how to debug?

Looks related to an issue I ran into where the directories were missing.
I needed to git checkout a patch.
Possible solution - https://cardano.stackexchange.com/a/6251/6004
The instructions are at :
https://tutorials.cardanoacademy.io/plutus-pioneer-program/setting-up-plutus-playground/cloning-plutus-repository

Thanks. The patch works:
git checkout 3746610e53654a1167aeb4c6294c6096d16b0502

I don't know exactly why, but doing this fixed it for me:
# In the plutus-apps folder
GC_DONT_GC=1 nix-build ./default.nix -A plutus-apps.haskell.packages.plutus-playground-server.components.exes.plutus-playground-server
# That will build a bash script somewhere (in store)
# edit that file located in this path:
whereis plutus-playground-server
# replace subshell (in Line 10) with the path from last nix-build command
# edit the file from this path: /nix/store/*-plutus-playground-generate-purs/bin/plutus-playground-generate-purs
# replace subshell (in Line 6) with the path from last nix-build command
cd plutus-playground-client
nix-shell
plutus-playground-server

Source: https://github.com/NixOS/nix/issues/4246#issuecomment-738888246


text:
How do you deploy ready made AI on chain
I have made a bunch of trading bots using python and tensorflow. How do I deploy this stuff on the chain with Plutus?
Is this the approach taken by Dr Ben Goetzel at SingularityNet or do they run it locally and only use the smart contracts for payment?

I have done that as well for Kucoin Binance etc python is great for backend data analisis... Well.. BlockChain are just transactions...  you should be able to do a BlockChain a transaction from your backend current running bot and give data to your bot from a service like Blockfrost... also.. what you buy and sell should be locked funds in smart contracts, for exqample liquidity pools from sundae Swap...  :)  the buy and sell transactions should be tx with smart contract interactions.

I am not very knowledgeable when it comes to AI, but I'm pretty sure right now it's impossible to have one on-chain for two reasons. First, it would be too computationally heavy, so the current CPU and transactions size limits would be reached. Second, there are no modules that allow this on-chain.
Plutus has a very limited number of types and functions allowed inside the on-chain validator, which certainly doesn't include tensor-flow or any AI related libraries.
Personally, I don't know how Singularity Net is doing, but I suppose they are doing this work off-chain and using oracles to communicate the results on-chain.
If you want to learn about oracles and how to deploy plutus smart-contracts, the best resource right now is the Plutus Pioneers Program. The third cohort already started, but you can watch the lectures on youtube and do the homework cloning the github repository.

Im already in the 3rd cohort but they don't seem to cover this.

They talk about oracles in week06, at least they did in the second cohort

Thanks that should be this Thursday then


text:
Contract deployment in week03 is failing with "beneficiary signature missing"
When running the grab.sh script the following error occurs:
./grab.sh
Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with:
The Plutus script evaluation failed: An error has occurred:  User error:
The provided Plutus code called 'error'.
Script debugging logs: beneficiary's signature missing
PT5

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

Turns out I was using the wrong vesting.addr - so the gotchas here were

NEED TO "cabal repl" after updating the deploy.hs
get the correct vesting.addr and use it in the give.sh and grab.sh

The warning signs for if you've used the wrong vesting.addr is that you see a whole bunch of erroneous ones in the TxHash of the script address.  There should only be one!

I have spent a full day on this same issue! Drove me around the bend until I saw this post of yours. So thanks a million!  I don't know how to 'like' your answer in here - but huge kudos to you!
For others with the same issue, all I had to do in the repl after updating and saving the Deploy.hs was a :r to reload Deploy.hs. Major lesson learnt. Always :r before running anything. I then ran writeVestingValidator in the repl to create the vesting.plutus script file. I then, from the nix-shell, used cardano-cli query utxo --address $(cat vesting.addr) --testnet-magic 1097911063 and saw the contract address stiing there with no (zero, empty) utxos present. I then ran the give.sh and waited about a minute before I found my utxo in my contract (vesting.addr) at cardano-cli query utxo --address $(cat vesting.addr) --testnet-magic 1097911063. I copied the TxHash from this newly created utxo in at the vesting.addr to update the grab.sh file. Saved it, ran it, and FINALLY found my gift utxo sitting in my wallet 2 addr.


text:
English Auction Compilation Failure. Need help understanding the compile error message
I need help.
Followed the lecture up to the compile.
Got this failure :
ConnectionError (HttpExceptionRequest Request { host = "localhost" port = 8080 secure = False requestHeaders = [("Accept","application/json;charset=utf-8,application/json"),("Content-Type","application/json;charset=utf-8")] path = "/runghc" queryString = "" method = "POST" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 proxySecureMode = ProxySecureWithConnect } **ResponseTimeout)**

UPDATE: Since the message appeared to me to be a timeout issue (I'm a mainframe programmer so I'm crash coursing on understanding thrown error messages on this paltform), I took a chance and simply re-submitted my compile.
It has now compiled SUCCESSFULLY!! Woohoo. I need small successes like this every now and then to keep the hope alive and trudge on.

You should accept your own answer.


text:
What tools are currently available or in development, to watch an address, and expose a bad actor that without authorization took ADA from a wallet?
Despite that the legitimate owner of a given amount of ADA in a wallet went loose on keeping hxs account secure, and the saying "No your keys no your ADA", when a bad actor takes ADA not authorized by the ADA owner, the bad actor has to use one of his wallet's receiving addresses. This is an immutable fact that will stay forever in the blockchain.
Using tools like Cardanoscan.io for example, one can trace and watch that wallet to see what other information has on it, * what transactions have occurred, * what is on each transaction, - i.e. NFTs-, to what pool it is delegating to, what have been purchased with that ADA, or if nothing has been done with the ADA, then watch it closely.
Additional Tags: Reputation. Bad-Actor

the bad actor has to use one of his wallet's receiving addresse

This is not completly true, there are tools called "mixers", that obfuscates the destination address of transactions.
This will make really difficult to understand in which wallet they arrive.
Also another related point is the fact that, if the attacker did everything good, it will be difficult to trace his identity and then to persue him legally.
In any case, it would also be impossible to restore the funds without the attacker's private key, so it is better to focus on how to keep a wallet safe instead of try to trace funds that are already lost and can't be restored (this is just my opinion).

you have a valid point on focusing in keeping a wallet safe; still, even if the funds cannot be recovered, it is always worth to explore options that clear the road for authorities to persecute this type of attackers. I appreciate your response.

Regarding tools, well there are in random order:

https://cardanoscan.io/ (like you already mentioned)
https://explorer.cardano.org/
https://cexplorer.io/

And soon a light wallet: https://lace.io
But I think the use-case of bad actors was never the main goal of any of those products. But any of those websites could maybe help you.
In any case, store your crypto safe. Use a hardware wallet.

Thanks @Melroy van den Berg. Yes, a cold wallet is the go to for safety.


text:
CLI creating a paper wallet
Is a paper wallet the same as doing.
$ cardano-wallet recovery-phrase generate > recovery-phrase.txt
$ cardano-wallet wallet from-recovery-phrase
$ cardano-wallet address list | grep_first_unused.sh | QR_code_generator.sh > wallet_qr.png
$ print_to_paper.sh < wallet_qr.png
$ print_to_paper.sh < recovery-phrase.txt

Or is there more to it than that? I have heard people talk about it but could not find the feature in the latest Daedalus.
Paper wallet as discussed by Charles here: https://www.youtube.com/watch?v=JwhB2YKYFKs&t=1s

It depends on what you mean by "paper wallet". If you want to generate a 24 word mnemonic in secure, ultra-cold fashion, you'd need to use cardano-cli in conjunction with cardano-wallet on an airgapped machine.
If however you do not require something as sexy as a 24 word mnemonic, you can just use cardano-cli address key-gen on an airgapped machine and write down the cborHex of the skey on paper.

Ok yeah I just tried the commands air-gapped. Works like normal, interesting. So you could share an airgapped address with somebody and it will just work?
Oh I changed the command from address create to address list.

Yes, when you key-gen on an airgapped machine, whatever addresses you then build using the created vkey can be accessed/authorized with the associated skey.


text:
Ensure a unique policy ID for a "time before" type minting policy
Let's suppose I am starting an NFT project, and I choose to use a time-lock based policy script.  For example, the policy is enabled until some slot in the future.
E.g, here's the Hosky Cash Grab NFT script, which is open until slot 112500819.
{
  "type": "all",
  "scripts": [
    {
      "keyHash": "4d04380dcb9fbad5aff8e2f4e19394ef4e5e11b37932838f01984a12",
      "type": "sig"
    },
    {
      "slot": 112500819,
      "type": "before"
    }
  ]
}

When you calculate the Blake2B hash of the policy script serialized to bytes, you get a policy ID, e.g. a5bb0e5bb275a573d744a021f9b3bff73595468e002755b447e01559.
If another project happens to choose the same slot for their required-time-before policy and generates the same script or they simply choose to use the same script, won't they also have the same policy ID? This seems like a bad outcome, since I assume that querying the NFT assets minted under the policy ID could potentially show NFTs from another project.  Am I correct about this?
As a related question, I understand that projects may register a policy ID for their project in a github repo Cardano-NFTs/policyIDs.  What protection or value does registering offer?

They will also have to come up with the same keyHash to have the same policy ID, and that is virtually impossible.


text:
Is there a Ganache-like in Cardano?
Currently, I have been playing around with the Cardano Playground and I was wondering if there is an existing tool already present where I can personally run a Cardano blockchain like Ganache of Ethereum blockchain?
Regards,
Ivan

Plutus playground simulates the working of a blockchain. Testnet with smart contract feature is expected before end May

Yes?
In the lecture #4 of the current Plutus Pioneer program, there's a way to run a faux blockchain with Plutus contracts.  The first 90 minutes are a Haskell tutorial, but then it goes into how to use the EmulatorTrace.
It's not a full testnet, so it might not be a full replacement for Ganache (which I haven't used), so maybe No.