text:
Which API can give the buy price and sold price of NFT of cardano blockchain?
I am working on Cardano NFT tool kit, which basically shows the NFT's owned by a user. The tool kit shows the various information about NFT stored in wallet like (Buy Price, Sold Price, Rarity, Holding period, Floor price) apart from this some other data like (Policy Id, FingerPrint, Collection name, Asset name, Image IPFS link ). I have tried to get this data from Wallet address ...first using (https://cardano-mainnet.tangocrypto.com/{app_id}/v1/addresses/{address}/assets) which gives me policyId , fingerprint , asset name and these data from first API that i have got used in the all other API's. Second using (https://api.opencnft.io/1/asset/{asset}/tx), third using (https://api.opencnft.io/1/asset/{asset}) and **fourth using (https://api.opencnft.io/1/policy/{policy}/floor_price) which gives. But these all  process in taking too much time to fetch the data.
So, is there any particular api which can give all these data or any solution for this?

My first thought was to go to https://blockfrost.dev/. Here is their API documentation: https://docs.blockfrost.io/. You'll need an API key, but for limited use you can get one for free and test out your scenario.
You can initially get the asset history.
curl -H "project_id: 123456" https://cardano-mainnet.blockfrost.io/api/v0/assets/ad79da159614ff55130b3a28189fbe5c429c0dfc1c0aeaf94a1de95e4b6964646f7330373138/history
[{"tx_hash":"79b99a605b46603dbeefefab83bc72dfc241dafd1236504014732d6c3d3a5195","action":"minted","amount":"1"}]

Grab the transaction hash(s) and then run
curl -H "project_id: 123456" https://cardano-mainnet.blockfrost.io/api/v0/txs/79b99a605b46603dbeefefab83bc72dfc241dafd1236504014732d6c3d3a5195

That will give you a lot of details you won't need, but you can look at output amount:
    "output_amount": [
        {
            "unit": "lovelace",
            "quantity": "19809463"
        },
        {
            "unit": "ad79da159614ff55130b3a28189fbe5c429c0dfc1c0aeaf94a1de95e4b6964646f7330373138",
            "quantity": "1"
        }
    ],

Here you can see that 19809463 lovelace (or 19.8094630 ADA) was spent on unit ...330373138. This is the first transaction, so we might assume this was the purchase price. The same goes for the sold price. If you want the latest sold price, use the latest transaction hash from the /txs api call. Or loop over each to get the price history.
Use whichever language you want for the curl calls, and loop to process the transaction data. Here's a little javascript to grab the tx_hash.
fetch('https://cardano-mainnet.blockfrost.io/api/v0/assets/ad79da159614ff55130b3a28189fbe5c429c0dfc1c0aeaf94a1de95e4b6964646f7330373138/history', {
   headers: {
      'project_id': '123456'
   }
})
   .then(response => response.text())
   .then(text => console.log(JSON.parse(text)[0].tx_hash))


text:
Week02 Homework 1
I am getting type mismatch when I use traceIfFalse. What could be be reason? And how could I get this resolved. I also noticed that it didn't fail while I build lecture examples.

Couldn't match expected type PlutusTx.Builtins.Internal.BuiltinString' with actual type [ghc-prim-0.6.1:GHC.Types.Char]'

In the first argument of traceIfFalse', namely "expected boolean True"'
In the first argument of ($)', namely traceIfFalse "expected boolean True"'
In the expression:
traceIfFalse "expected boolean True" $ (boolx == True && boolx == booly)
|
19 | mkValidator _ (boolx, booly) _ = traceIfFalse "expected 42" $ (boolx == True && boolx == booly)

You need to use the OverloadedStrings Haskell extension.
Add {-# LANGUAGE OverloadedStrings #-} to the top of your file.

source: Stack Exchange

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

sort: votes


text:
Can I communicate with my local test net via REST/WebAPI
I am using this https://github.com/woofpool/cardano-private-testnet-setup to run my local testnet.
I was using this
const CardanocliJs = require('cardanocli-js');
const cardano = new CardanocliJs(options);
const txinds = cardano.queryUtxo(walletAddress);

But now I want my script to run on a different machine than the node and because cardanocli-js use cardano-cli and cardano-cli use cardano-node it's impossible
Note:
The script and the machine will not keep any private keys. The script will generate transactions based on some parameters.
In most protocols, Nodes have rest api, but I can't find anything like that in cardano.
Should I start this on the same machine as Cardano node in order to achieve my goal? https://github.com/input-output-hk/cardano-graphql
Or maybe some other tool from the cardano ecosystem?

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


text:
Daedalus synch problem
Not always, but very often the Daedalus wallet seems to synchronize completely again. Shouldn't the downloaded blockchain be permanently on the computer and then only the missing rest be synchronized?

I'm not sure what your specific use case is, and maybe you just want Daedalus, but I would recommend not using it. While being a full node, it doesn't serve much purpose for network integrity.


text:
Minting with MESH - Error Missing key witness for: 1e101f14d
Having an issue trying to mint an NFT with my own policy. It's throwing the error below:
Missing key witness for: 1e101f14d07f203b01f8.....
I am not sure what to do here and any assistance would be appreciated. Long time developer, short time developing on Cardano.
Here is my code:
const nativeScript: NativeScript = {
  type: 'all',
  scripts:
  [
     {
      type: 'sig',
      keyHash: '1e101f14d07f203b01f89d1562831374f....'
    },
    {
      type: 'before',
      slot: '317614504'
    }

  ]
};

const forgingScript = ForgeScript.fromNativeScript(nativeScript);

const { wallet, connected } = useWallet();
const [txHash, setTxHash] = useState<string | null>(null);
const [loading, setLoading] = useState<boolean>(false);

 const wallet_for_mint = new AppWallet({
    networkId: 1,
    fetcher: blockchainProvider,
    submitter: blockchainProvider,
    key: {
      type: "mnemonic",
      words: [
    'tenant',
....
      ],
    },
  });

 const assetMetadata1: AssetMetadata = {
      name: "ASSETNAME",
      type: "TYPE1",
      item: "FLAG",
      image: "ipfs://Qmb18wvCu.....",
    };

    const asset1: Mint = {
      assetName: "TESTASSET",
      assetQuantity: "1",
      metadata: assetMetadata1,
      label: "721",
      recipient:

      "addr.........e",
    };

    const txMint = new Transaction({ initiator: wallet_for_mint });
    txMint.mintAsset(forgingScript, asset1);

    const unsignedTxMint = await txMint.build();
    const signedTxMint = await wallet_for_mint.signTx(unsignedTxMint);
    const txHash = await wallet_for_mint.submitTx(signedTxMint);

Is this all the code? Where do you set the witness count?

Hey. Thanks for the reply. That is all the code. I dont see in the sample code where the witness count is set.

It appears that you need to call one of the signature methods from ForgeScript. In most of the examples, they use ForgeScript.withOneSignature(address). However there are multiple options:

withOneSignature
withAtLeastNSignatures
withAnySignature
withAllSignatures

This looks like it needs to be done before your call to ForgeScript.fromNativeScript(nativeScript). This might set the witness count in some way.
"The --witness-count 1 basically tells cardano-cli that there will be only 1 signing key required for this transaction to be valid. Since the UTXO input involved in this transaction will only be coming from payment1 wallet, so that means we indeed only need 1 key to sign the transaction."
https://developers.cardano.org/docs/integrate-cardano/creating-wallet-faucet


text:
Can anyone provide an easy to understand script that sends ADA using the Cardano Serialization Lib?
new to coding here. (obviously)
I am looking to understand how this works, and I am sure if I physically see the code I will pick up on it quick.
I am looking for a very simple script that sends ADA to a specified address when a user clicks a send button, preferably in PHP. I already have connect to wallet working on my site, I am just incredibly lost on sending ADA.
Thanks in advance.

To get started with the Cardano Serialization Lib, have a look at their examples (with code) in the Cardano Developer Portal: https://developers.cardano.org/docs/get-started/cardano-serialization-lib/generating-transactions
That being said, there are more high level libraries nowadays that make building transactions a lot more simple than using the Cardano Serialization Lib.
Edit: You don't even need to have any backend (server side code like PHP) if you just want to send some ADA from the users wallet to some other address.
You could use a JavaScript library that gets the UTXOs from the wallet-connect API, builds the transaction and submits it using the wallet-connect API.
See for example this: https://developers.cardano.org/docs/get-started/cardano-serialization-lib/generating-transactions

Looking at: https://developers.cardano.org/docs/get-started/cardano-serialization-lib/generating-transactions
I need guidance on how to insert this into a php page, so the user clicks a button to make this transaction take place. The link is just code, there needs to be an action for this code to take place. Am I missing something?

PHP code is executed on the server. I'm not aware of any PHP port of the serialization lib. This simple use case of sending ADA from the user wallet to another address can be done completely in the browser (using JavaScript). Therefore I suggested that you could use MeshJS. You would import the library in your HTML and then you can add a button that calls a JavaScript function. This function creates the transaction and submits it through the wallet in the users brwoser.

"This simple use case of sending ADA from the user wallet to another address can be done completely in the browser (using JavaScript)." Can you show me an example of this code working in Javascript?

Some examples using the MeshJs library can be found here: https://developers.cardano.org/docs/get-started/mesh/transactions-basic


text:
Need to access documentation for Plutus.Contract.Oracle but not available in https://input-output-hk.github.io/plutus/master/
Playground is discontinued but the updated documentation seems to be lacking in components that I have been working with.
I did try to look up the other versions they have listed in their gh-pages repo here https://github.com/input-output-hk/plutus/tree/gh-pages but those pages also don't seem to have those
Any idea how I can access the old documentation I have tried the way back machine as well but it doesnt have those pages cached

If you're talking about the Haddock documentation, it moved here (for plutus-apss) and there (for plutus).
Some modules are still missing in the plutus-apps repo, we're working on it.

Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.


text:
Is it possible to obtain the cbor hex/script bytes from a bech32 script address?
I would like to get the script bytes from the bech32 address of a script. Is this possible?

To expand on the previous answer, you can use https://docs.blockfrost.io/#tag/Cardano-Scripts/paths/%7E1scripts%7E1%7Bscript_hash%7D/get endpoint and a TypeScript conversion function from here https://github.com/blockfrost/blockfrost-utils/blob/40964699913a54417371c63739e6d0c19712dca1/src/validation.ts#L220-L235

From some indexer, yes as it is common to support fetching script's information from it's hash. Here is an API endpoint for Blockfrost.
To obtain script's hash from its bech32 encoded address, you would first need to decode this bech32 encoding and then remove the 1 byte header (see CIP-19).

While all answers are insightful, here is an example that makes it possible to entirely get the jpg.store script bytecode from just its script hash obtained from the bech32 address, using the pycardano and python-blockfrost libraries:
from pycardano import (
    BlockFrostChainContext,
    Address,
    PlutusV2Script
)
import cbor2
from blockfrost import ApiUrls

# ------- Chain context
chain_context = BlockFrostChainContext(
    project_id="mainnetslL7jFzg8p4Hxk8pcJCRIcWvcM6P6FZE",
    base_url=ApiUrls.mainnet.value
)
jpg_store_addr = Address.from_primitive("addr1zxgx3far7qygq0k6epa0zcvcvrevmn0ypsnfsue94nsn3tvpw288a4x0xf8pxgcntelxmyclq83s0ykeehchz2wtspks905plm")
script_hash = jpg_store_addr.payment_part
script_cbor = chain_context.api.script_cbor(str(script_hash)).cbor
script_bytes = PlutusV2Script(cbor2.loads(bytes.fromhex(script_cbor)))
print(script_bytes.hex())  # equals jpg.store script bytecode as shown on cardanoscan

Thought I'd give some context for others who might come across this.
The short answer:
No, you cannot derive it directly because the script address only exposes the script hash.
You can however find it using tools like this Blockfrost endpoint
Long answer:
Cardano addresses are made up of 3 parts; a header, payment part, and a delegation part.
   addr1  zxgx3far7qygq0k6epa0zcvcvrevmn0ypsnfsue94nsn3tvpw  288a4x0xf8pxgcntelxmyclq83s0ykeehchz2wtspks905plm
| header |                  payment part                    |                 delegation part                 |

If you decode to Hex you get
    11     9068a7a3f008803edac87af1619860f2cdcde40c26987325ace138ad  81728e7ed4cf324e1323135e7e6d931f01e30792d9cdf17129cb806d
| header |                      payment part                       |                     delegation part                     |

The payment part in the above tells a node how to validate the transaction:

Either it is a pubkeyhash from a wallet, in which case the node checks for that wallets signature
Or it is the hash of a script, in which case the node checks for an attached script and executes it

This means that the only information you know from a script address is the hash of the script, and there is no way to directly derive the script bytes from this due to the nature of hashing
If you use a tool like the Blockfrost endpoint above to get the script, you must provide the script hash which you can get from the payment part of the HEX representation of the address.


text:
After transaction, how to display Transaction ID?
After signing a transaction (using Lucid), how can i display the transaction id?

Nevermind, I figured it out.
// Display success message with transaction ID as a link
const transactionLink = 'https://cardanoscan.io/transaction/' + txHash;
successMessageDiv.innerHTML = 'Success! Transaction ID: ' + txHash + '';


text:
How to display all of the tokens in connected wallet?
Looking for a way to display the tokens (and values if possible) in a connected wallet using serialization or any other method. Really scratching my head on this one.
Thanks!

Which wallet are you using?

Whatever wallet works? I just need the code to display tokens and ill make it work in my script.

You can use the Koios - Account Assets API endpoint for this.


text:
Force include wallet optional message?
Is there any way to force a message along with the payment using Lucid, or any other js payment? I am trying to tie an order number along with the transaction.
thanx.

You can include the order number as metadata.
https://lucid.spacebudz.io/docs/getting-started/make-payments/#send-ada-with-metadata


text:
How add many metadata
I want mint nft with many metadata?
https://meshjs.dev/apis/transaction/minting

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

Below is the example from the page you referenced, but with additional metadata fields attached. You can create your own custom metadata fields on the asset this way.
const assetMetadata: AssetMetadata = {
  "name": "Mesh Token",
  "image": "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
  "mediaType": "image/jpg",
  "description": "This NFT is minted by Mesh (https://meshjs.dev/).",
  "custom1": "Your custom value 1",
  "custom2": "Your custom value 2"
};
const asset: Mint = {
  assetName: 'MeshToken',
  assetQuantity: '1',
  metadata: assetMetadata,
  label: '721',
  recipient: 'addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr'
};
tx.mintAsset(
  forgingScript,
  asset,
);


text:
Using cardano-wallet with Plutip local cluster
I have to test integration Cardano with out services (written in c#, so I am totally noob in Haskel).
So I have built Plutip local cluster insing Nix and now  I can run Plutip local cluster in such a way:
/home/docker/plutip/result/bin/local-cluster \
  --wallets 3 \
  --wallet-dir /home/docker/cardano-data/wallets \
  --working-dir /home/docker/cardano-data/plutip \
  --ada 100000 \
  --utxos 5 \
  --dump-info-json /home/docker/cardano-data/local-cluster-info.json

Then try running cardano-wallet:
cardano-wallet serve \
  --node-socket /home/docker/cardano-data/plutip/pool-1/node.socket \
  --mainnet \
  --tls-ca-cert cert2/ca-cert.pem \
  --tls-sv-cert cert2/server.crt \
  --tls-sv-key cert2/server.key \
  --listen-address 0.0.0.0 \
  --port 8090 \
  --database /home/docker/wallet-db

And here is the problem: when I use --mainnet because Plutip generates funds for the mainnet network, then wallet tries to synchronise for an extremely long time.
When I run wallet with the --testnet /home/docker/cardano-data/plutip/genesis.byron.json option, the sync is very fast, but wallet gives me an address in testnetwork, so I have no idea how to transfer funds between plutus addresses and wallet ones.
Any ideas how to get them to work together, either in mainnet, or in testnet address pool?


text:
Cabal build all fail on M1
I want to add Cardano to Express project and followed the steps in documentation: https://developers.cardano.org/docs/get-started/installing-cardano-node/#macos. Unfortunately, “cabal build all” step failed after three hours of running.
I found a similar question on GitHub, it was advised to uninstall Libsodium, but I get an error for that as well(No such keg: /opt/homebrew/Cellar/libsodium).
Here is my terminal with the previous commands ran successfully:

Please see the failing final message:

Have you seen this:
https://github.com/input-output-hk/cardano-node/issues/3506#issuecomment-1089974749

Yes, I saw that post, but libsodium uninstall failed.
I posted a similar question on StackOverflow and provided the screenshot there.
https://stackoverflow.com/questions/76282227/cabal-installation-fails-on-m1

So I would think then that libsodium is not installed correctly

Welcome to the Cardano stack exchange! Please try to post your terminal output as text instead of images. Text can be found using the search or even search-engines like Google. With images this is not possible.


text:
Nami Wallet access
Cpu crashed,got new cpu, not able to send or receive in Nami wallet, no customer service email. How can I get customer service to Nami Wallet developers with no email available?

I'm assuming that you are referring to your computer with "cpu".
There is no customer support for Nami. You need your 24 words recovery phrase (that you wrote down when creating the wallet) to restore it. After doing this, you should see your funds and can use them as before.
You can find instructions on how to restore a wallet here: https://metaroids.com/learn/how-to-use-nami-wallet-full-guide/#How_to_Restore_Nami_Wallet


text:
Why does an cardano token have multiple policys
I stumbled upon Society token, in multi_assets table via cardano-db-sync it has 2 entries with same name but the meta data difference is minimal, as well they're fingerprints are different

policy = 25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c
name = 534f4349455459
fingerprint = asset1tpsewdtydk223j2tkx2wh09qptuyge638246u4

https://tokens.cardano.org/metadata/25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459

policy = 24ecd375f858e31b20ec8c16a19b2c4efededf66f1f994325c41dcc1
name = 534f4349455459
fingerprint = asset12sq05wm7ujttuzz5v7a3rulgw0zfy2j8e4uez6

https://tokens.cardano.org/metadata/24ecd375f858e31b20ec8c16a19b2c4efededf66f1f994325c41dcc1534f4349455459

How to acknowledge which of the entry is the correct one ?
Are we dealing with an copycat actually, that somebody has made the exact meta data entry?

When looking from https://cardanoassets.com/ we could see, it might be just an copycat

Probably they launched it with the wrong supply in the first place and then they launched the second one with 700M.


text:
How to stake NFT without locking?
I am developing NFT staking platform.
And I want not to lock the NFT while it is staked.
(Users can move their NFTs at anytime)
But to do so, I have some problems.
How to calculate the rewards for this NFT?
(I was planning to distribute my token: Native Token not ADA, to users for staking their NFTs.)
But what if the user once puts their NFTs on staking pool and then get it back to their wallet, and put it back again (to receive rewards)?
Can you help me to decide how to calculate the rewards fairly?
Thank you.

An easy way to do this would be to take a snapshot of the staked NFTs at the end of every epoch (or any other pre-defined timeframe). This would mean that the NFTs are not locked, but would have to stay staked for at least 1 epoch go generate rewards.
Or you could track every single NFT to see from when to when it was in the staking pool and only count that time for the rewards. This would require you to process all future transactions for all NFTs that enter your stake pool.

Thank you, very much.
This is really helping.
But I'd love to know more about it.
Can I discuss with you further?

Well, I have thousands of NFTs, and to track them is really heavy work.
Can you suggest me the way to take the snapshot easily?

Without knowing the implementation details of your app, it's hard to give detailed advice. But have a look at APIs like https://api.koios.rest/ or https://blockfrost.io/, those can give you a lot of blockchain data in a simple REST call.

Eddex, can we discuss further in DM? (Discord, Telegram?)

If you have specific questions, I'm happy to help you here on StackExchange.

Okay, Thank you. @eddex.
Here is my question.
I am now trying to distribute the rewards in my own Native Token (not ADA) to delegators to my pool with ADA AND my custom NFT.

To do so, I am going to take the snapshot of delegators and each delegator owns how many NFT.
But there are total thousands of NFTs, and I don't know how to do it efficiently.
Can you help me?

I don't think there is much you can do to improve the performance of this. Checking the amount of NFTs each delegator holds should not be too expensive. And even if it takes a while to execute this, it should not be a problem since it is not a time/performance critical task.


text:
How to monitor Cardano Minswap transactions using Blockfrost?
I was trying to monitor the swap actions
like who swapped which A to B Token, as real-time from Minswap platform.
I was using Blockfrost webhook for this, but I fetched lots of transactions including those (main swap transaction which are what I want).
The problem is that I couldn't filter them out of all transactions.
Can anybody help me with this issue?
Thank you.

I used a blockfrost api for this issue.
To be exact, blockfrost supports webhooks features which can be used as a hook to catch up certain cardano transactions.
So you can monitor Minswap Transactions (You know Minswap Order, Pool contract address).

@FiringDev would be nice, if you posted your solution here, so ppl can learn from it. thanks!

Try to look at the blockfrost-adapter from MinSwap.

I share my github code for this solution.
code


text:
How to verify signed Tx and signer's address?
I am building dApps on cardano, and I faced an issue.
I was trying to let the users sign message to verify them. (using signData method of wallet)
But signData method is not supported for ledger type wallet yet.
So I try to fix this using signTx method which is supported both for ledger and seed-phrase account.
And I got the signedTx (hex string) and the transaction string and
build the signedData like this.
const signedData = {
    signature: transaction string,
    key: signed transaction
}

And I tried to verify this in the same way I verify the signed message using
@emurgo/cardano-message-signing-nodejs
@emurgo/cardano-serialization-lib-nodejs

But I got error like this.
Deserialization failed in TransactionWitnessSet because: Invalid cbor: not the right type, expected Map' byte received Array'.

Can anyone help me with this issue?
Thank you very much.

The error you're seeing is related to deserialization. It suggests that the data format you're trying to read doesn't match the expected format. In Cardano, the data structures are often serialized using Concise Binary Object Representation (CBOR).
Here are some things to check:

Data Type Mismatch: Make sure that the data type of the signedData you're trying to deserialize matches what is expected. Your error message indicates that it's expecting a CBOR Map, but it received an Array instead.

Correct Libraries: Ensure you're using the right versions of the @emurgo/cardano-message-signing-nodejs and @emurgo/cardano-serialization-lib-nodejs libraries.

Method Mismatch: If you're trying to verify a signed transaction, make sure you're using the appropriate methods for transaction verification and not the ones meant for message signing.

Documentation and Examples: Check any provided examples or documentation to ensure you're using the correct data formats and methods.

It's hard to pinpoint the exact issue without more code or context, but checking these areas might help you resolve the issue. If I have to guess, you are giving it a string instead of array of bytes.


text:
How to take the snapshot of staking NFTs?
Last time I asked how to stake NFT without locking, and @Eddex gave me answer.
How to stake NFT without locking?
His answer is about to take the snapshot every epoch and track the NFTs so we can calculate the rewards according to the time, they are staked.
But if I have thousands of NFTs, this is really heavy work.
Can anybody suggest me the easy way to take the snapshot?
Or any other way to stake NFTs without locking and calculate the rewards.
Thank you.

How does your stake- and unstake-mechanism work? Where do you keep track of what NFTs are staked?

You can use an API such as blockfrost.io to fetch the data about the state of your NFTs at given time.


text:
Fetch rich cardano addresses?
I am building some dapps on Cardano network.
What I want to do is to

fetch cardano addresses whose balances are more than 1M ada.

Can anybody help me with this?
Thanks.

I see the tag blockfrost so I assume that is your tool of preference.
I believe the only solution using blockfrost would be performing a series of requests for every stake address to the "specific account" endpointand access the controlled_amount field.
you could get a list of all the addresses from a tool like koios: https://api.koios.rest/#get-/account_list
However, tools like blockfrost and koios are not meant for such queries;
What you are asking for is a snapshot of all possible addresses currently present on the blockchain; so what you likely want is to have your own cardano node and your own cardano-db-sync instance to perform these queries.


text:
Error: encoding/hex: invalid byte: s When using Lucid calling payToContract
I am getting an issue when creating a Lucid transaction and calling payToContract
I have created the datum and it is erroring on the line that converts this datum toHex
With the following error: Error: encoding/hex: invalid byte: s
This happens every time I run the logic,
Code to build the datum
onst deadline = Date.now() + 6 * 60 * 60 * 1000; // in 6 hours
const datum = new RequestDatum(
  new RequestMetadaDatum(
    ownerAddress,
    ownerAddress.payment_cred()!, // the owner whe can reclaim the request
    bigint.from_str(deadline.toFixed(0)), // deadline in posix time
    assetClassFromUnit('lovelace'), // the LP assets need to be ordered
    assetClassFromUnit(assetSubject)
  ),
  new SwapAction(SwapDirection.BTOA, bigint.from_str(minimumAmountTokenOut.toString()))
).to_plutus_data();

Transaction code
// Create a transaction that creates a swap request
const unsignedTx = await this._lucid
  .newTx()
  .payToContract(this._lucid.utils.credentialToAddress(this._lucid.utils.scriptHashToCredential(REQUEST_SCRIPT_HASH)), toHex(datum.to_bytes()), {
    lovelace: BigInt(lockedCoins.to_str()),
    assetSubject: quantityOfToken,
  })
  .complete();

This is an implementation using the Wingriders Blockfrost Adapter found here: https://github.com/WingRiders/dex-blockfrost-adapter/blob/main/examples/swap-fe-vanilla-js/src/swap.ts
Would appreciate any guidance here, thanks!

it's a bit hard to tell from where your error might come from, but your error simply means that you tried to use something that wasn't properly encoded in hex.
Therefore, the error message arises that the character s was read, but it's indeed not a valid character of a hex-encoding.
This problem often occurs for me, when I have forgotten to convert the name of a token from UTF-8 to hex.
This could also be the issue for you, i.e., you have a token starting with s in its name, and now you want to use the string encoded with utf-8 in, e.g., your datum. Instead, the token name should be converted to hex before using it as part of your datum.


text:
How to use lucid cardano with angular?
Lucid cardano import fails whatever way I try to add it to angular project. This is currently my best attempt, but still a failed one.
import {Blockfrost, Lucid} from "lucid-cardano";

    let a = await Lucid.new(
      new Blockfrost(
        "ApiAddress",
        "projectId",
      ),
      "network"
    );

I enabled custom webpack builder in angular.json:
      "builder": "@angular-builders/custom-webpack:browser",

and setup my "webpack.config.js" file like this:
module.exports = {
  experiments: {
    topLevelAwait: true,
    asyncWebAssembly: true,
    layers: true
  }
};

All according to the latest documentation:
https://github.com/spacebudz/lucid
But still I receive this error:

An unhandled exception occurred: ENOENT: no such file or directory,
scandir ''

I did it all on clear angular project. Please help.
What can I be missing?


text:
Adding stake credential to script address
I compiled my plutus script and generated a payment credential only address. The logic all working fine- no issues.
However when I add a stake credential to my plutus script address, the logic starts to fail. I have tried with PKH and Script hash staking credentials. Even tried using a stake credential created with an always succeeds withdrawal validator.
Anyone know whats going on?

some actual code of the contract would help understand the issue better.
The error you describe suggests you are doing some checks for the script address (which is formed by payment credentials + optional staking credentials)
if you are checking for equality with an address built at contract runtime
(something like PCredential.PScriptCredential({ valHash: ownHash }) in plu-ts)
then you are checking for the address to be strictly equal to the one without any stake credentials.

A simple way to generate such an address is by using Eternl.

Go to https://eternl.io/
Open Settings (gear icon in the bottom left)
Open "Franken Address Generator"
Enter your script and stake address parts and generate

Hope this helps. Otherwise please add an example of what you already tried and provide more details on the error you get.


text:
How to get ALL used addresses of a Daedalus wallet (byron era) with cardano-cli
i'm looking for a way to get ALL used addresses of a Daedalus wallet (byron era) with the cardano-cli.
Background:
Daedalus is not showing up the used addresses combined under a "Recieve" tab, like it does for Shelly wallets. One can only click through all transactions an guess what addresses belong to the wallet. This is pretty time consuming and error prone, especially when there are transactions with multiple out-/inputs.
My hope is, to utilize the cardano-cli for that purpose. I already managed to install the cli and set it up to use the Daedalus socket. But further i didn't come. Can someone please hive me a hint where to start.
Thanks for any tips!

This is not possible directly using the cardano-cli. You can use a third party tool to do this, like blockfrost.
A simple curl command using your free project id would look like this.
curl -H "project_id: REPLACE WITH YOUR PROJECT ID" https://cardano-mainnet.blockfrost.io/api/v0/accounts/REPLACE WITH YOUR STAKE ADDRESS/addresses

thanks for your answer, but byron era wallets don't have a staking address.


text:
Is there a standart way to sync off-chain metadata (assets, tokens, mints) like cardano-db-sync does with on-chain data (epochs, blocks etc)?
I have running cardano-node-ogmios:v5.6.0_1.35.5 in couple with cardano-db-sync:13.1.0.0 (docker-compose.yml) and looking for the solution to sync off-chain assets localy. Is there any standart solution for that?
I've noticed that some assets (27200 items) have been copied localy to postgres database by service cardano-graphql-background:8.0.0 but have no idea why only 27200 assets and either I can copy more assets using this service?
I would greatly appreciate any help.


text:
Different types of Datums
I have a good understanding of the role of Datums in Cardano's Extended UTXO model, including their use in representing the state of a smart contract. However, I'm seeking further clarification on the different types of Datums that can be used, such as inline and hashed Datums. Could someone elaborate on the various types, their specific uses, and the considerations for choosing between them in the development of smart contracts?

The Inline Datum was introduced with the Vasil Hard Fork (https://cips.cardano.org/cips/cip32/). Before this, only using a Datum Hash was possible. Using a Datum Hash is more difficult for a decentralized application, because the Datum has to be shared off-chain between all parties who are doing transactions.With Inline Datums, it becomes a lot easier, because the Datum is visible on-chain.

There is another point here as well, in addition to George's. The addition of "reference inputs" (https://cips.cardano.org/cips/cip31/) also means that it is possible to use datum without spending the corresponding UTxO, as was necessary before.  This also expands the use-cases and makes dealing with (for example) concurrency and shared state easier.

This is also how the Oracles in Cardano are working, they publish their information in a Datum, which can be used (as a reference input) multiple times by different DApps.


text:
How to handle sensitive data in smart contracts?
I'm interested in creating an escrow smart contract using Plutus, where a seller stores an encryption key in the Datum and sells it for a price. The key should only be accessible to a buyer who pays the required price. Considering that data in the Datum is publicly visible on the blockchain, what strategies or methodologies could I use to securely store and transfer sensitive information like this within the constraints of Cardano's smart contract model?

Storing secrets on the blockchain is not possible. Also, transferring secrets is not advisable because doing it via blockchain means publishing it to everybody.
For any real world scenario, I can think of, this makes the blockchain unsuitable for this type of transactions.
Now, if you are fine with the blockchain only playing the role of witness, i.e. a ledger showing that a secret has changed owner, than you can implement a protocol that treats the hash of the secret as the value to be transferred. The actual secret would need to be transferred off-chain. Any dispute could use the blockchain as proof-of-transaction though.
You can take it one step further and implement the messaging channel for the transfer of the secret on-chain. You could have the buyer publish single-use public encryption keys that the seller uses to encrypt the secret. The encrypted secret would then be pushed to the blockchain in a transaction. With this solution, you can of course not prove on-chain that the actual secret that corresponds to the hash was published in the transaction. But in case of dispute, both parties could have the transfer of the secret verified by an arbiter to whom the buyer would disclose the private key corresponding to the used public key.


text:
Decoding transaction redeemers to JSON
I need to decode a redeemer hash (such as c4f0f65e1a03560608800ab884a2ed37377361e64462d14645610ac88b4aebd3) to the readable JSON format, just like cexplorer does, preferably using Javascript/Typescript. Tools such as cardano-cli are not an option.
How is the redeemer encoded anyway? I was unable to find a clear definition of what this hash exactly is, which makes it difficult to find information on decoding...

A hash is the product of a one way function. It is not possible to decode the redeemer hash.
The redeemer itself is stored onchain inside the witness set of the transaction, see cddl spec (rfc8610). This also shows you how plutus_data is encoded.
Explorers such as cexplore obtain this information using a chain-index service which stores transaction data for efficient querying such as db-sync, kupo or marconi.

That is really helpful to know! I was unaware that the redeemer hash not what contains the data but I guess it's in the name (hash is data one way encoded).


text:
How to get data based on Block-Height?
in EVM we can call any read-only function and pass it a block_height we would want the data to be returned on.
for example if I wanted a pool's liquidity at block height 999999, i would call that liquidity function and pass it the blockheight .
contract.liquidity({ blockTag: 999999 })
is there something equivalent on cardano?


text:
which programming language is predominantly used for writing smart contracts in Cardano now?
I am a newbie to blockchain in the Cardano ecosystem. I have been exploring the Cardano documentation, which mentions various programming languages for writing smart contracts on the platform.
How do I determine the appropriate programming language for my Dapp?
Currently, which programming language is predominantly used for writing smart contracts and has been widely adopted in production on Cardano now?

The main programming language used to date is still Haskell.
Whether based on the GHC plugin "PlutusTX" by IOG (the first "smart contract language" released for cardano) or based on "Plutarch" (the second one, which is an eDSL in Haskell)
Despite that, new languages such as Aiken, plu-ts, OpShin are gaining momentum.
To determine which one is the one for your dApp it strictly depends on what you are more comfortable with
(eg. if you prefer typescript you'll go with plu-ts; if you prefer python you'll go with OpShin, and so on).
Keep also in mind that most of your dApp will likely be offchain code (transaction creation), and the smart contracts will only be needed to validate those transactions.

If you are interested in learning about Cardano I can highly recommend the course at plutuspbl.io it's a project based learning environment and covers PlutusTX, Aiken etc (and it's free)


text:
Catalyst App still showing Fund9 instead of Fund10 and connection in progress as of 26/6/2023
The Catalyst App has not been updated since 2022 and gives only information about Fund9 as of June. When will the Fund10 voting round be available in the app and my wallet registration completed?

Same question asked here (but with an answer):
https://forum.cardano.org/t/fund-10-registration/117712/5


text:
Is it possible to generate secp256k1 addresses?
CIP-0049 introduces the secp256k1 elliptic curve to Cardano in order to provide the corresponding ECDSA/Schnorr signatures as primitives. What I don't understand about this is whether those primitives are restricted to be used in smart contract or if I can have a simple address generated from a secp256k1 public key.
Note: I'm new to the cardano ecosystem, so I apologize if I misused some concepts or terms.

SECP256k1 is currently just the verify functions for ECDSA/Schnorr signatures in a plutus script (smart contracts). Cardano uses ed25519 for its payment key pairs that addresses are derived.


text:
Find contents of a address from script context
I’m trying to find if a particular address submitting a transaction contains a NFT.  Not necessarily the transaction itself but the address in general contains the NFT.  I was looking at using TxInInfo but I believe that only contains inputs of the transaction itself.  I also looked at the TxOut but that is the outputs of the transaction.  Here is an example of what I was trying
{-# INLINABLE testMintingScript #-}
testMintingScript :: NFTInfo -> () -> ScriptContext -> Bool
testMintingScript nftInfo () ctx = traceIfFalse "Didn't find NFT" tokenInOutputs
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    ownOutputs :: [TxOut]
    ownOutputs = txInfoOutputs info

    tokenInOutputs :: Bool
    tokenInOutputs = any (\x -> assetClassValueOf (txOutValue x) (AssetClass (policyIdNFT nftInfo, tokenNameNFT nftInfo)) > 0) trythis

I’ve looked through the source code and the many helper functions like findOwnInput and getContinuingOutputs but it is more of the same thing.  Can someone point me in the right direction about which part of the data structure I need to look at?


text:
Cabal - could not resolve dependencies error
I have completed the pioneer program and am writing my own app.  I've created my react front end and now am trying to serialize my smart contract in Haskell for a minting policy I wrote.  The problem I am having is I believe I am unable to get the Plutus library installed correctly.  I did a cabal update then cabal init to get cabal in my program.  I then pretty much copied the cabal configuration from Week05 in the pioneer program with some slight modifications in to my project. See below
cabal-version:      2.4
name:
version:            0.1.0.0
synopsis:
license:            Apache-2.0
build-type:         Simple

extra-source-files:
   CHANGELOG.md
   README.md

common common-all
    build-depends:    base ^>=4.14.3.0
                , aeson
                , bytestring
                , containers
                , cardano-api
                , data-default
                , plutus-ledger-api
                , plutus-tx-plugin
                , plutus-tx
                , text
                , serialise
                , utilities
default-language: Haskell2010
ghc-options: -Wall -fobject-code -fno-ignore-interface-pragmas
             -fno-omit-interface-pragmas -fno-strictness
             -fno-spec-constr -fno-specialise -fexpose-all-unfoldings
             -fplugin-opt PlutusTx.Plugin:defer-errors

library
import:             common-all
hs-source-dirs:     app
exposed-modules:    TC_Contract

I have an app folder where I have TC_Contract.hs so I belivee I have everything I need setup correctly in the cabal configuration.
when I try to use the cabal repl command I get

The error says it cannot find plutus-ledger-api which is in the cabal file.  If I comment out plutus-ledger-api then it does to the next one on the list of build-depends.  It is like I am missing a reference to something but I don't know where.  I think I am missing some information on how I actually get Plutus in my project.  I've built a cabal file for a standard haskell program without a problem and the cabal files in the pioneer program were already complete.  Confused on what to do.  Does anyone have any ideas?  Thanks.
Oh also as I note I copied the Utilities folder into my dapp from the pioneer program code as there was a lot of useful functions in there.  It is strange that file had its own cabal file as well.  Not sure if that is creating a problem as well.

Someone mentioned something to me on the Cardano discord that I needed my cabal.project file.  I guess for some reason using cabal init doesn't put it in there?  Anyway, after I put that file in there and configured it everything built properly.

Yes, you will need a cabal.project file.


text:
Critical dependency: the request of a dependency is an expression
I keep receiving this:
Is it normal or i missed something?
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- event compiled client and server successfully in 1247 ms (18 modules)
- wait compiling...
- event compiled client and server successfully in 254 ms (18 modules)
- wait compiling /_error (client and server)...
- warn ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js
./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib.js
./node_modules/@meshsdk/core/dist/core.js
./node_modules/@meshsdk/react/dist/react.js
- warn Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/messages/fast-refresh-reload
- warn ./node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.js
Critical dependency: the request of a dependency is an expression

node versions LTS 18 and 16
Win/Ubuntu 20/22
url: https://meshjs.dev/guides/nextjs
It seems to be working fine, but how can I get rid off?
It installs @meshsdk/core 1.5.2 but can't upgrade to 1.5.4 due to @meshsdk/react@1.1.7
Thanks in advance!


text:
Blockfrost policy/metadata api issues
I am trying to get the metadata for the policy ID
but every Blockfrost gives error saying "invalid path"
I am able to get data related to assest using:
"https://cardano-preprod.blockfrost.io/api/v0/assets/2a384dc205a97463577fc98b704b537f680c0eba84126eb7d5857c865050424c32303233796f75726561636865645261686174"
but I am not able to get any information for this policy ID: 2a384dc205a97463577fc98b704b537f680c0eba84126eb7d5857c86
and when I used https://cardano-preprod.blockfrost.io/api/v0/metadata/txs/labels/721
i could not find the required metadata with policy ID: 2a384dc205a97463577fc98b704b537f680c0eba84126eb7d5857c86
HOW DO I ACCESS METADATA (721) FOR POLICY ID: 2a384dc205a97463577fc98b704b537f680c0eba84126eb7d5857c86
there are around 15 object expected to be return form this policy ID

To get a list of assets with specific policy ID, use the /assets/policy endpoint.
For your example, it is https://cardano-preprod.blockfrost.io/api/v0/assets/policy/2a384dc205a97463577fc98b704b537f680c0eba84126eb7d5857c86.

this will get me the list of assets for that policy id, how do I get the metadata for those policy id.

policy id doesn't have metadata, only assets might have in this case


text:
Retire a stake pool and get the rewards and pledge before
I had once the knowledge on how to operate a stake pool, but I hadn't had time to care about it, and now I want to end it. Now I still have some ADA staked but also as the pool deposit thingy (forgot how it was called). Now my problem is: it doesn't run anymore because it was so old...
Is it possible to copy all files to my own computer and get the ada out of there, or do I need to update and run the pool again before I am able to retrieve my ADA which sits at the pool's address?
Please help, the docs when I google it are all with "Error 404 Page not found " which is horrible..
Cheers

You can create the retirement certificate with just the cold key and a single payment utxo using cardano-cli. This can be done completely off-line on a cold environment if you know the utxo your referencing as tx-in ahead of time using cardano-cli transaction build-raw. It can also be done on a live environment with a running mainnet node using cardano-cli transaction build


text:
Console devtools sign and submit transaction
so i'm runing this to prompt a transaction on nami wallet, sign and submit.
the ideal scenario was to nami wallet submit transaction for herself but somehow that is not happening, so i tried to submit via blockfrost api.
the script that i paste on devtools console:
// Replace this with your transaction data
const cborEncodedTransaction =
  // Your CBOR encoded transaction data here
  "MY_TX_CBOR";

// Replace this with your API key from Blockfrost
const apiKey = "PROJECT_ID_BLOCKFROST";

async function signAndSubmitTransaction(cborEncodedTransaction) {
  try {
    // Check if Nami Wallet is available
    if (!window.cardano) {
      throw new Error("Nami Wallet is not available. Make sure you have the Nami Wallet extension installed.");
    }

    // Sign the transaction using Nami Wallet
    const partialSign = true; // Set this to true to enable partial signing
    const transactionWitnessSet = await window.cardano.signTx(cborEncodedTransaction, partialSign);

    // Convert the transactionWitnessSet to a hex-encoded string
    const signedCborTransaction = transactionWitnessSet;
    console.log("Signed Transaction (hex-encoded):", signedCborTransaction);

    // Submit the transaction using Blockfrost API
    console.log("Submitting transaction to Blockfrost...");
    console.log("CBOR Encoded Transaction with Witness:", signedCborTransaction);

    const response = await fetch("https://cardano-mainnet.blockfrost.io/api/v0/tx/submit", {
      method: "POST",
      headers: {
        "Content-Type": "application/cbor",
        "Project_id": apiKey,
      },
      body: signedCborTransaction,
    });

    console.log("Blockfrost Response Status:", response.status);
    console.log("Blockfrost Response Data:", await response.json());

    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`Blockfrost API error: ${errorData.error}, ${errorData.message}`);
    }

    console.log("Transaction submitted successfully.");
  } catch (error) {
    console.error("Error signing or submitting transaction:", error);
    throw error;
  }
}

// Call the signAndSubmitTransaction function with the transaction data
signAndSubmitTransaction(cborEncodedTransaction);

the error that i get:
{
    "error": "Bad Request",
    "message": "\"transaction read error RawCborDecodeError [DecoderErrorDeserialiseFailure \\\"Byron Tx\\\" (DeserialiseFailure 0 \\\"expected list len\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\")]\"",
    "status_code": 400
}

the nami window pops up with the correct transaction for me to signed it, and after that the error happens.

Your variable signedCborTransaction is just key witnesses for inputs being spent in this transaction that belong to your wallet, specifically, it's CBOR of transaction_witness_set with only entries for 0th key as per this CDDL specification.
You would need to add this witness to your original transaction (cborEncodedTransaction) and then submit it.


text:
I am getting error while using "cabal build all" cmd
I am new to plutus. I am trying to learn plutus for which I am using "plutus-starter" code to begin. while using "cabal build" i am getting following error:
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: Win32-network-0.1.0.0 (user goal)
[__1] trying: base-4.16.4.0/installed-4.16.4.0 (dependency of Win32-network)
[__2] next goal: byron-spec-chain (user goal)
[__2] rejecting: byron-spec-chain-0.1.0.0 (conflict:
base==4.16.4.0/installed-4.16.4.0, byron-spec-chain => base>=4.12 && <4.15)
[__2] fail (backjumping, conflict set: base, byron-spec-chain)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, byron-spec-chain, Win32-network

How can I solve this.

You are using the wrong version of GHC which supplies the base library.
According to https://www.snoyman.com/base/ base version 4.16.* is supplied by ghc-9.2.* .
From the bounds required on base (base>=4.12 && <4.15) I would suspect you should be using ghc-8.10.7.

I think it solved my problem. Thank you very much.


text:
How to get installed wallets on android browser? window.cardano is undefined
we have implemented an app that reads the wallets via window.cardano in the browser.
When we run this app in the browser on an Android device, the window.cardano object is undefined.
How can we access the wallets and API in a browser on an Android device? Is there a way?
Greetings
Waldemar

What browser do you use on mobile? And what wallet did you install in that browser?

hi, i'm using chrome and firefox and i've installed nami, gerowallet and yoroi wallets. thanks

As far as I know, it is not possible to install extensions on Chrome for Android.. If you managed to install any of these wallets in your phone's Chrome/Firefox browser, then the connection should work the same way as on the PC.


text:
get all transactions info of Cardano by using third party 'Blockfrost' with only 1 time call api?
I'm a noob about Cardano, i wonder if be able to get all transactions info of cardano by passing an specific address.
For example i have an specific address is:
addr1qy7nlfwaw3jsfftcnewgqg27dwa08uqeamjhs29tr5rgszun8netpzv3gpj5enhz36nhnw2jjfknfya64nwhgfw6ze2qhvj0xx (have 8 transactions)

like the way in ethereum scan: has provided puclic api and just pass the specific ethereum address (normal transactions type), i will get all of transactions info (blockNumber, timeStamp, hash, address from, address to, value, gasPrice,.....) by just only one time call API.

-> but with Blockfrost as i what knew, if need to get all transactions info, it is not possible to use 1 call APIs to receice all 8 transactions, it takes many calls to get info about each transaction.
first of all, need to get all address transaction (
https://cardano-mainnet.blockfrost.io/api/v0/accounts/{stake_address}/addresses or can be use https://cardano-mainnet.blockfrost.io/api/v0/addresses/{address}/transactions) to get a list of transactions hash, then with each transactions hash -> will be call or need to go throught a few more APIs to get the address info)
I'v would appreciate if some one can help me for this topic.

Looks like neither Blockfrost nor Koios (another Cardano API) provide this at this point in time. In both APIs you have to query the TX hashes first and then query the details of each TX seperately.
Koios is a community driven project, so you can propose this change in one of their channels on Telegram or Discord if you want.

Koios does seem to support multiple tx hashes now: https://api.koios.rest/#post-/tx_info


text:
Extracting Metadata of an NFT using Lucid
I am trying to extract the metadata of any NFT of interest on-chain. According to Lucid documentation, you can use metadataOf(). Here is my code:
const lucid = await Lucid.new(
    new Blockfrost(
      "https://cardano-preprod.blockfrost.io/api/v0",
      Deno.env.get("BLOCKFROST_API_KEY")
    ),
    "Preprod"
  );

const test = await lucid.metadataOf("ASSETNAME_HERE");
console.log(test)

The code throws an error: ""No variant matched." Meaning that it can't find .metadataOf. Anyone has an idea how to fix this?

The error "No variant matched" likely means that the metadataOf method didn't find the asset you're querying for, or there might be some issue with how the Lucid library is initialized or called.

Make sure Lucid and Blockfrost are properly imported.
Verify your BLOCKFROST_API_KEY is correctly set in your environment.
Confirm that "ASSETNAME_HERE" is actually the correct asset identifier.
Double-check if you're using the correct version of the Lucid library that supports the metadataOf method.

If all these are fine, try reaching out to the Lucid library maintainers or community for specific issues with the metadataOf method. You can find them on their Discord channel: https://discord.com/invite/82MWs63Tdm
If nothing works, you might want to look for some different library.

Yeah, all those were correct. So, I actually just skipped lucid and directly use blockfrost api commands to query the blockchain.

Great to hear that. Please mark question as resolved.


text:
How can I ensure my verified message correctly wraps the original message using CIP30 signatures on macOS
I'm working with CIP30 signatures for message signing on macOS, and need to verify that the signed message (Sig_structure in CBOR format) wraps the original message properly for this [site][1]. The Sig_structure is defined as:
Sig_structure = [
context : "Signature" / "Signature1" / "CounterSignature",
body_protected : empty_or_serialized_map,
? sign_protected : empty_or_serialized_map,
external_aad : bstr,
payload : bstr
]
any best practices ?
[1]: https://www.vgopromo.com


text:
Understanding a weird Cardano transaction with repeated addresses
Can anyone explain this transaction?
https://cardanoscan.io/transaction/4911eeec04808b593a34f527bc54ca9c6bf511d6e1ce2a8d2f813f7faaaaa9c9?tab=summary
It features one input and, as outputs, includes the contract (script address) alongside the same address repeated five times, plus some reward withdrawals.
I created the contract (script) and its enterprise address to lock (or 'burn') tokens. I'm puzzled about how and why this transaction occurred.
You can observe dozens of standard transactions on the same script here:
https://cardanoscan.io/address/71ddeef9f90c80761867d2371cbb8003b4d5559ba795640e7042ca01ed?tab=transactions
This is the first time I've encountered such an odd transaction.

What's strange about it? The fact that it creates multiple UTxOs in the sender's wallet is an optimization for the parallelism of the future transactions.


text:
How to develop stablecoin on Cardano?
I am new to Cardano and would like guidance on prototyping a fiat-based stablecoin on the platform. Could you please provide me with some guidance on where to begin?"

There are two components to your question. Firstly how to design and implement a stable coin, which is a question that is completely independent of Cardano, and secondly how to create a token on Cardano which I am sure is documented somewhere.

Once you have answers to these two components, combining them to produce the result you want should be relatively easy.

Thanks a lot for your guidance.

I have found some resources for creating tokens on Cardano. For the stable coin concept, most of the information on the internet seems to suggest using smart contracts for implementing stablecoins. However, it appears that using native tokens would be more suitable for Cardano. Unfortunately, I am unsure how to integrate these two components.

The actually implementation of a stable coins is only a TINY part of the whole enterprise. Well over 95% of the task is figuring out  how to back the value of your stable coin and how to peg it to whatever your token is meant to be pegged to. Pretty sure you do not need a smart contract to implement a stablecoin on Cardano as long as you do the other bit first.

Thank you very much. Let me think out loud. I plan to create a token on Cardano and connect it to a bank account. If users transfer money within the network, I will use a regular transaction without accessing the bank account. However, if users transfer money outside the network to a third party, I will burn tokens and transfer the money from the bank account to the third party.

Yes, that sounds like a rudimentary stablecoin.


text:
Blockfrost API error with pycardano
I get blockfrost.utils.ApiError: {'status_code': 400, 'error': 'Bad Request', 'message': 'Invalid address for this network or malformed address format.'}
when using pycardano and this code
# Create a BlockFrost chain context
context = BlockFrostChainContext(
    "Project_id", base_url=ApiUrls.mainnet.value)

Same problem if I use API url directly
Is it a Pycardano issue or blockfrost?

The error is pretty clear:

Invalid address for this network or malformed address format

Can you show us more of your code?

thanks for quick reply. I found the error.


text:
pycardano library seed phrase
found nice examples generating verification keys and payment keys but I don't get to same time generate the seed phrase. Without the seed phrase I cannot open the wallet in a hot wallet to view it and so forth.
I simply do not understand the docs.
here is api docs
https://pycardano.readthedocs.io/en/latest/api/pycardano.crypto.html?highlight=seed%20phrase

You can take a look at this function that I am using to work with Hierarchical Deterministic Wallets in PyCardano. If the mnemonic file does not exist, it generates a new one and saves it to disk, and if it exists, it is using it.
def wallet_from_mnemonic(mnemonic_file: str, address_count: int = 1) -> dict:
    """Generate the wallet from a mnemonic phrase existing in a file on disk.
    If the mnemonic file does not exist, generate a new mnemonic and save it.
    """
    try:
        with open(mnemonic_file, "r") as f:
            mnem = f.read().strip()
    except FileNotFoundError:
        mnem = HDWallet.generate_mnemonic()
        with open(mnemonic_file, "w") as f:
            f.write(mnem)
    hdw = HDWallet.from_mnemonic(mnem)

    """
    Derive the staking key
    """
    stk = hdw.derive_from_path(stake_derivation_path)
    stk_skey = StakeExtendedSigningKey.from_hdwallet(stk)
    stk_vkey = StakeExtendedVerificationKey.from_signing_key(stk_skey)

    """
    Derive the first payment address
    """
    wlts = {}
    for i in range(address_count):
        payment = hdw.derive_from_path(payment_derivation_path[0:-1] + str(i))
        p_skey = ExtendedSigningKey.from_hdwallet(payment)
        p_vkey =
PaymentExtendedVerificationKey.from_signing_key(p_skey)
        p_addr = Address(p_vkey.hash(), stk_vkey.hash(), network)
        wlts[i] = {
            'addr': p_addr,
            'skey': p_skey,
            'vkey': p_vkey
        }
    return wlts

great I'll try it. Even if I however generated new wallets with more info already


text:
(Failed to build scrypt-0.5.0. The failure occurred during the configure step.)
Getting erro rwhile doing "cable build all".
OS
Your OS:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Cable version :
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library
ghc version:
The Glorious Glasgow Haskell Compilation System, version 8.10.7
Additional context
I tried these few steps also
1)cabal clean
2)cable build all
3)sudo apt-get install libsodium-dev
4)sudo apt install libscrypt-dev
Problem Report
Installing regex-pcre-builtin-0.95.2.3.8.44 (lib)
Completed regex-pcre-builtin-0.95.2.3.8.44 (lib)
Installing Cabal-syntax-3.10.1.0 (lib)
Completed Cabal-syntax-3.10.1.0 (lib)
Failed to build scrypt-0.5.0. The failure occurred during the configure step.
Build log (
/home/ubuntu/.cabal/logs/ghc-8.10.7/scrypt-0.5.0-9dc7f5056f17df13813f95e91bb667ceed7dc3e60a8b91da16ab03a3c4c8a06b.log
):
Configuring library for scrypt-0.5.0..
cabal-3.6.2.0: Missing dependency on a foreign library:
Missing (or bad) header file: crypto_scrypt.h
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
cabal: Failed to build scrypt-0.5.0 (which is required by test:unit from
cardano-wallet-2023.7.18, exe:mock-token-metadata-server from
cardano-wallet-2023.7.18 and others). See the build log above for details.

You keep asking this same question all over the internet. Have you actually gone back and seen if there were any responses? This question really belongs on GH in the cardano-wallet repo. You are far more likely to get an answer there than you are here.

Thank you for your reply...


text:
MeshJs integration With Next 13 Error: Element type is invalid. Received a promise that resolves to: [object Promise]
I am trying to create a connect button to the Nami Wallet where the user can register so I can take the public address, network id, and so on as I need it for the backend.
To implement the Nami wallet connection I am using MeshJs. I followed the documentation but when I use the MeshProvider component I get this error:
Error: Element type is invalid. Received a promise that resolves to: [object Promise]. Lazy element type must resolve to a class or function.
I'm currently utilizing Next.js 13 in my project, and I've organized my providers in a separate file. Given that I'm also using Redux and Redux Persist, this is where I integrate the MeshProvider.
const Providers = ({ children }: { children: React.ReactNode }) => {
  return (
    <MeshProvider>
      <Provider store={store}>
        <PersistGate loading={null} persistor={persistor}>
          {children}
        </PersistGate>
      </Provider>
    </MeshProvider>
  );
};

This component is used inside the main layout.tsx.
Am I encountering the error due to placing the component in the wrong file? I attempted to use it within the main layout.tsx, but it seems the MeshProvider relies on useEffect and requires placement within a use-client component."


text:
Creating a Testnet node ( stake pool ) on Ras Pi
I did watch this series on YT for Ras Pi - https://www.youtube.com/watch?v=GBdpE1ta1EU&list=PLBhbLwOuj0DfTnneuG3vyoDHY7Dv_aiyq&index=10
But I have a doubt about the updated method.
Is Cabal better or Nix, while creating a Cardano testnet node on Cardano?
Please suggest and re-direct to the right config. Thanks!

For getting started on a testnet it is best to look at the up-to-date guide https://docs.cardano.org/cardano-testnet/getting-started


text:
Loading specific Datum JSON with Map structure into Plutus type
We have a specific Datum, taken from Orcfax oracle UTXO:
https://preprod.cexplorer.io/datum/9ced750ebbb2c9a9eac2e07a91525cadd3bfab23950089faa3e3a55517d1033f
the part we are interested in is the very first field, map:
"map": [
        {
            "k": {
                "bytes": "40636f6e74657874"
            },
            "v": {
                "bytes": "68747470733a2f2f736368656d612e6f7267"
            }
        },
        {
            "k": {
                "bytes": "5f3a636f6e74656e745369676e6174757265"
            },
            "v": {
                "bytes": "61346230303130306537313331386533633130373266343332643930373264376530356230386530666338353333656363323531323861623934653737323937"
            }
        },
        {
            "k": {
                "bytes": "6964656e746966696572"
            },
            "v": {
                "map": [
                    {
                        "k": {
                            "bytes": "70726f70657274794944"
                        },
                        "v": {
                            "bytes": "41726b6c79204964656e746966696572"
                        }
                    },
                    {
                        "k": {
                            "bytes": "74797065"
                        },
                        "v": {
                            "bytes": "50726f706572747956616c7565"
                        }
                    },
                    {
                        "k": {
                            "bytes": "76616c7565"
                        },
                        "v": {
                            "bytes": "75726e3a6f72636661783a61636130373632622d326661372d346461622d396261352d663935333631373430633738"
                        }
                    }
                ]
            }
        },
        {
            "k": {
                "bytes": "6e616d65"
            },
            "v": {
                "bytes": "4144412d5553447c5553442d414441"
            }
        },
        .........................

The strange thing is, values are of a different type. Some are strings, some are lists or integers. As far as I understand, in Plutus/Haskell, AssocMap can contain only values of the same type, and there is no way to declare a type for this Map.
The closest I get to this structure in Plutus is this:
import PlutusTx.AssocMap (Map, fromList)

data OrcfaxDatum = OrcfaxDatum {
    testOne  :: BuiltinByteString,
    testTwo  :: (Map BuiltinByteString BuiltinByteString, Map BuiltinByteString Integer, Map BuiltinByteString [Integer])
  } deriving Show
PlutusTx.makeIsDataIndexed ''OrcfaxDatum [('OrcfaxDatum, 0)]
PlutusTx.makeLift ''OrcfaxDatum

-- in offchain code:
let datum = OrcfaxDatum "test" (fromList [("test", "test")], fromList [("test", 1)], fromList [("test", [1])])
let dr = encode (scriptDataToJson ScriptDataJsonDetailedSchema $ fromPlutusData (PlutusTx.toData datum))
Haskell.error $ Haskell.show $ dr

which produces the following JSON output:
{
   "constructor":0,
   "fields":[
      {
         "bytes":"74657374"
      },
      {
         "constructor":0,
         "fields":[
            {
               "map":[
                  {
                     "v":{
                        "bytes":"74657374"
                     },
                     "k":{
                        "bytes":"74657374"
                     }
                  }
               ]
            },
            {
               "map":[
                  {
                     "v":{
                        "int":1
                     },
                     "k":{
                        "bytes":"74657374"
                     }
                  }
               ]
            },
            {
               "map":[
                  {
                     "v":{
                        "list":[
                           {
                              "int":1
                           }
                        ]
                     },
                     "k":{
                        "bytes":"74657374"
                     }
                  }
               ]
            }
         ]
      }
   ]
}

But these are just a separate maps, and Orcfax Datum JSON won't be parsed correctly.
If Map in Orcfax Datum would contain values of identical type, parsing would be easy:
import PlutusTx.AssocMap (Map, fromList)

data OrcfaxDatum = OrcfaxDatum {
    testOne  :: BuiltinByteString,
    testTwo  :: Map BuiltinByteString BuiltinByteString
  } deriving Show
PlutusTx.makeIsDataIndexed ''OrcfaxDatum [('OrcfaxDatum, 0)]
PlutusTx.makeLift ''OrcfaxDatum

-- offchain code
let orcfaxMap = fromList [("test", "test"), ("test", "test")]
let datum = OrcfaxDatum "test" orcfaxMap
let dr = encode (scriptDataToJson ScriptDataJsonDetailedSchema $ fromPlutusData (PlutusTx.toData datum))
Haskell.error $ Haskell.show $ dr

Result:
{
   "constructor":0,
   "fields":[
      {
         "bytes":"74657374"
      },
      {
         "map":[
            {
               "v":{
                  "bytes":"74657374"
               },
               "k":{
                  "bytes":"74657374"
               }
            },
            {
               "v":{
                  "bytes":"74657374"
               },
               "k":{
                  "bytes":"74657374"
               }
            }
         ]
      }
   ]
}

As you can see, the structure is identical.
I think this Datum was built with Mesh or something similar:
import { resolveDataHash } from '@meshsdk/core';
import type { Data } from '@meshsdk/core';

const datumMap: Data = new Map<Data, Data>();
datumMap.set('token', 'meshtoken');
datumMap.set('price', '12345678');
const datumMapHash = resolveDataHash(datumMap);
// datahash: 406f12b8df90412d7af0ff40e80ce62234602ed0b5af2633042b866b1a22b8f4

const datumMap2: Data = new Map<Data, Data>();
datumMap2.set([1, 2], ['meshtoken', 123]);
datumMap2.set([3, 4], 12345678);
const datumMap2Hash = resolveDataHash(datumMap2);
// datahash: 9017cbec493c851cf0f19ff0e69a8188266cefdd9af2210496c55e7a1d743bdb

What am I missing?
How to parse this Datum onchain with PlutusV2?
How to define type for this map?
thanks

You could define a union type for values, something like
data Val = B BuiltinByteString
  | M (AssocMap BuiltinByteString Val)

type OrcFax = AssocMap BuiltinByteString Val

then you can deserialise the Datum to a raw Data and "parse" it manually, pattern matching on the parts you are interested in. Data being a generic description of any data structure, allows to mix types this way.


text:
How to decouple Constr from Data
Imagine I have the following field in the Datum:
{
    "fields": [
        {
            "int": 3810998862
        },
        {
            "int": 18446744073709552000
        }
    ],
    "constructor": 3
}

I am retrieving this field in the Plutus script and converting to Data type. The final result I am left with is:
price :: PlutusTx.BuiltinData

This variable is of type:
Constr Integer [Data]

How can I retrieve/decouple only [Data] part and ditch this Constr with Plutus (without Plutarch)?
Saw something with UnConstrData, but I cannot make it work:
test = UnConstrData (PlutusTx.unsafeFromBuiltinData price)

Getting:
 * Couldn't match expected type `BuiltinData -> t'
                  with actual type `DefaultFun'
    * The function `UnConstrData' is applied to one argument,
      but its type `DefaultFun' has none
      In the expression: UnConstrData price
      In an equation for `x': x = UnConstrData price

Thanks


text:
How can Datum be decoded from utxos that were generated using MeshJs Marketplace Smart Contracts?
I have datum that was formed using the MeshJS Marketplace Smart Contract.
Can someone help me with the process to decode the datum. I have tried various methods mentioned in their discord with no success. NOTE: I have saved the values needed to form the datum but I want to know the process in which I can decode the datum hashes from the utxos.
The full utxo that shows up from cardano-cli is :
2d66a297a1add05094885b29158561f6786b2f473010a77f8954b3caea620794     0        1336100 lovelace + 1 ec869b653472b4f68cc86e14731723bdd97573f0a7ccf81a0fc6b8c6.476f6c64656e20427574746572666c79 + TxOutDatumHash ScriptDataInBabbageEra "b600faebcefacd601d3a7a741ae60ebadcc450e745f53b8df3ea3b9f1cdfbf82"

The datum hash is:
b600faebcefacd601d3a7a741ae60ebadcc450e745f53b8df3ea3b9f1cdfbf82

check out the new marketplace, demo, codes, aiken workspace and transaction building.


text:
Why do i loose all wallets and need to resync after symlinking chain folder?
Since my partition with /home on it started to fill up, i relocated the folder ~/.local/share/Daedalus/mainnet/chain onto another drive.
After moving the files and symlinking to the new location, i restarted Daedalus. Now all my wallets are gone and Daedalus is resyncing from 0%. (Which is now ongoing for 16hours and is currently at 72%...)
This is confusing to me, since it was perfectly synced before moving the chain folder, so i would only expect to re-sync the new blocks while moving (like less than 1%). And especially that all my wallets are now gone, is weird to me (not a big deal, of course i've got the seed phrases for all of them).
But this is rather inconvenient and i don't understand why this is happening. Can anyone explain this behavior?

Turns out in order to use symlinks accross devices, one needs to alter the nix command to mount these locations.
See this answer: https://cardano.stackexchange.com/a/9340


text:
Documentation for developing a personal Cardano project
I am looking to build a personal project related to Cardano. Are there any documents on libraries or APIs to implement functionalities such as checking balance, transferring funds, etc.?

You can have a look at https://docs.cardano.org/introduction/ for some general information about Cardano.
For APIs and tools, https://developers.cardano.org/tools has a big collection of useful projects that you can use. There is also a getting started section that can be useful: https://developers.cardano.org/docs/get-started/
Checking balance and submitting transactions can be easily achieved using an API like Koios or Blockfrost if you don't want to run your own infrastructure.
If you use JavaScript, Mesh is a great library to start building a project on Cardano. Otherwise just have a look at the tools section of the developer portal to find libraries for the programming language you'd like to use.

Does Cardano have a testnet similar to Ethereum or Binance Smart Chain?

Yes, there are multiple, you can find more information about testnets here: https://developers.cardano.org/docs/get-started/testnets-and-devnets

The cardano-db-sync project follows the chain a inserts on and off chain data into a PostgreSQL database from where it queries using SQL.


text:
stake pools - do they encourage centralisation?
Quote from cardano docs:

The higher is the stake in a pool, the more rewards will be assigned
to its owners.

Doesn't this mean that the bigger the pool is the more profitable it is and therefore it could lead to a small amount of stake pools (why someone would want to join smaller stake pool if it offers smaller profits?).

This is a complex topic, I'll try to explain it as simply as possible.
There is the so called "Saturation Parameter (K)". K is the desired number of active stake pools. From K the maximum amount of ADA delegated to one single pool is calculated. Once a pool exceeds the maximum amount of ADA, it will offer diminishing rewards. (Source https://cardano.org/stake-pool-operation/)
If there would be exactly K stake pools and all ADA would be delegated. All pools would have the maximum amount of ADA delegated (not too much). Therefore that would be the ideal scenario.
In practice, there are more than K stake pools. So the stake pool operators need to try to convince people to delegate to their pool. And you're right, many small pools struggle to get new delegators because people naturally tend to choose a pool that already has more stake delegated.
Recently the minimum fixed fee of stake pools has been decreases from 340 to 170 ADA to make the penalty of staking with a smaller pool less drastic for the delegators. However, this means even less rewards for the pool operators which might not be sustainable for them.
Please also have a look at this related question for more information.

Thanks for the related question. I have immediately asked myself about single entity maintaining multiple pools and the related question is very much about it.


text:
Where can I find Cardano implementation repository?
For Bitcoin and Ethereum I can easily find repositories with their implementations.
Where is an equivalent for that for Cardano?
I have found this repository but I am confused by the name of the owner of this repository (I heard about Emurgo, IOHK and Foundation but not about IntersectMBO) so I am not sure if that's what I am looking for(?)...

The Cardano node is composed of numerous components including:

https://github.com/IntersectMBO/cardano-base
https://github.com/IntersectMBO/cardano-ledger/
https://github.com/IntersectMBO/ouroboros-network/
https://github.com/IntersectMBO/ouroboros-consensus/
https://github.com/IntersectMBO/cardano-api/
https://github.com/IntersectMBO/cardano-cli/
https://github.com/IntersectMBO/cardano-node/

Ok, so I assume that if I am looking for the "core" Cardano functionality then I should go with cardano-node most likely.

If you are looking for the core functionality you should probably look at ledger and/or consensus.

Intersect is the cardano members based organization launched last year. Think of it like the Linux foundation equivalent for supporting Cardano development.

Ok, so my confusion about IntersectMBO was unnecessary :) There are a lot of organizations around Cardano...


text:
I want to develop my project related to Cardano
I want to develop a personal project related to Cardano. I have read some documents, but they require using project_id from Blockfrost. However, I don’t want to go that route. So, I’m wondering where to start. Are there any libraries or APIs that support this? I’m using Node.js and want to perform functions such as creating wallets, checking balances, transferring, etc.

Can you elaborate on what route you are refering? You need an API (such as Blockfrost) to access to the data on the Cardano network. Are you looking to run and index your own node?

My point is like this: Ethereum, I can use web3js to directly interact with the network and perform the mentioned functions. However, if I use Blockfrost to interact with Cardano, I need a project_id. So, I'm looking for a solution that allows free access to the Cardano network.

Even with web3js, you need a provider of the data, same as in Cardano.
In Ethereum, you can use Infura, in Cardano, you can use for example Blockfrost. In both you can use your own local node (altought in Eth it is much easier to setup).

An alternative to Blockfrost is the https://koios.rest API


text:
Mint an NFT using policy script on cardano
I'm trying to run validations before minting an asset/nft on cardano. I have written the policy script using plu-ts and transactions using mesh sdk.
Script
export const mintNFT = pfn(
  [datum.type, redeemer.type, PScriptContext.type],
  bool
)((datum, message, ctx) => {
  return pBool(true);
});

Transaction
const script: PlutusScript = {
  code: nftScriptCbor,
  version: "V2",
};

const recipient = await wallet.getChangeAddress();

const redeemer: Partial<Action> = {
  tag: "MINT",
};

const tx = new Transaction({ initiator: wallet });

const metadata: AssetMetadata = {
  name: "Test Token",
  description: "This is a test nft",
  image: "ipfs://",
  mediaType: "image/jpg",
};

const asset: Mint = {
  assetName: "MeshToken",
  assetQuantity: "1",
  metadata,
  label: "721",
  recipient,
};

const myUTxOs = await wallet.getUtxos();
tx.setCollateral(myUTxOs);

tx.mintAsset(script, asset, redeemer);

const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);
const txHash = await wallet.submitTx(signedTx);

return txHash;

The issue is that it mints the NFT, but doesn't run the validations. Although in transaction, it shows that contract is executed, but even if I return false from script, it still gets minted.
export const mintNFT = pfn(
  [datum.type, redeemer.type, PScriptContext.type],
  bool
)((datum, message, ctx) => {
  return pBool(false);
});

Can someone please explain how can I resolve this issue?

I hope this answer doesn't come too late.
the problem is that you are trying to use a contract meant to validate a spending of an utxo for minting instead.
when used for minting you DO NOT need a datum.
datums are only used for spending scripts.
what happens here is that the node only passes 2 arguments to the script.
which implies the script is only partially applied; hence it returns a new function, without never throwing an error.
not throwing an error causes the node to think the contract agreed to the transaction, and proceeded.
the fix is easy.
you just want to remove the datum from the contract definition.
so your contract would look like this:
export const mintNFT = pfn(
  [redeemer.type, PScriptContext.type],
  bool
)((message, ctx) => {
  return pBool(false);
});


text:
What does "Exception: unpaired digit" digit mean when trying to use the "assetClassValue" function?
Attempting to use function : assetClassValue (assetClass "67890" "PussToken") 100
Value (Map [(678900,Map [("PussToken",100)])])
Getting error -> Value (Map [(*** Exception: unpaired digit
CallStack (from HasCallStack): error, called at src/Data/Either/Extras.hs:6:34 in plutus-ledger-api-1.0.0.1 a5376ffff9bcd7feae2f904cd9bf193d5371c9e71ecc491aed0dbf5d6852f891:Data.Either.Extras

The input for "assetClass" excepts a paired hex value. I simply turned "67890" into an even number of digits -> 678900.
Then it works-


text:
Using cardano-cli, is their any way to decode a plutus script which is in cbor?
I am using "cardano-cli text-view decode-cbor --in-file mint.plutus" which is just returning the cbor portion as a result.
Even tried saving an --out-file via: .json etc...But gives me Giberish when I "cat" it.
Any way to decode a plutus script in CLI instead of using an external source?
There is an existing post which talks about decoding "transactions" (which works for transactions), - but that does not work when I manipulate it with a plutus cbor script->
How to decode cbor which is generated with cardano-cli build command?

This is not currently possible with cardano-cli. There are executables in plutus that you may find useful. See https://cardano.stackexchange.com/a/11449/1071.


text:
cardano_node_metrics_connectedPeers_int empty since node upgrade 1.35.7 -> 8.1.2
Since i upgraded my nodes from 1.35.7 to 8.1.2 the cardano_node_metrics_connectedPeers_int variable is empty.
All others are set as expected.
I already loaded the newest config, because ConwayGenesisFile was missing and set TraceBlockFetchDecisions again to true.
Are there any changes regarding cardano_node_metrics_connectedPeers_int in the new versions?

Yes, it is been changed from cardano_node_metrics_connectedPeers_int to cardano_node_metrics_peers_connectedPeers_int
If I recall correctly changes was brought since 8.0.0 version.


text:
What is the Cardano's equivalent to the Ethereum's EVM?
What is Cardano's smart contract engine called?
Smart contract language:
Solidity (Ethereum) => Plutus (Cardano) Simple enough, I get this.

Smart contract "engine":
EVM (Ethereum) => ??? (Cardano) EUTXO? Plutus? PAB?

There is no Cardano equivalent to the EVM because code execution on Cardano is mostly an off-chain process.
In short, "smart contracts" is a bit of a misnomer because of how very different programmability is achieved in UTXO vs Accounts based distributed systems. In short:

In accounts, smart contracts are programs that are authorized to autonomously initiate state changes when specific conditions (on-chain) are met. In a way these programs have their own agency, making it easy to create a very precise dependency cascade (if X then Y then Z, then e.t.c.). As such, Ethereum itself is akin to a shared, single threaded, dynamically modifiable program, whose state is shared among all participating nodes - we call this the EVM.

In eUTXO, smart contracts are simply "address guards" that only allow their UTXOs to be used as inputs if the spending transaction exactly follows the logic set forth by the script's author. In other words, any transaction attempting to spend from an address guarded by a smart contract many only do so by providing a proof that its logic is equivalent to the logic outlined by the guard's author. As such, Cardano itself is akin to a shared database that can only be updated according to either canonical (pre-smart contract) or custom (post-smart contract) rulesets. There is no shared "state" (dependencies) of the system, only a shared history of inputs and outputs. Hence, no "Cardano-VM"

This topic has already been addressed from multiple angles, so I will provide links below that go in greater detail. The following Q/A's helped me understand the differences in the structure of UTXO vs Accounts, so they may help you as well:

Referencing an External Plutus Script
eUTXO transaction model Vs Account Based Transaction Model
Can blockchain viewers read the source code of a smart contract if they know its address?
What's the difference between programmable validators and smart contracts?

Thank you very much! This has been immensely helpful.

So... it's essentially wrong to compare eUTXO to EVM, cosmWASM or eWASM? (Apples to oranges)

I am not familiar with cosmWASM, but it is apples to oranges in the sense that smart contracts on (e)UTXO vs Accounts models are hardly comparable.

Great write up ! Very insightful !

Great answer, thanks! I'd be a bit cautious about this statement though: "code execution on cardano is an entirely off-chain process." There is still an on-chain validation part run in Plutus-core as part of transaction validation.

Cardano has what is called Plutus Core.
The short of it is that it's an Abstract Machine made up of lambdas and techno-sorcery that finds a way to execute directly on the client machine via Cardano node. This gives it some efficiencies over the VM approach.
Therefore Smart contract "engine":
EVM (Ethereum) => Plutus Core
N.B. Plutus is usually used in a blanket manner, usually folks mean Plutus-Tx which is a Haskell derivative.


text:
Where is the returning Contract Monad in the handleError function of Contract Monad?
The type of handleError function is
:: (e -> Contract w s e' a)-> Contract w s e a -> Contract w s e' a

It takes two arguments

a function which takes error and returns a Contract monad (Contract w s e' a) without error
Contract Monad with error

and returns a Contract Monad without error (Contract w s e a). This is what I could understand. However when this is used in the following code
payContract = do
   pp <- endpoint @"pay"
   let tx = mustPayToPubKey (ppRecipient pp) $ lovelaceValueOf $ ppLovelace pp
   handleError (\err -> Contract.logInfo $ "caught error: " ++ unpack err) $ void $ submitTx tx
   payContract

In this function call submitTx Tx gives the Contract Monad with error and the lambda function \err -> Contract.logInfo $ "caught error: " ++ unpack err may be the first argument. What is happening to the returned Monad without error? and why void is used?

Definitions:
submitTx :: forall w s e. (HasWriteTx s, AsContractError e) => TxConstraints Void Void -> Contract w s e Tx
void :: Functor f => f a -> f ()
handleError :: (e -> Contract w s e' a)-> Contract w s e a -> Contract w s e' a
Explaination:
submitTx tx is of type Contract w s e Tx, i.e. a Contract Monad with return type Tx.
void takes any Monad and maps it to a Monad with return type (). This is useful if you don't care for the returned value: void $ submitTx tx :: Contract w s e ()
handleError then takes the Monad and handles any errors with the specified error handler (e -> Contract w s e' a). However, it doesn't change the return type of the Contract Monad. In case there is no error on runtime the return value is just passed through.
payContract calls itself recursively on the last line of the do block in order to listen to the pay-endpoint indefinitely. Let's assume you'd leave out handleError and only use void $ submitTx tx your contract would crash on the first submission error.
If you wouldn't use void, your program would still be valid, but your compiler would output a warning, because you didn't use the return value of submitTx tx.

What is happening to the returned Monad?

All of this takes place within the do block. So, similar to the
<- endpoint @"pay"

the returned Monad is being abstracted away for you. The whole function is returning a Contract, so if it fails on either line, it will exit "early" and return the failed value. The reason it's not using the <- symbol is the answer to your second question:

why void is used?

We don't need the contained value.
void :: Functor f => f a -> f ()

So, void for Contract converts Contract w s e a to Contract w s e ().

You could also do this conversion by ignoring the output of a monad, as long as you still return the correct a for Contract, which in this case is ().
_ <- submit tx
return ()

is equivalent to
void $ submit tx

However, void is more explicit and fits better with the
handleError (\err -> Contract.logInfo $ "caught error: " ++ unpack err)

in your example.


text:
In experience, what distro of Linux is ideal for SPO
I'm at a point where I'll be running an SPO. I am curious from the current SPOs what version of Linux do they recommend. I've practiced setting up a pool on ubuntu and mint.

Ubuntu is the most widely used OS. However, any Linux distribution should be fine. Windows is best avoided.

This is too subjective to be on topic in my opinion. IOHK offers a wide range of support, seemingly equal (for Linux).

The installation of Cardano nodes is done by compiling the source codes, so any Linux distribution can host your node. However, the majority of the "SPO" community is primarily experimenting with Ubuntu LTS (documentation, how-to, Q&A etc.) in the official forum. So if you're new to exploring the Cardano ecosystem, you might want to you start with the Ubuntu distrib in order to benefit from existing feedbacks.
Moreover, if you want an excellent step-by-step tutorial to set up your pool, I recommend the guide "How to build a Cardano Stake Pool" from CoinCashew.
Good luck!


text:
Hash MisMatch Error on Plutus and Nix
I keep getting the Hash Mismatch Error, anyway I can resolve it or get around it?
hash mismatch in fixed-output derivation '/nix/store/7y3jr1jvzkj2146h7sivw0sfr2bhap3j-ghc-8.4.4-x86_64-deb8-linux.tar.xz':
wanted: sha256:06mb0l3y3gbs8znafxskzrkvgf2wbl0m22xsxhs3wzvbyxbqhajc
got:    sha256:0nx6459adisd4p5mjb03yp5jbaxplkjvwzfgkyw3bmwb3g9fgi9j
cannot build derivation '/nix/store/p68295cg7f09il07dsjpyskkmw9ms22f-ghc-8.4.4.drv': 1 dependencies couldn't be built

can you post the steps you have tried and the platform in which you are tying please

You can get away with the mismatch between the ghc nix derivations: Tell Nix to use the IOHK binary cache. (It is indeed indicated as "IMPORTANT" the we should enable the IOHK binary cache at the top of the Plutus README file)
On tradition linuxes, that should do it:
sudo mkdir -p /etc/nix
cat <<EOF | sudo tee /etc/nix/nix.conf
substituters = https://cache.nixos.org https://hydra.iohk.io
trusted-public-keys = iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
EOF

On NixOs:
# configuration.nix
{ config, pkgs, ... }:
{
  # ... all the rest of the configuration of the server

  # iohk binary caches
  nix =
  {
    binaryCaches          = [ "https://hydra.iohk.io" "https://iohk.cachix.org" ];
    binaryCachePublicKeys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" "iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo=" ];
  };
}


text:
Catalyst voting app fund 6 waiting for update, current version can not vote
I can not vote for fund 6 currently because if I start android catalyst voting app, it says there is an update version under construction I have to wait on before I can vote. so my question is: when will this update be available? time is running out, I think voting on fund 6 runs out soon. who can help with this?

Catalyst voting is a two-step process.

Register in the wallet and generate a QR Code
Scan the QR code in the "voting app"

For the fund 6, the voting will start on 7 Oct 2021 IOHK BLog. The app is custom and will have the proposals being put on the vote, therefore it is likely the app may not be available until the proposals are finalized. The registration is a once in a "wallet lifetime" process. You will be able to reuse the QR code for every fund.

This is because Catalyst Fund 6 is not in the voting phase, it starts on 7th of October.
Check Project Catalyst FAQ.