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:
Querying a transaction by hash vs id
When I want to query a tx by hash I can do this:
select * from tx where encode(hash::bytea, 'hex') = '28b492be2f733201ba3441d5d7d0fefc097c3deba3f299628680fae484293758'

...but the hash, stored as bytea then makes the query expensive.
If given a hash string, is there a more efficient way to retrieve the record from the tx table?

Fortunately, your query can be written more simply as:
select * from tx where hash = '\x28b492be2f733201ba3441d5d7d0fefc097c3deba3f299628680fae484293758' ;

Note that I have prepended "\x" to the hash so that Postgres treats the hash as hexadecimal (bytea).
When I run my version of your query on a fully synced mainnet database, the query returns the result (as single row) in under a second while your query takes over 10 seconds.
I am pretty sure your version takes the hash of every row of the table, encodes it and then compares it with your provided hash, while my just directly compares it with no conversion.

Fortunately indeed! Just ran it now and it is MUCH faster.
I have some queries to update.
Thank you!

"binary value represented in hexadecimal format using the '\x' notation allows for a direct binary comparison without the need for any additional encoding or conversion."

I posted this in a TG channel I am in and someone suggested that the encode(hash::bytea, 'hex') construct means that Postgres is not able to use any index it has on that field.

ah - that makes sense. Thank you.

Someone else on that channel also suggested that select * from tx where hash = decode('28b492be2f733201ba3441d5d7d0fefc097c3deba3f299628680fae484293758', 'hex'); is equivalent to mine.

source: Stack Exchange

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

sort: votes


text:
How to using Mesh for making transaction from specific address of seed and send ADA to another address
I was trying to make 1000 ADA addresses from one seed. I have used MESH and make payment addresses.
and deposit successfully on those addresses, now I need to send ADA from one of these generated addresses to another address using mesh and Blockfrost.
import { BlockfrostProvider } from '@meshsdk/core';
import { Transaction, ForgeScript, AppWallet } from '@meshsdk/core';
//ADA address generation
const blockchainProvider = new BlockfrostProvider('mainneteerretu');

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

const address1 = wallet.getPaymentAddress(854);
const address2 = wallet.getPaymentAddress(855);

const utxos = await blockchainProvider.fetchAddressUTxOs(address1);

const forgingScript = ForgeScript.withOneSignature(address1);

const tx = new Transaction({ initiator: wallet });
tx.setRequiredSigners([address1]).sendLovelace(
  address2,
  "1000000"
);

const unsignedTx = await tx.build();

const signedTx = await wallet.signTx(unsignedTx);

const txHash = await wallet.submitTx(signedTx);

please note me where must change.

At a first glance, the code looks ok. Can you please share more details on the problem? How do you start the code? Do you get an error message?

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


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:
Validator always accepts and Mints (but it shouldn't)
Hey I have this simple stupid validator:
validator {
  fn nft(datum: Datum, _redeemer: Void, context: ScriptContext) {
    let ScriptContext { transaction, purpose } = context
    when purpose is {
      Mint(policy_id) -> False
      _ -> False
    }
  }
}

Now when performing a call to this validator to Mint it still returns True for the transaction and the native token is minted. I'm confused, how can this be?

That is because the interface of the source you have is for a spending validator, and NOT for a minting policy.
Let me explain.
for the chain there is not difference between spending validators and minting policies, it is all just UPLC.
on top of that, the node considers any script that doesn't fail (aka. never evaluates an error) to be correct.
so when you run a script you apply a bunch of data and then you only check if it throws an error or not.
now, the key difference is that a spending validator expects 3 pieces of data ( datum, redeemer, context );
all the others (minting policies, staking validators, etc) expect only 2 pieces of data ( redeemer and context )
when you use your source ( that takes 3 inputs ) as a minting policy ( which expects 2 inputs ) the node only passes 2 of the 3 inputs.
now applying those two inputs is equivalent to a partial function application.
so the result of the application is a new function, and it is a totally valid evaluation because no error is evaluated!
basically, when applying only two inputs (as in this case) the evaluation always succeeds.

NOTE: behind the scenes aiken (and also plu-ts and many other languages) are wrapping your contract that returns a boolean in a simple "if then else" that evaluates an error if the condition is false!

Been trying so many different thinks... Also had with a redeemer datum and context only but also got an error. Seems like I must have forgotten to compile or something. It works now at least thank you

There is a misunderstanding regarding "Script purpose". From Alonzo ledger document,

The script purpose is passed to it to
allow the script to reference itself via its hash, and to be aware of what it is validating.

So for minting policy, it's often useful to know minting policy script's own currency symbol, which would hence be given via Mint script purpose.
For the validator which is taking in datum, then it's purpose is exactly to validate spending of script outputs. I.e., validating spending of a UTxO locked in this phase-2 script. It's script purpose can't be Mint as your code is assuming, but has to be Spending, where it would give you the output reference of the UTxO being spent in question.


text:
React.js version conflict between modules using Mesh.js and use-react-screenshot
I’m using a Mesh.js starter template that’s using React.js 18 version.  I also want to utilize a component called use-react-screenshot that is react.js version 17.  Unfortunately the component will not load because of the mismatch.  What’s the best practice to resolve the version conflicts?


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:
How to get listed in cexplorer.io/collection
Cexplorer shows "NFT Collections" tab for mainnet https://cexplorer.io/collection and preview https://preview.cexplorer.io/collection . How can collection end up listed there? I have minted nft collections on preview testnet but it's not showing up in https://preview.cexplorer.io/collection (there is only one collection listed in preview testnet atm of writing)
How does this work? Do I have to ping cexplorer team to list some policy as a collection?
Thanks for answers in advance!

collection data are obtained from jamonbread.io - if they list some collection, then is it available on Cexplorer.io
(preview is manual)

Disclaimer: This is just a best guess how I think it could be done.

Looks like on preview there is (currently) only 1 collection that they probably added manually just for testing.
On mainnet I would assume that they take the data directly from the blockchain or maybe from an API like the opencnft.io API or even from JPG.Store.


text:
blockfrost.io API, reference inputs and redeemer tx_index
AIUI, when using the blockfrost.io API, the tx_index field in a redeemer contains the index of the enclosing transaction's input that it consumes (is that true ?).
However, with reference inputs, it seems that in this API the reference inputs and "regular" inputs are all merged in the transaction's utxos.inputs list.
In that case, it looks the tx_index field in the redeemer no longer matches the index of the referenced input in the inputs list, but rather the position of the Nth non-reference input in the list.
Example:

without reference inputs:

utxos.inputs = [i1,i2,i3]`
redeemer.tx_index=2

In that case, the redeemer points at i3

with reference inputs (marked as ri):

utxos.inputs = [ri1, ri2, i1,i2,i3]`
redeemer.tx_index=2

In that case, the redeemer also points at i3 because the reference inputs are ignored in the indexing.
Can someone confirm that this understanding is correct, or provide the correct way of interpreting the redeemer's tx_index field ?

AIUI, when using the blockfrost.io API, the tx_index field in a redeemer contains the index of the enclosing transaction's input that it consumes (is that true ?).

The index holds different meaning for different purposes. For instance, if minting policies are involved in a transaction, index for a particular minting policy would be it's position in lexicographic ordering of the involved minting policies. For more information, see indexOf function in Alonzo ledger documentation. So, if you are only looking for indexes where purpose in response is set to spend then your understanding of tx_index is correct.
Now any output which is inside transaction_input then it is indeed getting consumed by the transaction (if it is of course successful), reference input(s) cannot be inside this transaction_input list. Provider's might mention it in input(s) but then they would also mention whether it's a reference input (in which case you can ignore it) or not. So, yes, your understanding on ignoring reference input(s) to determine for index is correct.


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:
Cardano-db-sync insertion error
I'm trying to sync data from Cardano using cardano-db-sync https://github.com/input-output-hk/cardano-db-sync, but the insertion process is stuck at epoch 323 due to the following error.
logs from cardano-db-sync container.
2023-09-05 11:46:20 [db-sync-node:Info:69] [2023-09-05 04:46:20.06 UTC] Setting ConsistencyLevel to Unchecked
2023-09-05 11:46:20 [db-sync-node:Info:69] [2023-09-05 04:46:20.06 UTC] Starting chainSyncClient
2023-09-05 11:46:20 [db-sync-node:Info:69] [2023-09-05 04:46:20.07 UTC] Suggesting intersection points from memory: [] and from disk: [At (Block {blockPointSlot = SlotNo 54172778, blockPointHash = cdf1659a3479ff45a5a82119992dce030df5dd8b0b1c77b40ba4fb64a22dfd57}),At (Block {blockPointSlot = SlotNo 53740772, blockPointHash = 87c4a226c0be561fc4046c6eb6329b83358aad467ed5ccdd8b606cbdb21c46c0}),At (Block {blockPointSlot = SlotNo 53308780, blockPointHash = 8ea9407d84e0dad7eb281d41a84a292d538575583548e1237db29af677bc9b23}),At (Block {blockPointSlot = SlotNo 52876752, blockPointHash = af192981f47a4150b4d4f96e2184050699febbbc31de18c3815bb5f338578ff6}),At (Block {blockPointSlot = SlotNo 52444775, blockPointHash = f041cf4833a057855654977df9fbe4f90f65b38c5403cad3d8b61d6015aa40db}),At (Block {blockPointSlot = SlotNo 52012780, blockPointHash = 1cef8acffe72da132b404da7d3e207e93fbbc6cb21f190bffe0969022e18dd98})]
2023-09-05 11:46:20 [db-sync-node.Subscription:Notice:54] [2023-09-05 04:46:20.07 UTC] Identity Required subscriptions started
2023-09-05 11:46:20 [db-sync-node:Info:69] [2023-09-05 04:46:20.08 UTC] Cardano.Db tip is at slot 54189281, block 6924046
2023-09-05 11:46:20 [db-sync-node:Info:75] [2023-09-05 04:46:20.08 UTC] Running DB thread
2023-09-05 11:46:20 [db-sync-node:Info:76] [2023-09-05 04:46:20.08 UTC] Running Offline fetch thread
2023-09-05 11:46:20 [db-sync-node:Info:75] [2023-09-05 04:46:20.10 UTC] Delaying delete of 761 blocks after Just 6923285 while rolling back to (slot 54172778, hash cdf1659a3479ff45a5a82119992dce030df5dd8b0b1c77b40ba4fb64a22dfd57). Applying blocks until a new block is found. The node is currently at Tip (SlotNo 85337653) dc36cb4b276a4647efa8e53b6e86a93cef0c4964d12b8f90c3d9cc0e7228c684 (BlockNo 8423610)
2023-09-05 11:49:45 [db-sync-node:Info:75] [2023-09-05 04:49:45.52 UTC] Found snapshot file for slot 54172778, hash cdf1659a3479ff45a5a82119992dce030df5dd8b0b1c77b40ba4fb64a22dfd57. It took 2.359985918s to read from disk and 203.053995538s to parse.
2023-09-05 11:49:48 [db-sync-node:Info:75] [2023-09-05 04:49:48.04 UTC] Found snapshot file for slot 54172778, hash cdf1659a3479ff45a5a82119992dce030df5dd8b0b1c77b40ba4fb64a22dfd57
2023-09-05 11:49:48 [db-sync-node:Info:75] [2023-09-05 04:49:48.05 UTC] Setting ConsistencyLevel to DBAheadOfLedger
2023-09-05 11:50:16 [db-sync-node:Info:75] [2023-09-05 04:50:16.92 UTC] File /var/lib/cexplorer/54172778-cdf1659a34-322.lstate exists
2023-09-05 11:50:19 [db-sync-node:Info:75] [2023-09-05 04:50:19.60 UTC] Reached EpochNo 323
2023-09-05 11:50:31 [db-sync-node:Info:75] [2023-09-05 04:50:31.79 UTC] Received block which is not in the db with HeaderFields {headerFieldSlot = SlotNo 54189303, headerFieldBlockNo = BlockNo 6924047, headerFieldHash = 5ebbb8ce01d25918903b804b003094545a7111d8763e71ff0c14c33898358bd0}. Time to restore consistency.
2023-09-05 11:50:31 [db-sync-node:Info:75] [2023-09-05 04:50:31.80 UTC] Starting at epoch 323
2023-09-05 11:50:32 [db-sync-node:Info:75] [2023-09-05 04:50:32.84 UTC] Insert Alonzo Block: epoch 323, slot 54189303, block 6924047, hash 5ebbb8ce01d25918903b804b003094545a7111d8763e71ff0c14c33898358bd0
2023-09-05 11:50:33 [db-sync-node:Info:75] [2023-09-05 04:50:33.11 UTC] Setting ConsistencyLevel to Consistent
2023-09-05 11:50:33 [db-sync-node:Error:75] [2023-09-05 04:50:33.26 UTC] Error: resolveTxInputs TxIn {txInHash = "\140+<\254\229\168\\ \234\156\246\216\251\208\&1\193X\203\130\249\DLE\242\226\219\f\GS\148\NUL\184\EM\137\223", txInIndex = 0, txInRedeemerIndex = Nothing}  tx hash 8c2b3cfee5a85c20ea9cf6d8fbd031c158cb82f910f2e2db0c1d9400b81989df
2023-09-05 11:50:33 [db-sync-node:Info:75] [2023-09-05 04:50:33.26 UTC] Shutting down DB thread

Could anyone help to fix it, please?
Thank you

Is this mainnet?
Your issue is at epoch 323 which is from over a year ago. Are you trying to sync from scratch? If so, why, we provide snapshots which only take hours to install.

yes, this is mainnet, I'm following the guide https://github.com/input-output-hk/cardano-db-sync and just run docker-compose up. The sync process is from epoch 0. Could you share where the snapshots are? and will they contain all the history tx of wallets?

The snapshots are linked from the Github releases page and the docker compose file allows the specification of a snapshot. Sorry, can't help more than that because I do not know much about docker.

Thank you. I found the document here https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/state-snapshot.md. it's very useful


text:
From where can i get the stake address while integrating cardano blockchain with flutter using blockfrost
I am using this package https://pub.dev/packages/blockfrost to integrate the Cardano smart contract with my Flutter application. I want anyone can log in to the app and interact with the contract so I will not pass a static stake address in the following api call .


text:
Error submitting a transaction (Error: PPViewHashesDontMatch)
I hope I can get help from someone on here. I built a minting transaction on preprod using Lucid that uses a validator that always pass, and I am stuck with this error:
error: Uncaught (in promise) Error: "transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (MissingRedeemers [(Minting (PolicyID {policyID = ScriptHash \"e6584023b2579776600aaefc75c081ef027c5860a8dc7504b7b4d18c\"}),ScriptHash \"e6584023b2579776600aaefc75c081ef027c5860a8dc7504b7b4d18c\")])),UtxowFailure (FromAlonzoUtxowFail (PPViewHashesDontMatch SNothing (SJust (SafeHash \"75be5e37c2a7f07027713f0cf852aabedb84498d31182e96a4d2390dc2817d3f\")))),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (UtxosFailure (CollectErrors [NoRedeemer (Minting (PolicyID {policyID = ScriptHash \"e6584023b2579776600aaefc75c081ef027c5860a8dc7504b7b4d18c\"}))]))))])"
here is the built transaction:
  .newTx()
  .collectFrom([utxo], Data.void())
  .attachMintingPolicy(into)
  .attachMetadata("721", metadata)
  .mintAssets({ [assetName]: BigInt(1) })
  .payToContract(
      contractAddress,
      { inline: Data.void() },
      { lovelace }
  )
  .complete();

const txSigned = await tx.sign().complete();

const txHash = await txSigned.submit();

After a thorough testing, I found that the problem is in .attachMintingPolicy (into) where into is the validator. Here is the validator definition:
  const validator_ = JSON.parse(await Deno.readTextFile("plutus.json")).validators[0];
  return {
    type: "PlutusV2",
    script: toHex(cbor.encode(fromHex(validator_.compiledCode))),
    };
  }
const validator = await readValidator();

corresponding aiken code:
validator {
  fn store(datum: Data, context: Data) -> Bool {
    1 == 1
  }
}

Does anybody know what's going on? Thanks in advance.

There are at least 2 errors in the message you showed, we'll go over them
MissingRedeemers
This is the very first; you should always look for the errors from the first to the last.
In particular the error comes with wome additional infos: "(MissingRedeemers [(Minting (PolicyID {policyID = ScriptHash \"e6584023b2579776600aaefc75c081ef027c5860a8dc7504b7b4d18c\"}),ScriptHash \"e6584023b2579776600aaefc75c081ef027c5860a8dc7504b7b4d18c\")]))"
which indicates the hash of the minting script that is missing the redeemer.
You need to specify your redeemer even if it is not used in the contract.
You probably want to specify it in the "mintAssets" call.

NOTE there is a third error (CollectErrors [NoRedeemer ... which is realted to this one, the reason for this should be the same.

PPViewHashesDontMatch
This is an error raised only during transaction submission.
In particular, every transactions that uses a plutus script needs to include the current protocol parameters cost models.
This should be done automatically by lucid to my uinderstanding, so you likely want to make sure you are using the correct network ( if you are submiting in preview testnet you need to build the transaction for preview testnet, not for some other network (eg. mainnet))

Heyyyyyy Michele!!!! Adding Data.void() in the .mintAssets solved the problem. Thankssss alot!


text:
How to format metadata for Lucid?
Our metadata as a CIP 25 looks like this:
Pool pm metadata tool
We are using Lucid to attach it during transaction building in this way:
const filename= "https://arweave.net/" + arweaveId
      const metadata = {
        [policyId]: {
          "Origin Certificate": {
            "description": [
                "Village": "Los Hornos, Comayagua",
                "Country": "Honduras",
                "Grower": "Nelvin Humberto Vaquis",
                "SCA Grade": "85",
                "Altitude": "5245 ft",
                "Variety": "Parainema, PACA, & H-90",
                "Characteristic": Citrus Flavor, Floral Tones",
                "Bean": Medium Complexion"
            ],
            "files": [
               {
                  "mediaType": "image/png",
                  "name": "Origin Certificate",
                  "src": filename
               }
            ],
            "image": filename,
            "mediaType": "image/png",
            "name": "Origin Certificate"
          }
      },
      version: "1.0"
      };

But something exceeds the character limit even though none of the strings exceed 64 characters. Also, removing the quotation marks removes the error about the character limit but the metadata doesn't format correctly.
To attach the metadata we do the following:
.attachMetadata(721, metadata)

What could we change to eliminate the issue?

From the looks of it, file links are too long. Have you tried shortening links, or using different file hosting service?
Try something that looks more this: Pool pm metadata tool.


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:
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:
db-sync not syncing
I've restored a recent db-sync snapshot (I am running node 8.1.2). The restore was successful; I can run SQL queries against the default cexplorer database. However, there seems to be an issue when I begin running db-sync to sync the rest of the way.
For context, I am using the Guild Operator's scripts (.dbsync.sh -d); the systemd service deploys successfully, but after several hours the (restored) database still appears not to be syncing, as evidenced when I run:
cexplorer=# select now () - max (time) as behind_by from block ;
       behind_by
------------------------
 5 days 22:44:28.094372
(1 row)

And after several minutes:
cexplorer=# select now () - max (time) as behind_by from block ;
       behind_by
------------------------
 5 days 22:58:38.184134
(1 row)

The behind_by value keeps increasing, so I assume the databse is not syncing.
Here are the log message(s) after running tail -10f $CNODE_HOME/logs/dbsync.json:
{"app":[],"at":"2023-09-13T20:45:54.69Z","data":{"kind":"LogMessage","message":"Handling input offset 22100000"},"env":"<unknown>:00000","host":"","loc":null,"msg":"","ns":["db-sync-node"],"pid":"918006","sev":"Info","thread":"6"}
Any ideas what could be wrong or what the log message means?

The reason why its not syncing will almost certainly be obvious if you look at the logs of both the node and db-sync.

I asked cause I'm definitely a noob.
I suspect it has something to do with the "Handling input offset" message, but not sure what it means.

Nothing to do with that message. That is an effect not a cause and it gives zero clue as to the actual cause.

so then which log files are you referring to?

The logs for the node and the logs for db-sync. One or the other should have the proper cause. I am not familiar with the Guild operator scripts so I am not sure where the log files are. Probably in $CNODE_HOME

Few checkpoints for you before you even start:

Check status for services:
sudo systemctl status cnode
sudo systemctl status cnode-dbsync
Since you've used Guild-Ops scripts, you've already got gLiveView installed in $CNODE_HOME/scripts folder. I assume you went through documentation to ensure you've updated variables in env file.
Before looking at dbsync, I'd first recommend you ensure your node is working and in sync - gLiveView gives a nice little overview to check status of your node.
All the logs are in $CNODE_HOME/logs folder, the node (by default) would be node0.json. So if any of the component isnt working, you'd need to check corresponding log file for the cause.


text:
How to Pull Transaction Information Using lucid-cardano Library in TypeScript?
I'm working on a Cardano project using TypeScript, and I'm trying to fetch transaction details using the lucid-cardano library. Specifically, I have a transaction hash and I'm interested in retrieving all related information, such as the spent UTXOs.
Here is some pseudo-code to illustrate what I'm trying to achieve:

import { SomeModule } from 'lucid-cardano';

const txHash = "some_transaction_hash_here";

async function getTransactionInfo(txHash: string) {
  // Code to pull transaction info using lucid-cardano
}

getTransactionInfo(txHash)
  .then(info => {
    console.log('Transaction Info:', info);
  })
  .catch(err => {
    console.error('An error occurred:', err);
  });

I'm facing difficulties in figuring out the appropriate API calls or methods provided by lucid-cardano to achieve this. The library documentation is not very detailed in this. If lucid-cardano is not suitable for this task, are there any alternative libraries that could serve the purpose?
I'm using Blockfrost as provider.
Any help would be greatly appreciated. Thank you!


text:
How to deserialize Datum using Lucid
The following code allows me to query a Datum from the blockchain using Lucid and Blockfrost:
import { Blockfrost, Lucid } from "https://deno.land/x/lucid@0.10.7/mod.ts";

const lucid = await Lucid.new(
  new Blockfrost(
    "https://cardano-preview.blockfrost.io/api/v0",
    <your BLOCKFROST_API_KEY>
  ),
  "Preview"
);

const nft = "b7e0e70f653f23abc39d16f6f6be16fd72e3fe3030db9b16cecccf68524549545f5354415445";  // example

const utxo = await lucid.utxoByUnit(nft);
const datum = utxo.datum
console.log(datum);

The output to the console, for this example, is:
d8799f1903e819f80c1903e81903e8ff

My question now is, what command in Lucid allows me to deserialize this output?  I don't even know what kind of encoding I am dealing with (I suspect it is CBOR).
By the way, I know that the desired deserialization, for this example, should be:
{
   constructor: 0,
   fields: [
      {
         int: 1000
      },
      {
         int: 63500
      },
      {
         int: 1000
      },
      {
         int: 1000
      }
   ]
}

I figured out that the Lucid command that does the trick is Data.from.  First, in the original code, I need to add Data in the list of imports:
import { Blockfrost, Lucid, Data, } from "https://deno.land/x/lucid@0.10.7/mod.ts";

Then simply add:
const solution = Data.from(datum);
console.log(solution);

at the end of the original code.

Still it would be nice to know if it is indeed CBOR the encoding from which Data.from deserializes.


text:
Is there any way to wrap a cardano native asset to eth?
I am looking for wrapping some native cardano tokens to the etherium network is there any way to achieve the same? Any help or urls will be very helpfull.

It can be done with Milkomeda C1 sidechain and Nomad bridge. See the Ethereum to Cardano walkthrough here: https://medium.com/@wingriderscom/how-to-transfer-erc20-assets-to-cardano-ba9c7b9b5a5

there is only limitted number of tokens are available if i want to wrap a token which is not in at thease list what i have to do for example a nft.

I am accepting the answer how ever there is no way to wrap many tokens out there nfts also a problem now.


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

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

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

You probably need to install libsystemd-dev.

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

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


text:
cardano-db-sync How could we define an asset as NFT?
Could anyone tell me if is there any way to check if an asset is NFT using the database of cardano-db-sync?
I tried to look at tx_metadata table and check if in json field contains an image, but many NFTs do not have an image.
I also tried considering an asset as NFT if the mint quantity of them is equal to 1, but it seems that some NFT could be minted more than once and burn as well
Thank you


text:
Coming from ethereum I am looking for the Cardano equivalent of https://remix.ethereum.org/ for quick development
I am coming from the Ethereum world, where I got started with https://remix.ethereum.org/ really fast. What is the equivalant in the Cardano world so that I can experiment fast just using my web browser and without having to install anything (except for an Eternl wallet)?


text:
Getting error while submit sign transaction
I am try to submitting sign transaction on Rosetta (https://ada-rosetta.nownodes.io/construction/submit) but, each time getting below error.
TTL is already higher than slot.
Request
{
    "network_identifier": {
        "blockchain": "cardano",
        "network": "mainnet"
    },
    "signed_transaction": "83a40081825820a92992d62f7a3403db8f7e6b70c474d243a42f3bde6fce885c0269468234b9b8000182825839014ce3b447716ce9779e16b741d2f44c4ee8a8d0925a3795fb6ed5a2238f6da85dc3995f61843359f243e7ec30c874a865ec1e3779505488c91a00e4e1c0825839014a4ae28d8b0efdf3464b6103baef51db26f72b249a1577837d114382b0d3859a1daefbdc0ba7cd9f196367a8cad5ccfe36625578246f04fa1a09b18edd021a000292a3031a062c277da10081825820ef6a319263c403d52eadec3afe9430431f65ea5a3a2a1d6d8b88dde7c68d3ccf5840f2fc07145f3a004119e2511f0f8ad752c54c97f5fe174b14246ddef7336009d9152770fe065a397a57663d4774e922112e76191eb58dcb57b0f5fed75ecc6e0cf6"
}

Response
{
    "code": 5003,
    "message": "Parse signed transaction error",
    "retriable": false
}


text:
Why is there no real Wallet Plugin for Firefox
It seems that wallets are not able to implement cip30 for firefox, what is the hurden to do it, and why does it work for chrome?

This has been an issue since a long time. At least for Nami, it is possible to add the extension to Firefox, but the performance is horrible.
See: https://github.com/berry-pool/nami/issues/68
It seems like no one took the time to look into this yet even though there are quite some users requesting Firefox support.

so it is technically possible but there is just not enough demand?

Yes, it is for sure technically feasible. Ethereum wallets like Metamask also work in Firefox.

i mean not a wallet it self, i mean the CIP-30 connector, which enables websites to communicate with the wallet


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:
How to query cardano blockchain related data like createwallet, getnewaddress, getbalance , sendtoaddress
I have done cardano node setup and sync it 100% And also install an cardano wallet using CLI. Now I want to interact with cardano using node js, can someone please tell me how we can do basic operation like create wallet, getnewaddress, transafer or sendtoaddress , getbalance. or which libraries we can use. or Are there any RPC method by using that i can query blockchain related data.


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:
What DAPPS Can Be Built On EUTXO Chains That Account Based Chains Cannot Make?
I remember reading that the EUTXO model is a superset of the account-based model. My question is does this mean that there are some types of Dapps that can only be built on EUTXO chains, and if so what are they?


text:
Historical price data for Cardano native assets
Does anyone know where I can get historical price data for Cardano native assets? Data that can subsequently be used for data analysis and visualization. Something similar to what taptools is using highs, lows, pct change, etc.
Thanks in advance

i think you are out of luck with this one
only way to do this from the start of smart contracts and accurately would be to parse dex transactions on the blockchain
the good thing is there aren't that many dex's, especially in the early days, unfortunately it'll likely require collaboration with some dexes to pull it off
imho the only viable solution for your use case is to stick with taptools data along with additional feeds from coinmarketcap for the handful of native tokens that are on there


text:
Restore state snapshot running out of disk space
I'm following this guide to restore the latest state of the chain to my local machine
https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/state-snapshot.md
while running the restore job as the following command. it consumes significant amounts  of free disk space
PGPASSFILE=config/pgpass-mainnet scripts/postgresql-setup.sh --restore-snapshot /Users/manhdt/Downloads/db-sync-snapshot-schema-13.1-block-9348936-x86_64.tgz /Users/manhdt/ledger-state/mainnet

Included 53GB of the latest snapshot https://update-cardano-mainnet.iohk.io/cardano-db-sync/index.html#13.1/. My Macbook (32 GB RAM, 512GB SSD) still has over 320GB of free disk space. However, it reduces pretty fast and my Mac runs out of space after a while (approximately 1 -> 2 hours).
Does anyone could help to pass this issue?
Thank you

I am not aware of any work around from this other than providing extra disk space. Maybe a temporary (ie, just during the restore operation) external disk may be a solution.

Thanks. I've removed the compressed file during the insertion process to claim extra space

The snapshot file will be copied to another folder during the insertion process. Then it's safe to delete it to claim more than 50Gi free space.
Thanks


text:
Unable to interact with cardano blockchain using cardano-wallet-js
My node is running on 6000 port. And cardano-wallet is running on 6002 port.
ubuntu@ip-172-31-44-6:~/cardano/testnet$ netstat -tuln | grep 6000
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN
tcp6       0      0 :::6000                 :::*                    LISTEN
ubuntu@ip-172-31-44-6:~/cardano/testnet$ netstat -tuln | grep 6002
tcp        0      0 127.0.0.1:6002          0.0.0.0:*               LISTEN
But I unable create wallet using cardano-wallet-js. getting Error: connect ECONNREFUSED 0.0.0.0:6002 .
Script*********
I am trying with below script. I tried using ('http://127.0.0.1:6002/v2') this url also but still unable to connect or do operation on cardano node using script.
import { WalletServer } from 'cardano-wallet-js';
const walletServer = WalletServer.init('http://0.0.0.0:6002/v2');
// const walletServer = WalletServer.init('http://127.0.0.1:6002/v2');
import { Seed } from 'cardano-wallet-js';
// generate a recovery phrase of 15 words (default)
let recoveryPhrase = Seed.generateRecoveryPhrase();
//For convenience, you can convert the recovery phrase into an array using this:
let words = Seed.toMnemonicList(recoveryPhrase);
// console.log(words);
let mnemonic_sentence = Seed.toMnemonicList(recoveryPhrase);
let passphrase = 'tangocrypto';
let name = 'tangocrypto-wallet';
let wallet = await walletServer.createOrRestoreShelleyWallet(name, mnemonic_sentence, passphrase);
console.log("wallet",wallet);
// List wallets:
let wallets = await walletServer.wallets();
// console.log("Wallets", wallets);
######################Error######################
<ref *1> Error: connect ECONNREFUSED 127.0.0.1:6002
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {


text:
How to get pointer to an actual cardano address by pool script hash in format "script...."?
The address format is script15ew2tzjwn364l2pszu7j5h9w63v2crrnl97m074w9elrkxhah0e. In this example from https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/minswap/index.js, you can observe that by using the address in the format script... with the getAdaInAddress function, Koios will return it.
However, achieving the same result with Cardano-db-sync is a bit more challenging. I couldn't find any reference to the script... format in the database.
I also attempted to use https://www.npmjs.com/package/cardano-addresses, but this format triggered an error with the inspectAddress function.


text:
Getting problem with sendPayment method in cardano-wallet-js
I am following (https://developers.cardano.org/docs/get-started/cardano-wallet-js/) this document for development using cardano-wallet-js. And using below script for sendPayment, but getting error to send payments.
import fetch from 'node-fetch';
const walletId = "b2eaa569bf27180c9806783bdd75dd145e216ae2";
const resp = await fetch(http://0.0.0.0:8236/v2/wallets/${walletId});
const wallet = await resp.json();
let receiverAddress = [new AddressWallet('addr_test1qzhg95y7f9kh23qwu0hmnncs8lg3ezk2vw5980e27cmv2cn4r5r6cmxxf3qqhhz49shud34ye7ppk3gq5zu7gagd2wzs6v2zcs')];
let amounts = [5000000]; // 5 ADA
let transaction = await wallet.sendPayment(receiverAddress,amounts);
Error:---
let transaction = await wallet.sendPayment(receiverAddress,amounts);
^
TypeError: wallet.sendPayment is not a function
at file:///home/ubuntu/cardano-git-repo/cardano_raw_api/scripts/sendtoaddress.js:12:32
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v18.18.0


text:
Asses Utxos Time In On-Chain Code
Can you assess the time a Utxo was created in on-chain code?
i.e. A transaction to a smart contract that can claim  only Utxos - in that contract address - sent in a specific time period?

Pretty sure that is possible with cardano-db-sync.
Every new UTxO is created by a transaction, which is part of a block and the block will have a timestamp.

is that something queriable from the script context for any utxo input in the tx to the validator?

I was wondering if is something than can be extrapolated from script context with PlutusTx, so provable from the script/validator itself, but I don't think so


text:
Platforms calculating epoch start/end timestamps off by 1 second?
I've seen this many times now and I believe it's wrong, or at least strange. I'd like to see what you folks have to say.
Let's take a look at any random epoch, say 400, and request Koios, Blockfrost and Cardanoscan to get the start/end timestamps.
They all show the same timestamps: 1679003091 to 1679435091. This suggests timestamp 1679003091 is the first and 1679435091 the last second of epoch 400, doesn't it?
At the time of writing, an epoch is configured to have 432,000 slots and each slot equals one second. Since slots are the smallest entity we don't need to care about milliseconds.
How do these platforms calculate the timestamps: I believe they take the genesis block timestamp of epoch 0 at 2017/09/23 21:44:51 and keep adding 432,000 seconds. Yes, I am aware Byron era had a different slot configuration, but it doesn't matter here as the result is the exact same length in terms of time (432,000 seconds per epoch).
This doesn't seem wrong on the first glance. But timestamp 1679435091 of epoch 400 is the first second of that epoch, so it counts as 1, not 0. Adding 432,000 seconds to 1 results in 432,001 seconds.
Let's take a look at epoch 401 now. We find the epoch's start timestamp to be the exact same as the end timestamp of the previous epoch. This seems wrong. Epochs don't overlap.
Shouldn't we treat the first slot of an epoch as 0? It'd result in a clean continuation of time without bleeding into the next epoch.


text:
How to query input UTXOs of a transaction
Could anyone help to query input UTXOs of a transaction, please?
I tried to use tx_in and tx_out tables to view the detail inputs and outputs of the transaction https://cardanoscan.io/transaction/81a53921f59028c56eb7920d944d1db5997f27fbae249fa520413990c4a7d944?tab=utxo
First of all, I could get the outputs of the transaction easily by using the following query

However, when trying to get Input UTXOs using SQL queries, there was an issue I would like to describe as the following.

I've tried to query data from tx_in table to get tx_in_id that is used for the transaction

select * from tx_in where tx_out_id = 76360126; -> There are 2 tx_id 76360263 and 76363286

2. Then I tried to query back to the table tx_out with 2 above tx_id. However, it shows more addresses than those on Cardanoscan; some are not actually used in the transaction. How Could I get the exact Input UTXOs of a transaction?

You are probably looking for this:
https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/interesting-queries.md#transaction-inputs-for-specified-transaction-hash

Yeah, Thank you. The query works fine.

I'm glad to hear it.


text:
DBSync: Querying ma_tx_out
I queried ma_tx_out and used the fingerprint of an asset to get its ident so I could get the tx_out_id to get the most recent tx_out for a given asset - but that asset is only in that tx_out because the UTXO has that asset in it, and was used as a part of a transaction that has nothing to do with that asset itself being transferred to another wallet, or contract etc.
How can I filter starting from ma_tx_out  so I am only looking at the latest tx that involves THAT asset directly rather than indirectly?
Scenario A: Asset X is sent from Wallet Z to another wallet
(this is one I want to retain as the tx involves Asset X directly)
Scenario B: Wallet Z transfers some ADA to another wallet, and Asset X is found in one of the UTXO's involved in the transaction.
(this one I don't want to retain, as Asset X is only involved in the tx indirectly)

Do you mean that in latest tx_out that you currently find for an asset, it didn't actually change hands but was transferred back to the same address as it came from?

Correct. It is on the same address in the outputs as it is on the inputs. I have resolved my "issue" by examining both inputs & outputs.

It you join the tx (and the ma_tx_out table should reference tx) table with the block table then block.block_no increases by 1 each block. The you just need to filter by all block.block_no bigger than the one you want.

In this one for example:
https://cardanoscan.io/transaction/38e7ca5d1419bd8ce5e10b1723a223f6ab8fe3b4f4738d23988f26daa5d8c705?tab=utxo
How can we tell that the "Summary" of this tx is a simple transfer of ADA, and that even though there are other assets on the UTXO's involved, those assets themselves have nothing to do with the actual tx being performed, except indirectly?
The "Summary" on this one is "91 ADA moved from here to there" - but the assets on the UTXO's involved appear to be a part of the tx when I query from the perspective of ma_tx_out

The ADA transfer and the other asset transfers are all part of the same transaction. I would not call that an "indirect" association. ADA tx_out values can be associated with multi asset tx out entries because they the ma_tx_out table will have a tx_out_id field that points back to the tx_out table.

Agreed. However, look at this one, the summary shows it is a simple transfer of 91 ADA:
https://cardanoscan.io/transaction/38e7ca5d1419bd8ce5e10b1723a223f6ab8fe3b4f4738d23988f26daa5d8c705?tab=summary
"Summary" shows a transfer of 91 ADA. "UTXOs" has one which has several assets on it and 2 ADA.
When I query ma_tx_out for latest using the fingerprint of any of those assets, I get that tx, even though the tx is about a transfer of 91 ADA as opposed to having anything to do with the transfer of any of those assets on that utxo. In my case, I'd like to ignore that tx, but not sure how.

Put another way, for this one:
https://cardanoscan.io/transaction/38e7ca5d1419bd8ce5e10b1723a223f6ab8fe3b4f4738d23988f26daa5d8c705?tab=summary
How does Cardanoscan know to have the transfer of the 91 ADA in the "Summary" tab? How does it determine from the tx that a transfer of 91 ADA is all that tx effectively did?

I don't know how cardanoscan does it, but if I was asked to replicate it, I would a build a query that for a transaction queries both the tx_out table and the ma_tx_out table. For a tx that only transfers ADA, the returned ma_tx_out output would be empty.


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:
Missing inline_datum_id in tx_out table
I'm trying to get the specified transaction's datum value, but it didn't appear in the cardano-db-sync db. Can anyone enlighten me, please?
the transaction: https://cardanoscan.io/transaction/74b2639cb3bf558545e1bf4f5117d006c093385dadf539f41295153192af0ebf?tab=utxo

Datum and inline_datum_id didn't appear (NULL value) in the tx_out table as the following

select
    address,
    inline_datum_id,
    (select substring(cast(hash as varchar),3) from tx where id = T1.tx_id) txhash,
    (select value from datum where tx_id = T1.tx_id) datum
from tx_out T1
where tx_id = 75437263

address                                                                                |inline_datum_id|txhash                                                          |datum|
-------------------------------------------------------------------------------------------------------+---------------+----------------------------------------------------------------+-----+
addr1z8snz7c4974vzdpxu65ruphl3zjdvtxw8strf2c2tmqnxzv34sh40d6k0vud6w4mkqew7gsr3fuw7pu7jerszgghjk0s5xtpcd|               |74b2639cb3bf558545e1bf4f5117d006c093385dadf539f41295153192af0ebf|     |
addr1q9kmkl3xwjm9sxymcppx7jlft8vr4ux6v2wp5c8x49pamdf557v3rld8xnpm79a8h8wcvs7fy78zlth6vae0nxyq7aksnectvv|               |74b2639cb3bf558545e1bf4f5117d006c093385dadf539f41295153192af0ebf|     |
addr1qx7tzh4qen0p50ntefz8yujwgqt7zulef6t6vrf7dq4xa82j2c79gy9l76sdg0xwhd7r0c0kna0tycz4y5s6mlenh8pqrkj6fh|               |74b2639cb3bf558545e1bf4f5117d006c093385dadf539f41295153192af0ebf|     |

It still appears on cardanoscan.io: https://cardanoscan.io/transaction/74b2639cb3bf558545e1bf4f5117d006c093385dadf539f41295153192af0ebf?tab=utxo

Actual datum value: https://cardanoscan.io/datumInspector?datum=d8799fd8799f4040ffd8799f581ccded41e880c3facb6364e903d9830d52bb12fcf10f6401eda355fbd24653414c4d4f4eff1a0bebc20000d8799fd8799fd8799fd8799f581caafb1196434cb837fd6f21323ca37b302dff6387e8a84b3fa28faf56ffd8799fd8799fd8799f581c52563c5410bff6a0d43ccebb7c37e1f69f5eb260552521adff33b9c2ffffffffd87a80ffffff
Thank you

Because Cardanoscan does lots of processing most of the time to derive the datum value even if it is not part of the output. Thanks

A tx_out may have a datum_hash, without having an inline_datum_id, since not all datums are inlined. Inline datums were introduced in the Babbage era as an optimization mechanism.
Also, the Tx that you mentioned runs some Plutus scripts. This implies that it consumes and does not necessarily create outputs that have a datum. So you should probably check the tx_in of the tx and not its tx_out.


text:
Cannot find utxo using cardano-cli on docker cardano-node preprod
I am trying to follow the project based learning program but get stucked here:
https://plutuspbl.io/modules/102/1023
I started the docker container for cardano-node (https://hub.docker.com/r/inputoutput/cardano-node) like this:
docker pull inputoutput/cardano-node:1.35.3-configs
docker run -e NETWORK=preprod inputoutput/cardano-node:1.35.3-configs
export CARDANO_NODE_SOCKET_PATH=/ipc/node.socket

Updated according to previous answer but still not working:
docker pull inputoutput/cardano-node:8.1.2
docker run -e NETWORK=preprod inputoutput/cardano-node:8.1.2

I created my address as described (https://plutuspbl.io/modules/102/1022):
cardano-cli transaction build \
--babbage-era \
--testnet-magic 1 \
--tx-in $UTXO_IN \
--tx-out $SENDERADDRESS+$LOVELACE_TO_SEND \
--change-address $SENDERADDRESS \
--out-file simple-tx.raw

cardano-cli transaction sign \
--signing-key-file $SENDERKEY \
--testnet-magic 1 \
--tx-body-file simple-tx.raw \
--out-file simple-tx.signed

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

Sending ADA using Lace in Preprod works. I can see the transaction here:
https://preprod.cardanoscan.io/address/00afb85707bc11b8a018610da4b79f73d2c3553dedce2a8a414bd2eb974326c013bb1e3aae31194b06e23222a9e47e481db054447fcfae217f
But I cannot find the utxo using
cardano-cli query utxo --testnet-magic 1 --address $SENDERADDRESS

As SENDERADDRESS I tried the generated wallet address (as shown in the lecture) and also my lace address but both are just showing empty results (line of dashes).
If I was using the wrong network not even sending the ADA from Lace should have worked right? Any suggestions what might be wrong?
Update: Turned out I just did not wait long enough. The block of the container tip must of course be greater than the block containing the transaction:
cardano-cli query tip --testnet-magic 1

That's an old node version that can't cross the Babbage hard fork. Please update to 8.1.2.

Thanks for your answer. I tested again using

docker pull inputoutput/cardano-node:8.1.2
docker run -e NETWORK=preprod inputoutput/cardano-node:8.1.2

Again no result using the cli but I can find it here: https://preprod.cardanoscan.io/address/00b52857af1ed681cde138710077c887931fbd31c4718543f0a2bd2d7d83d03c257a1c1fe6763034537ec9c1a0c8261054a7909d527f4ce87d
Any suggestions? Also from the documentation I expected a version like 8.1.2-configs but it seems 1.35.3-configs was the only tag with a -configs postfix. Are the configs now included in every release?


text:
I want to mint an NFT using a JSON file using plu-ts, but I dont know how and where to start
I want to mint an NFT using a JSON file using plu-ts, but I don't know how and where to start.
Do I need to create a Node? OR Do I need to write it in Haskel? I have read and performed everything from the official documentation of the plu-ts but it has been confusing for me. If anyone can help me out here I'll be very thankful. Even a video would help.

Why plutus? It sounds like a native script is perfect for your use case. https://developers.cardano.org/docs/native-tokens/minting/


text:
How web3 protocols know which UTXOs should be consumed
I'm trying to get the history interaction of a wallet on Levvy Fi via Cardano db sync. But I find it difficult to understand how Levvy Fi generates a wallet with their scripts and how they know which UTXOs could be consume from their side.
Could anyone explain to me how protocols know which UTXOs should be consumed and which UTXOs they have the right to consume?
For instance, this transaction has 2 UTXOs that have a script generated by Levvy.Fi
https://cardanoscan.io/transaction/ef276d849fffe232c999cd802a4197eb3bd5c9ced90f1ec92b1c5446332553b5?tab=utxo
But How Levvy.Fi knows that they have the right to consume these 2 UTXOs. Assuming that in the wallet "addr1zy6r74xk4haj26c7jpq6w25t2xt8qzr9wr2kz805n8re02nsxfk6rvced60w4h629n75rs2wsfpyg5yjuxjc3rvd0adqh0f057" have many UTXOs available.

I don't know what Levvy.Fi does, but anyone knows which UTXO they can spend by looking at UTXO's address -- they can spend it when:

it's a hash of a key (wallet) they control, or
if it's a hash of a script they know the source for and can provide a redeemer for

Which specific UTXOs to spend is up to the spender (application, wallet) to choose arbitrarily.


text:
Graphql-engine docker images
Anybody now the github for how the following docker images are being build.
https://hub.docker.com/r/inputoutput/cardano-graphql-hasura/tags
The image is used in https://github.com/cardano-foundation/cardano-graphql/releases
Thanks in advance!
Maarten


text:
In which cases Plutus compiler is producing expensive code?
I have heard a couple of times, that is hard to make Plutus produce non-costly code, and one should consider writing scripts on a level with Plutarch's help instead. Still, I never get real reasons and examples for this.
Only case I am aware of are problems unnecessary Scott-encoding, but I am not aware of details.
Is this problem real and still relevant? If so in which cases does one get it, and how it may be mitigated? Can it be done with an external optimization pass, like plutonomy or Plutus options tweaking?


text:
Stopping Cardano node... Daedalus Mainnet (5.3.0#44942bd51)
I have just installed Daedalus Wallet V. 5.3.0 for the first time, in order to stake my ADA Cardano 3,800.00 tokens. I ran the 24 hour initialization synch before loading any ADA. that worked fine. then I proceeded to load my tokens: test 1 was from Coinbase of 39.00 tokens, it transferred and registered fine in the New Wallet. Then I transferred a second batch of 39.00 tokens from Binance-US to the Daedalus Wallet, that also transferred fine and showed in the wallet. Then I transferred the final large batch of Tokens from Binance 3700+ tokens to the Daedalus Wallet. That batch also showed up in the Cumulative total in the Wallet. I was getting ready to stake the tokens was checking out the Menu options, and i got a new screen:  Daedalus Mainnet (5.3.0#44942bd51)
Daedalus  Edit   View   Help
And and active Image updating over and over with a message below
Stopping Cardano node...
This process updated the databases and could take several minutes.
To preserve the data integrity, please wait until this process is complete.
then 4 symbols below: the on/off button (active), (the rest of the icons are grayed out inactive) sound icon, clock Icon, Refresh icon
MY pc is a windows 10 pro OS, with 3.7 ghz I7 CPU, 32 GB ram, and 1 Samsung NME m.2 SSD, and 1 Samsung 870 Sata SSD drive.
Windows build 44942bd51, Cardano Node 1.35.4-ebc7be471, Cardano Wallet 2023.4.14-3f9055373
This Process has been running for 16 hours so far. Do I interrupt it, as I am not familiar with Daedalus Wallet, and I don't want to corrupt or lose my tokens. I am also very new to Crypto, about 40 days now. Please advise!

Don't worry! All your transfers are already showen in the wallet, that means the transaction is confirmed. They will always stay there, As long as your seed phrase is safe, your funds are also safe. In simple term Your address is tied to your seed phrase not to deadelus.
You could restore your wallet in the Eternl app. It's fatser than daedalus


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:
Securing Stake Pool With Hardware Wallet
was looking at this project for securing cardano stake pool node with a hardware wallet (trezor specifically) https://github.com/vacuumlabs/cardano-hw-cli
just curious if anyone out there has used this to secure their node, was it possible to use the "hidden" wallets feature in trezor?
also i'm curious if if all the signing and certs could be done with the trezor or do you still need a air-gapped environment for protecting keys? or is trezor the "airgapped" environment now?

I started my pool before using a hardware wallet for the cold key was possible, so I did not test this. But I don't see any reason why using the hidden wallet feature wouldn't work.
You still need an airgapped environment for enhanced security (the cold key is the most important key), but it is less important when you have the cold key on a hardware wallet.

You do not secure your stake pool with your hardware wallet. What you are talking about is securing your pledge using your hardware wallet (with hidden wallet is ok). Then this hardware wallet is set as an owner on the stake pool.
Your airgapped stakepool keys are completely different. Those are used to set your pool information (margin, pledge, minFee, relays, metadata, etc..) and register owners. Those should remain airgapped for security.

You can also use the hardware wallet for the stake pool cold key. This is what the question is about. You cannot import the cold key of an existing stake pool in a hardware wallet, you need to create a new cold key (a new stake pool) for that.


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


text:
How can Mithril update the transactions after taking the snapshot?
Question:
When I check the Mithril explorer, The snapshots will be saved in Mithril Aggreagtor 5 times a day. Light wallets can then download this snapshot to see their transaction history without downloading the full node. But snapshots only provide pre-snapshot transaction information. If after the snapshot is created, I make a transaction, will the transaction be updated on my wallet? Or do I have to wait 4 hours for the next snapshot of my transaction to be updated?
Answer:
It would depend on the specifics of your wallet, but the idea is that a (heavyweight at least) wallet would start with a snapshot taken at some point in the past, and then "follow the chain" from that point on, a process that should be pretty fast (eg. seconds or minutes) to reach the tip of the chain.
Once there, it will proceed as normal and your transaction will certainly be reflected in your wallet's state and on-chain as soon as possible, eg. pending confirmation.
=> Question: So what is the mechanism of heavyweight wallet? How can it follow the chain?

A heavyweight wallet can follow the chain by running a node.
When starting a node from scratch, it takes probably a few days to have it in sync. Mithril reduces this to minutes (or tens of minutes).
A wallet cannot see transactions history in the Mithril archive. A node is required for that, and actually not only a node, but also a chain index like cardano-db-sync or something similar. Not all information required to be displayed in a wallet can be extracted directly from the node, that's why a chain indexer is required.
I hope this answers your question.


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

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

Can anyone help?

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

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

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

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

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


text:
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:
Retrieve ADA from a UTXO address linked with my ADA account on Ledger

I sent ADA from an exchange to Ledger, to an address listed as part of a set of addresses used as the receive address for a previous transaction.
I chose one of these multiple "To" addresses to be the receive address for this new transaction, and it seems the address I chose out of the set was a UTXO address and not the main receive address of the previous transaction.
I can see this UTXO address on the block chain, containing the amount sent. Is there a way to retrieve the ADA sent to this UTXO address?

I don't have a Ledger so I'm not quite sure. But here's how it usually works:

Your wallet has multiple addresses
You can use any of them to receive ADA
You can send ADA from any of the addresses as long as there is at least 1 UTxO on it
It is also possible to send ADA from multiple UTxOs on multiple addresses in one transaction

To answer your question: Yes, it should for sure be possible to spend the ADA on this address.
Unfortunately I don't know how you'd do this in the Ledger UI. Maybe this article can help you: https://support.ledger.com/hc/en-us/articles/6200626140957-How-to-send-a-Cardano-ADA-transaction-with-Ledger-Live?docs=true
If you can't do it with the official Ledger software, try using a Cardano wallet and connect your Ledger to it.

Here's how to connect to Eternl wallet: https://support.ledger.com/hc/en-us/articles/6433454118685-Connect-your-Ledger-Cardano-ADA-account-to-Eternl?docs=true

Can send ADA out of Ledger, but the available quantity does not include the latest inflow which was sent to a utxo address (one of the eight "To" addresses shown in the screenshot).
Will experiment with an Eternl wallet and see, thanks for the suggestion.

Further investigation suggests I sent my ada to another user accidentally, because this user's address showed up in my list of "To" addresses due to being batched up in the same transaction id by the exchange used. Will seek support from the exchange to retrieve funds.


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:
Some issues encountered when working with Cardano

How can I generate a bech32 address in the following code:

const wallet = new AppWallet({
  networkId: 0,
  fetcher: blockchainProvider,
  submitter: blockchainProvider,
  key: {
    type: 'root',
    bech32: '',
  },
});

I want to receive free tokens on the preprod network of Cardano, how can I do that?


text:
How to analyze the Plutus budget usage?
When I run my minting policy script I get the error
Command failed: transaction build  Error: The following scripts have execution failures:
the script for policyId 0 (in the order of the PolicyIds) failed with:
The Plutus script evaluation failed: An error has occurred:  User error:
The machine terminated part way through evaluation due to overspending the budget.
The budget when the machine terminated was:
({ cpu: 5735219989
| mem: -56
})

Is there any way to catch what is the cause of memory overflow/leak?

Have you looked at https://plutus.readthedocs.io/en/latest/howtos/profiling-scripts.html?


text:
I encounter issues when retrieving metadata for tokens on the Cardano network
I encountered an error while retrieving token metadata as follows:
var policyId = '8bca871dcd4f1dd9588d901d02677b6d2413fd19e4c8febfc353edff';
var assetName = '5045505041'; // PEPPA

var subject = policyId + assetName;

await blockfrostProvider.fetchAssetMetadata(
  subject,
);

But when I use https://tokens.cardano.org/metadata/{subject}, it works. So, where is the issue on my part?