text:
DB Sync deleting blocks up to slot operation running for 10+ hours
I recently created a new server and install of Cardano node and db sync (1.34.1 & 12.0.2) on same machine. I implemented the snapshot restore to bring the Postgres DB up to EPOCH 325 and was able to successfully connect and query the data without issue.  However, now I would like for DB sync to start loading any new (delta) data beyond EPOCH 325, but the DB sync appears to be "sitting" at an operation called "Deleting 8751 blocks up to slot 55342638".  The operation has been running for 10+ hours and I'm starting to become concerned that the DB sync is not working.
NOTE
I do understand that the DB sync operation can take a considerable amount of time, especially for the more recent blocks.  However, from a data processing perspective this is getting hard to comprehend, especially without being able to see logs or events that could show progress.
I'm sure others are experiencing the same issue and if you were able to find a solution, please do share.  All help is very much appreciated.

I am the main dev on db-sync.

"Deleting 8751 blocks up to slot 55342638"

The message that is to be expected right after that is "Blocks deleted", but deleting 8751 blocks should only take 10s of minutes at most providing the machine you are running on meets the minimum system requirements.

Hello, thank you for the support!  Yes, the machine has been configured to exceed the requirements you referenced.  It would be great if there was a way to trace the events to help diagnose the issue.  As the main dev, could you please help me in producing the necessary logs so that I can troubleshoot this issue?  Thank you again.

If there is nothing in the db-sync logs, then this is a PostgreSQL issue.

Thank you Erik.  PostgreSQL logging it is then!  I'll be sure to update once I have this issue identified.

I have the same issue. Because of corrupted connection to a remote cardano-node.
After connection got fixed, db-sync still wants to remove 203 blocks (the other day 213) and that takes forever.

Mar 31 14:13:46 ip-10-31-12-145 cardano-db-sync[682]: [db-sync-node:Info:59] [2022-03-31 14:13:46.35 UTC] Deleting 203 blocks up to slot 57168135

Actually, I have never seen db-sync to finish that procedure and I was always switching to manual snapshot restore procedure, that is more predictable in that case.
My machine is beefy AWS instance running dbsync and postgres v14 only.
I would appreciate any Postgres troubleshooting tips.
db-sync logs show nothing after message about deletion.
In processes I see:

postgres     776     663 98 14:13 ?        00:17:00 postgres: 14/main: cardano mainnet [local] DELETE

Hello,
Thanks so much for commenting on this thread.  My db sync node has been operating without issue after completing the block deletion.  I continue to research Postgres DB logging / profile trace methods, but "work" keeps getting in the way.  I'm sorry I cannot provide further support, but I will be sure to update once I have established the appropriate DB profile tracing to help troubleshoot issues such as this.

Apparently, the DB sync process just takes a really long time to "initiate".  Not sure if that is the right term, but I will use it for now.
I just checked the db-sync status and it has completed the deletion operation and has moved on to processing the deltas.
I believe that the db-sync utility is an absolute must in the Cardano Ecosystem and I look forward to the opportunity to further improve this technology.
Happy exploring everyone!

Took about 2 hours for me to delete 318 Blocks... My Read IOPS is a bit low (133K Read / 44.5K Write), 2 x 500GB SSDs Raid1, Intel Xeon-E 2136 - 6c/12t - 3.3 GHz/4.5 GHz
2022-06-07T02:21:37.182748120Z [db-sync-node:Info:57] [2022-06-07 02:21:37.18 UTC] Rolling back to slot 62991407, hash b3adef1cb2d8f642f51d60212a719f92080f94b3455c8001e211bf244fbbac3b
2022-06-07T02:21:37.184475177Z [db-sync-node:Info:57] [2022-06-07 02:21:37.18 UTC] Deleting 318 blocks up to slot 62998495
2022-06-07T02:21:37.193243543Z [db-sync-node.Subscription:Notice:47] [2022-06-07 02:21:37.19 UTC] Identity Required subscriptions started
2022-06-07T04:02:32.178760338Z [db-sync-node:Info:57] [2022-06-07 04:02:32.17 UTC] Blocks deleted
2022-06-07T04:03:31.899791964Z [db-sync-node:Info:57] [2022-06-07 04:03:31.89 UTC] Found snapshot file for slot 62991407, hash b3adef1cb2d8f642f51d60212a719f92080f94b3455c8001e211bf244fbbac3b
2022-06-07T04:03:44.397586843Z [db-sync-node:Info:60] [2022-06-07 04:03:44.39 UTC] getHistoryInterpreter: acquired

133K Read / 44.5K Write

That's almost unmanageable for large database processing, you'd expect your instance to lag a lot

Yeah, I've been planning on upgrading the memory, but good to know I need to upgrade the storage as well

Sure, just to be sure , you might want to double-check system requirements for dbsync if you havent - those are predominantly aimed for mainnet configuration

This was caused by some missing indexes. cardano-db-sync 13.x.x has already these indexes set-up.


text:
How to verify signed data?
I'm having some trouble to understand how am I supposed to verify if a signed data was really signed by a specific address.
Checking this CBOR
845846A201276761646472657373583900E922E8166852073D6C1C9BE0736530404C9C26D9BA1773E11D32D11C0F7B2C7F8924528D797A8F86D8210D6276E09F47B82ECD53A24900E7A166686173686564F44B68656C6C6F20776F726C645840D1FCCD8B340A46FD9573FE6A0F6BFC8373562019E9FCD8BDFD7A7D08A89FE98BF28E6736BAE823C024C7B20081C6D30FC4676D2A314299F22CB0264EE7E6AB04

That I got from signing a "hello world" message payload:
[h'A201276761646472657373583900E922E8166852073D6C1C9BE0736530404C9C26D9BA1773E11D32D11C0F7B2C7F8924528D797A8F86D8210D6276E09F47B82ECD53A24900E7', {"hashed": false}, h'68656C6C6F20776F726C64', h'D1FCCD8B340A46FD9573FE6A0F6BFC8373562019E9FCD8BDFD7A7D08A89FE98BF28E6736BAE823C024C7B20081C6D30FC4676D2A314299F22CB0264EE7E6AB04']

I see that I have the address in the headers and I also have the ed25519 signature, but I'm not sure how am I supposed to determine the public key for this and I obviously don't have access to the secret at that point. I was trying something like:
import { eddsa } from "elliptic";

const EdDSA = new eddsa("ed25519");

const key = EdDSA.keyFromPublic(
    ? // what do I put here? Is there a way I can get the public key from the address hex?
);

const verifies = key.verify(
  "hello world",
  "D1FCCD8B340A46FD9573FE6A0F6BFC8373562019E9FCD8BDFD7A7D08A89FE98BF28E6736BAE823C024C7B20081C6D30FC4676D2A314299F22CB0264EE7E6AB04"
);

console.log("Valid:", verifies);

Thanks in advance for your time!

To start with, Message Signing in Cardano follows CIP-0008 https://github.com/cardano-foundation/CIPs/tree/master/CIP-0008
Reading this would give a more idea around message signing.
Answer to your question, How to verify this signature,
From the CBOR you have pasted, This CBOR is CIP-0008 followed COSE_SIGN1 structure, and most probably created from Nami Wallet.
Further decoding first array item from decoded CBOR, you can see the following Map,
{1: -8, "address": h'00E922E8166852073D6C1C9BE0736530404C9C26D9BA1773E11D32D11C0F7B2C7F8924528D797A8F86D8210D6276E09F47B82ECD53A24900E7'}

This contains address as one property, This map is also supposed to contain one more attribute 4 with publicKey of corresponding privateKey that signed the message unfortunately is missing.
So if you have public key in that, You can follow CIP-0008 to verify the message, but as it is missing, only option you have is to ask publicKey from whom you received this message, if you got this CBOR from Nami Wallet then you might have got publicKey as well.
More details on how to verify this CBOR can be found in CIP-0008.
Updates
You can also use @stricahq/cip08 javascript library to to create/verify signature.
import { CoseSign1 } from "@stricahq/cip08";

const messageCBOR = "<message cbor received from wallet>";
const builder = CoseSign1.fromCbor(messageCBOR);

// If message cbor contains publicKey, it will try to verify the
// signature and return true/false
const verified = builder.verifySignature();

// if you want publicKey and address
const publicKeyBuffer = builder.getPublicKey();
const addressBuffer = builder.getAddress();

Thanks for the clarification! I do believe Nami wallet sends the public key in the headers, but I believe Eternl wallet still doesn't :(

source: Stack Exchange

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

sort: votes


text:
Can someone show me how to get the transaction in the proper format for cip-30?
I have generate a transaction using cardano-cli and I am trying to get Nami wallet to sign the transaction.
The command to build the transaction

cardano-cli transaction build-raw
--fee 0
--tx-in $browserTxHash#$browserTxIx
--tx-out ${desktopAddress}+5000000
--tx-out ${browserAddress}+10000000
--out-file transaction.raw

Which writes the following to the file "transaction.raw"

{
"type": "TxBodyAlonzo",
"description": "",
"cborHex": "86a50081825820e34a60ee397dee115b75379af692962dabc085bed002fc0371e578ebd27acd62000d80018282581d60bf1466152d256eb5e8b490c5febc029593f0e9a5b9ee270d75ba35491a004c4b4082583900d9cdd3ead63bd0db91bd83cfa9f3d588bb05a3fb487d5eb62946672cbfcbf21db7267631bbd23f1b8744b9491088eda66ba2ec0e7d2d98841a0098968002000e809fff8080f5f6"
}

I then tried using the CIP-30 based javascript command with nami in the chrome console to request a transaction signature with the command

namiAPI.signTx("86a50081825820e34a60ee397dee115b75379af692962dabc085bed002fc0371e578ebd27acd62000d80018282581d60bf1466152d256eb5e8b490c5febc029593f0e9a5b9ee270d75ba35491a004c4b4082583900d9cdd3ead63bd0db91bd83cfa9f3d588bb05a3fb487d5eb62946672cbfcbf21db7267631bbd23f1b8744b9491088eda66ba2ec0e7d2d98841a0098968002000e809fff8080f5f6",
partialSign=true)

However, I get an error:
"Inputs do not conform to this spec or are otherwise invalid."
The CIP-30 spec from https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030 is as follows:

api.signTx(tx: cbor, partialSign: bool = false):
Promise<cbor<transaction_witness_set>>

I am passing a cbor encoded string (I think), so why is this not working/what should that input look like?

Typhon Wallet Dapp connector is an alternative to CIP-0030 standard where You don't need to build transactions in the backend with Cardano CLI or build transactions in front-end application after fetching UTXOs. https://cardano.stackexchange.com/a/7658/117

i am at the same point, did you figure out what is wrong?

You were on the right track, the key is to add --cddl-format to the build command

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


text:
Anyone have experience using Pfsense SNORT to secure relays?
I've been exploring the wide array of content regarding relay and core node setup (prefer the manual approach).  I'd like to be as secure as possible and have been thinking about the use of tools / utilities such as SNORT on Pfsense.  Does anyone have experience using these utilities for their nodes?  If yes, what are the key lessons learned?
Thanks so much in advance for your support!

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.

I’m surprised that I have not received feedback for this inquiry.  I will try posting this on the cardano community to see if the I get more feedback.  I would have expected pool security to have been a higher priority for most.


text:
How do you make a faucet for native assets such as NFTS on cardano?
im trying to make an NFT faucet  for a NFT drop. How do I make the basic faucet  is there an example that I could build upon?

i have created this script in bash.
https://forum.cardano.org/t/auto-sell-and-send-tokens/94280/2

if you have any questions, please let me know.
the main idea is to

check your wallet with how many TxHash it is
take each TxHash and find sender
send to "sender" tokens or refund, based on what you want to achieve.

not so much CPU and hardware resources...
we have finished our first Sales today, with 3 different Packets.

Is there something written in Plutus for this?

still writing and learning mate :) - but i will do the best to bring ideas and guideline for this kind of solutions.
if any answer helps you, please dont forget to click on "this answer is useful" to support our try.

There's an example of a token sale in Plutus here from Lars for the Plutus Pioneer Program: https://github.com/input-output-hk/plutus-pioneer-program/tree/main/code/week08
and the lecture is here https://youtu.be/y5O58-NpnJ4
Maybe a good starting point for what you could be trying to achieve

great, thank you for sharing.


text:
CARDANO_NODE_SOCKET_PATH Error
I am trying to run my own cardano node and use cli wallets. When I run this command: cardano-cli query tip --mainnet
I am getting the following error: Command failed: query tip  Error: Error while looking up environment variable: CARDANO_NODE_SOCKET_PATH  Error: "CARDANO_NODE_SOCKET_PATH"
Can some one guide me please? I am very new to this
Thanks a Ton

Seems like you forgot to set the environment variable for CARDANO_NODE_SOCKET_PATH as mentioned in here while setting up the node.
https://developers.cardano.org/docs/get-started/running-cardano/#querying-the-cardano-blockchain

I am now getting this error :(

root@vmi828826:/home/cardano# cardano-node run \

--topology path/to/mainnet-topology.json
--database-path path/to/db
--socket-path path/to/db/node.socket
--host-addr 154.53.34.181
--port 3001
--config path/to/mainnet-config.json
InvalidYaml (Just (YamlException "Yaml file not found: path/to/mainnet-config.json"))

cardano-node: YAML exception:
Yaml file not found: path/to/mainnet-config.jsonroot@vmi828826:/home/cardano#

You have to change each of the values of 'path/to/...' to the actual path that suits your environment.

damn. i have no idea how to do that lol


text:
How to see the local node's mempool?
I'm building a few applications and am running into scaling issues.
Occasionally a lot of transactions need to be submitted, sometimes even chained, but generally it's simply splitting an incoming UTxO to multiple target wallets. This generally works fine unless the network is somewhat congested which results in outgoing transactions "hanging around" in the local mempool for a considerably longer time and UTxOs piling up.
Everything still works but it's less than optimal and can cause the service to become even more sluggish, I'd like to avoid that.
Ideally I'd be able to build some sort of scaling solution based on the nodes' current mempool size.
Unfortunately I have not found any cardano-cli command to easily view the mempool utilization which would be really helpful, maybe I missed something obvious.
So ultimately my question is:
Is there a way to easily view the mempool utilization?

Ogmios might help for this: https://ogmios.dev/mini-protocols/local-tx-monitor/

At the moment, you need to use Ogmios to see your local mempool.

Hey Marek, just curious, do you know if it's possible to aim Ogmios to look at a remote mempool?

Ogmios just connects to a Cardano node, so it is always using a "remote mempool".

Ah I just realised my mental model was funny, essentially you need to first connect/have access to a remote node to view its mempool.


text:
How to see the values of things as you code
How do I test different plutus functions to see if its applicable to be used in my code. How would I create the parameters that these functions would take in.
For example below is a Vesting contract from the Plutus-Pionner-Program. How do i see what happenes when you run this function.How do I test out what each individual function return when a parameter is passed in.
give :: AsContractError e => GiveParams -> Contract w s e ()
give gp = do
    let dat = VestingDatum
                { beneficiary = gpBeneficiary gp
                , deadline    = gpDeadline gp
                }
        tx  = Constraints.mustPayToTheScript dat $ Ada.lovelaceValueOf $ gpAmount gp
    ledgerTx <- submitTxConstraints typedValidator tx
    void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
    logInfo @String $ printf "made a gift of %d lovelace to %s with deadline %s"
        (gpAmount gp)
        (show $ gpBeneficiary gp)
        (show $ gpDeadline gp)

How would I pass in the necessary information to this to test if it runs or not.
Basically what I am asking is how do i just start hacking on Plutus. Just run some of the functions that Plutus have ,pass in some parameters , and see what it returns. I know i can run it in GHCI but I feel like I have some gaps in my knowledge and it is not connecting yet.

I share your dilemma. I am no expert, but my understanding is that whereas other languages tend to be imperative (do this to that, and then take that and do this to it), Haskell is more about defining what something is. Therefore, there is no interim state or progress status to easily query or capture (eg. alert('here!'); in javascript). Add to that the multi-nested user defined (often other-user defined ie. plutus development team) types and "builtin" types and the need to define instances to view something (eg. deriving Show) in your code, and I too find myself wandering blind and lost.


text:
checkDeadline function always returning False
I am trying to make a minting policy that fails after a certain deadline.
I have tried something like this
{-# INLINABLE mkTokenPolicy #-}
mkTokenPolicy :: TxOutRef -> TokenName -> Integer -> () -> ScriptContext -> Bool
mkTokenPolicy oref tn amt () ctx = traceIfFalse "Deadline reached"   checkDeadline         && --getinng error that oef isnt even used
                                   traceIfFalse "wrong amount minted" checkMintedAmount
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    checkDeadline:: Bool
    checkDeadline = ivTo (from mDeadline) >  ivTo (txInfoValidRange info)
        where
            mDeadline ::  POSIXTime
            mDeadline =  1680120281000

    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
        [(_, tn', amt')] -> tn' == tn && amt' == amt
        _                -> False

and have also tried something like this
{-# INLINABLE mkTokenPolicy #-}
mkTokenPolicy :: TxOutRef -> TokenName -> Integer -> () -> ScriptContext -> Bool
mkTokenPolicy oref tn amt () ctx = traceIfFalse "Deadline reached"   checkDeadline         && --getinng error that oef isnt even used
                                   traceIfFalse "wrong amount minted" checkMintedAmount
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    checkDeadline:: Bool
    checkDeadline = to mDeadline `contains` txInfoValidRange info
        where
            mDeadline ::  POSIXTime
            mDeadline =  1680120281000

    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
        [(_, tn', amt')] -> tn' == tn && amt' == amt
        _                -> False

However, no matter what I seem to do, checkDeadline always returns False. Does anyone have any thoughts on how I can fix this?

Make sure you are adding your time constraints in your off-chain code as well.
Here is an example of the constraints in the auction contract.
Background:
This can be kinda unintuitive to some people, but essentially the script doesn't know when it's executing, it just has the context from the transaction.
When you use Constraints.mustValidateIn X off chain, you are building a tx that is valid over X range. If you submit it outside of that range, it will fail before it ever gets to a validator script.
Say your script only accepts txs that are valid in range 5-10 and your tx is valid in range 1-10. Even if it occurs on 7, it will still fail the validator!
Script constraints are looking at the range a tx is valid, with the implicit assertion that it is being executed in that range (or else it wouldn't have made it to the script). That way, the script doesn't need to know which slot it is currently and can be deterministic. The non-deterministic stuff is cleanly separated from the pure scripts.

Can you provide the test?
The code looks fine
Prelude Ledger Ledger.Interval > checkDeadline x = to (POSIXTime 1680120281000) `contains` x
Prelude Ledger Ledger.Interval > checkDeadline (to 1680120280000)
True

Maybe you haven't provided any time contraints in the transaction?
If you don't then I think it defaults to the always interval. Then checkDeadline will fail.

This should be a comment really, but comments mess up the code


text:
Mainnet genesis block output off by 1,000,000 Lovelace + what is the test Ada from mainnet genesis?
I have been studying utxos on the mainnet and have run into some interesting inconsistencies.
If you run this query against cardano-db-sync's cexplorer database:
select sum(value)
from block
inner join tx on block.id = tx.block_id
inner join tx_out on tx.id = tx_out.tx_id
  -- Get genesis block
where epoch_no is null
  -- Filter "test ada" (idk ctrl f "test ada" here https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/interesting-queries.md)
  -- FYI there is 100,000,000 lovelace worth of "test ada"
  and tx_out.value <> 1000000

----------------------------
3111248464500000000

You will get 31,112,484,645 Ada which is one ada less than the 31,112,484,646 Ada the Cardano website claims was created in the genesis block.
Any insight behind this single extra Ada would be greatly appreciated!
On that same note, the discrepancy becomes 99 Ada if we don't remove the "Test Ada". From what I've seen, the "Test Ada" has been incorporated into the utxo set as if it is normal Ada. Really curious as to what's going on here! I'm building tools for measuring Ada distribution over time and would like to be precise about the accounting.
Anddd if you're feeling extra helpful, I don't understand the story behind why outputs are omitted from genesis after the Allegra hard fork.
Sorry for multiple questions, thanks in advance!

The test ada entries was used for testing the redemption of ada from the genesis block (aka AVVM certificate process).

Ok cool, so after (if) it's redeemed it is just incorporated into the utxo set


text:
transaction sign from 2 different wallet to unknown wallet
i have 2 wallet in my node, each one hold different Asset and ADA.
i want to sign a transaction with "cardano-cli transaction sign" command, using 2 times the "--signing-key-file " option for the 2 different wallets .., and i want to send all this tokens and ada to an unknown wallet.
is it possible?
example,
wallet_1 = holds 10 ADA
wallet_2 = holds 100 Tokens
            cardano-cli transaction sign \
                --signing-key-file $paymentSignKeyPath_A \
                --signing-key-file $paymentSignKeyPath_B \
                --tx-body-file ${txraw} \
                --out-file ${txsigned} \
                --mainnet >> $log

is that possible=? and also is it possible this one to be sent to an unknown 3rd wallet?
thank you,
TTS17

Yes it is possible, as long as the raw transaction is properly built.
If you wish to consolidate all UTXOs in the two wallets into a single one on the third wallet, you'd use all the UTXOs as --tx-in, and have a single --tx-out. Also, make sure that when estimated the fee, indicate that there will be two witnesses.

yes , thank you.
more specific to be,
i want from wallet-1 to send only NFT, from wallet_2 to send the minimum of the ada amount which must follow a NFT to a wallet_3, which wallet3 is unknown.


text:
cardano-cli transaction build script (NFT Contract Address Creation)
I am trying to send a market.plutus file to test a NFT marketplace to mainnet. I am building the transaction here like this:
cardano-cli transaction build
--alonzo-era --mainnet
--tx-in $UTxO-VARIABLE
--tx-out $CONTRACT-ADDR-VARIABLE+5400011
--tx-out-datum-hash 67882f9c671cb45fc6990a2d14a20b30bfce29ad99a401c283a100662e6600fb
--metadata-json-file
--change-address $MY-ADDR-VARIABLE
--out-file tx.build

Notice how the --metadata-json-file field is empty. It doesn't let me build it empty of course but I have no idea what goes here or what it should be.

'--metadata-json-file' wants a path to a JSON file eg --metadata-json-file metadata.json
This link shows an example of JSON metadata content, adapt and use as needed -
https://developers.cardano.org/docs/transaction-metadata/how-to-create-a-metadata-transaction-cli/
You can try leaving out this option, or provide the path to a file (that is either empty or that has minimum JSON data).
It's cheaper to experiment on the testnet, but I'm sure that you're aware of that.


text:
Cardano-graphql / Hasura - not found in type: 'query_root'
I found this github issue: https://github.com/input-output-hk/cardano-graphql/issues/507 discussing how to get assets of an address at a certain block using cardano-graphql / Hasura.
When I run the "SDL Version" of the query, as mentioned in the github issue, on the referenced page (https://graphql-api.mainnet.dandelion.link/), it works just fine.
When I try the same query on my cardano-graphql stack in Hasura, I get this error message:

field "paymentAddresses" not found in type: 'query_root'

I searched for similar errors, and it seems to have to do with permissions, but I can't figure out which permissions are missing.

Are you using the hasura console or the apollo graphql console?
That query won't be available through the hasura console since paymentAddresses is not a postgres table that hasura directly binds to. The apollo graphql server actually queries hasura, transforms the data and then returns it. You can see here that payment addresses calls the getPaymentAddressSummary function on the hasura client.

I just now realized the difference between the two consoles. Thanks. All works when entering it in the correct console.


text:
Plutus datum and redeemer on cardano-cli
I'm trying to deploy a smart contract on cardano-cli after its implementation on plutus playground.
Imagine that I have:
data TradeDatum = StartBid | Bid TradeDetails | Offer TradeDetails
    deriving (Generic, ToJSON, FromJSON)

data TradeDetails = TradeDetails
    { tradeOwner :: !PubKeyHash
    , budId :: !BuiltinByteString
    , requestedAmount :: !Integer
    } deriving (Generic, ToJSON, FromJSON)

How can I write this in an example JSON to submit on cardano-cli? I saw an example with int: 42,
{
  "constructor": 0,
  "fields": {int: 42}
}

but I really don't know.

How can I define the different types?
Inside the tradedetails, how can I define? and for example, how to express the pubkeyhash?

Can you give me an exmaple? There are some tutorials with the types of data that I can write inside the JSON (like int)?
Thanks.

Have a look at the following source Cardano-Api Haddock. Here you will find all about the conversion between Haskell data types and the Json format the cardano-cli uses.
I noticed that you used the marketplace of SpaceBudz as an example, so lets have a look at the other code in that repository. Notice the line 99.
print $ "Datum value: " <> encode (scriptDataToJson ScriptDataJsonDetailedSchema $ fromPlutusData (Plutus.toData offerDatum))

Here that function prints the offerDatum defined at line 85. You see here how the function from the cardano-api are used and then encoded to convert the datum to a json form? Here the <> symbol just means concatenate the two strings.
For a more detailed explanation of what is going on in this line have a look at the PPP cohort 3 lecture 3 from lars on youtube.

got it. thanks :)

{
"constructor": 0,
"fields": {int: 42}
}

This isn't valid because fields must be an array. The index of the constructor and fields will match the order of types defined for the validator script. For a Bid you'd use constructor 0 with a single field which is a json representation of TradeDetails (bytestring, bytestring, integer).
It is easier and safer to use scriptDataToJson.

got it. thanks :)

This answer helps me, indirectly. Thanks


text:
Why does my testnet wallet "disappear"?
I have an instance of Cardano Wallet running and pointing at testnet. I create/restore a wallet like this:
curl -v -H "Content-Type: application/json" -d '{"name":"My Wallet","mnemonic_sentence":["..."],"passphrase":"..."}' https://myserver.dev/cardano-wallet/v2/wallets

and get a successful response back, which includes a valid walletId.
For a few minutes, I can successfully query the API using this walletId. If I hit the /wallets/{walletId}/addresses endpoint, I get back a list of 20 unused addresses, as expected. However, after a short time (I haven't found the exact time but it seems to be around 5 minutes) I start to get a 404 with a response body similar to:
{"code":"no_such_wallet","message":"I couldn't find a wallet with the given id: ..."}

Is this expected behavior? Is there something else I need to do to ensure the wallet can be found when I need to "create" addresses for it? I know I could always just "restore" it before executing an operation against the wallet, but this seems like it would add a lot of extra potentially unnecessary requests.

After writing the question, I realized that maybe it was my instance of Cardano Wallet that was the problem. I checked the logs and it looks like the problem is two-fold: 1) I only allocated 1G of memory for the Cardano Wallet Docker container and it was being killed by the OOM killer. 2) I didn't have the wallet db mapped to a persistent volume, so whenever the container was restarted, I would lose my wallet.
So it doesn't appear that this is expected behavior. Host the Cardano Wallet API correctly and you shouldn't have this issue.


text:
How convert TxOut CtxUtxo era to Plutus Map TxOutRef TxOut
At least can someone give a hint how to convert TxOut CtxUtxo era to TxOut Ctx era.
I found that it's possible to convert to Ledger.UTxO and then ...


text:
Fetching exchange prices via an API?
Are there any APIs currently available that let you fetch Cardano native token prices without web-scraping?
SundaeSwap, ADAX, MuesliSwap, and MinSwap don't appear to have this functionality.
ErgoDEX may have it in the future but is there anything right now that works?
Just want to get the last known token prices for specific pairs. Doesn't matter if it's in ADA or USD.

MuesliSwap does provide some API endpoints that you could look into:
https://docs.muesliswap.com/cardano/api
There's a ticker that provides "24-hour pricing and volume summary for each market pair available on the exchange":
http://analytics.muesliswap.com/ticker
And you can also get more detailed historical price (or volume) data on each token, eg: https://analytics.muesliswap.com/price?policy-id=8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa&tokenname=MILK&interval=hourly
Here's an example site powered by their API according to the docs: https://cardanoassets.com/

On how to get the number of decimals of a token to convert the pricing data:
I couldn't find that info in the MuesliSwap API, though it could still be hidden in there somewhere.
In general though that info can be derived from the metadata of the minting transaction, eg here:
https://cardanoscan.io/transaction/d74798c4a1e453fbc6ba4fbb1d785e0534fb8531fd1bc054ceff5b086240d3b5?tab=metadata
(Check under label "20", which is defined in CIP-38 here: https://github.com/cardano-foundation/CIPs/pull/137)
If you need to automatically get this info, one way would be to use a service like Blockfrost to query it.
Once you have the policy id and asset name (eg from the muesliswap api), you could use this endpoint to fetch the asset details, including the metadata with the decimals field:
https://cardano-mainnet.blockfrost.io/api/v0/assets/9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145
(You'll need to convert the asset name "SUNDAE" from the MuesliSwap API to hex "53554e444145" and add it to the policy id)

Thank you. But some have very strange decimal numbers. For example SUNDAE_ADA: http://analytics.muesliswap.com/trades/9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d77.SUNDAE_ADA
How do I fix the prices with these decimal points?

If you're in Javascript, you could simply call "toFixed()" on those numbers to convert the floating point to fixed point representations, eg "(2.5e-3).toFixed(4)" becomes "0.0025", if you want 4 decimal places; for those smaller numbers you'll need more decimal places (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed)

But the problem is those aren't the correct prices. 2.5e-7 = 0.00000025 for the SUNDAE token. But the actual SUNDAE price on MuesliSwap is 0.25 ADA. Why is the price incorrect on the MuesliSwap api and how do I properly convert it?

Ah I see, okay thats because 1 SUNDAE has 6 decimals, so technically 1 SUNDAE is a million "tokens" (like 1 Ada is 1,000,000 Lovelace) - so you can just multiply the price by a million like so: (2.5e-7 * 1e6).toFixed(2) to get 0.25 (the actual SUNDAE price in Ada)

How do I automatically retrieve the number of decimals though?

Added the info to the answer above. There might be a better solution, but blockfrost definitely works for that. You'd probably just query this info once and store it on your end, so you should just need very few requests, ie one per token.

just to add, in case there's a token that doesn't follow the CIP-38 yet, you can also check the token registry here for the info https://github.com/cardano-foundation/cardano-token-registry/, eg here's the entry for SUNDAE: https://github.com/cardano-foundation/cardano-token-registry/blob/master/mappings/9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145.json


text:
If the desktop shortcut for the daedalus app gets removed, can I make another one? Why is it needed for proper opening of the app?
I tried opening daedalus from the windows 10 taskbar today. This brought up a prompt informing me that this method is an improper way to open it(any explanations why cardano hates windows taskbar would also be appreciated). I know how to make another desktop shortcut in windows, but I was curious to know if there's a 'correct' way of doing this? My solution is to dig around in the file manager taking guesses at which .exe file is the correct one. Is there a faster way of recreating this desktop shortcut? Is there a practical reason (I'm assuming it's a security vulnerability?) for this forced method of opening?
Digging through the web is tough with this problem because most searches only find errors with sync issues rather than local desktop problems.

A best guess for a solution here is to find the daedalus app via start menu "super-key". After opening the app (assuming you let the db sync adequately) and closing, a new desktop shortcut seems to get created for you immediately after closing.
This is incredibly convenient for the troubled user, I have no info to offer on security inquiries or what makes the windows 10 taskbar so improper.


text:
how to generate cardano new address using blockfrost.io?
Is it possible to generate new address and private key for cardano using blockfrost.io api,
that later on can use for transactions and adding it into wallet.
thank you

Short answer is no, because it poses a security risk for both them (generating and transmitting keys over the network) and the end-user consuming their service to do so (trusting the API not to log or persist those keys).
As with all other blockchains, the responsibility of generating (and securely storing) keys and addresses generally lie with the end-user who wants to interact with it. As they say, not your keys, not your wallet.
That said, you can generate them through:

CLI tools (e.g. cardano-cli, or cscli)
SDKs in your language of choice (e.g. CardanoSharp, cardano-serialization-lib, cardano-client-lib, etc.)
Software wallets which can generate recovery-phrases and root keys to derive multiple keys/addresses (e.g. Eternl/CC, Daedalus, Flint, Yoroi, etc.)
Hardware wallets with embedded root keys (e.g. Ledger, Trezor, etc.)

It is also worthwhile mentioning that you should practice extreme caution when generating the keys yourself. I highly recommend using an air-gapped machine, never storing the raw recovery-phrase digitally (raw text,photo,etc.) and never sharing it with anyone else.

thank you
do you know is it possible to generate lite wallet of cardano or how can it possible

At this stage I would ask what exactly are you trying to achieve? Do you mean to generate a set of wallet keys/addresses locally? Or to build light wallet software (e.g. my third point) yourself?

Looking at the docs at https://docs.blockfrost.io/ I'm pretty sure that's not possible.
Your best option might be to use a package like this, if your in nodejs:
https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs
(or this version for the browser: https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser)
The generation of keys with this library is explained here:
https://github.com/Emurgo/cardano-serialization-lib/blob/master/doc/getting-started/generating-keys.md
and can look something like this:
  const rootKey = Bip32PrivateKey.generate_ed25519_bip32();

  const harden = (num: number): number => {
    return 0x80000000 + num;
  }

  const accountKey = rootKey.derive(harden(1852)).derive(harden(1815)).derive(harden(0));
  const utxoPubKey = accountKey.derive(0).derive(0);
  const stakeKey = accountKey.derive(2).derive(0);

  const baseAddress = BaseAddress.new(
    NetworkInfo.testnet().network_id(), // Testnet
    StakeCredential.from_keyhash(utxoPubKey.to_public().to_raw_key().hash()),
    StakeCredential.from_keyhash(stakeKey.to_public().to_raw_key().hash())
  )

  console.log("New address: ", baseAddress.to_address().to_bech32())

There are of course also other ways to generate the keys, eg. via the CLI:
https://developers.cardano.org/docs/stake-pool-course/handbook/keys-addresses/

One more option is https://www.npmjs.com/package/@stricahq/bip32ed25519, this library is purely written in Javascript.


text:
What can certificate scripts do?
While looking through the options of the cardano-cli transaction build options I saw the options,
  --certificate-file CERTIFICATEFILE
                           Filepath of the certificate. This encompasses all
                           types of certificates (stake pool certificates, stake
                           key certificates etc). Optionally specify a script
                           witness.
  --certificate-script-file FILE
                           The file containing the script to witness the use of
                           the certificate.
  --certificate-redeemer-cbor-file CBOR FILE
                           The script redeemer, in the given JSON file. The file
                           must follow the special JSON schema for script data.
  --certificate-redeemer-file JSON FILE
                           The script redeemer, in the given JSON file. The file
                           must follow the special JSON schema for script data.
  --certificate-redeemer-value JSON VALUE
                           The script redeemer, in JSON syntax. There is no
                           schema: (almost) any JSON value is supported,
                           including top-level strings and numbers

I was wondering how and what type of scripts are allowed for these certificates? Can we also generate our own type of certificates with plutus? As stated after the --certificate-file flag these entail atleast stake pool certificates and stake key certificates. This would be a good lightweight option for on-chain voting.

I looked at the constructors in the Haddock files of the Certificates in the Plutus.V1.Ledger module. There the datatype DCert is defined as

I am not sure but answering my own question, currently only the above certificates are possible. It is still not clear to me what the --certificate-script-file flag does exactly.


text:
Block Propagation
I was checking GLiveView Stats on my pool and I noticed that served, under block propagation in block producer and relays have different values, 20 on BP and 2000 on Relay after 15H of Uptime.
Why does this happen? Is it because block not passed don't need more validation?
Does anyone have some reference where I can learn from?
Thanks for your time :-)

As explained in the Guild Operator's gLiveView section, served is:

served blocks counts how many blocks were fetched by "in" peers. If this does not increase for a long time, it means the "in" peers are learning about new blocks from somewhere else (and therefore this node is not contributing towards accelerating the propagation). Overall, these metrics are helpful in tweaking the topology and/or performance of the network links.

In other words, served is a measure of how many blocks have been fetched by other nodes from your node. It makes sense that served will be lower for your BP because the BP is supposed to only communicate with your relays, whereas your relays are responsible for communicating with the rest of the network.

Thanks for pointing me in the right direction


text:
How to see UTXOs at a script
I am creating a function that takes in UTXOs at a script as a parameter. I know there is a function Plutus.Contract.utxoAt but how do i see what that will return ? I am still developing out my script and it is not on the chain yet.I need to see what utxoAt will return in order to pass it in to a function.

It will return a map containing the TxOutRefs of the provided address. Perhaps these are what you want your script to validate? Unless I'm misunderstanding your intention, you can't use these contract functions onchain. They are useful for offchain actions such as inspecting and building transactions.

Yeah , turns out I can just put that in a print statement and run it in playground. I’ll be able to see what it returns in the log.


text:
How to delegate to a stake pool using CLI?
Using any graphical based wallet it's trivial to delegate to a stake pool. How do you accomplish this same task using only CLI tools (e.g. cardano-cli)?

You can use cardano-cli to delegate.
First, make sure your stake address is registered on chain.
If it isn't already and you want to do it from cardano-cli, you must first build the stake-address registration certificate:
cardano-cli stake-address registration-certificate \
--stake-verification-key-file <STAKE.VKEY_FILEPATH> \
--out-file <STAKE_ADDRESS_REGISTRATION_CERTIFICATE_FILE>

Submitting this certificate (if you haven't already) will cost 2 ADA as a deposit (which you can then reclaim if you de-register the stake address).
Next, construct a delegation certificate for the pool you wish to delegate to:
cardano-cli stake-address delegation-certificate \
--stake-verification-key-file <STAKE.VKEY_FILEPATH> \
--stake-pool-id <BECH32_OR_HEX-encoded_STAKEPOOL_ID> \
--out-file <DELEGATION_CERTIFICATE_FILEPATH> \

You may then submit these two certificates in a single transaction. If your stake address is already registered on chain you can skip the registration cert and only construct/submit the delegation cert.
For further clarification regarding this and/or signing/submitting these certs as transaction, I'd recommend the CoinCashew Guide, specifically the section on pool registration.

Where does STAKE.VKEY_FILEPATH come from?

The CoinCashew Guide appears helpful but falls short because it's instructing on how to create a new stake pool instead of delegating to an existing stake pool.

VKEY_FILEPATH> is just a placeholder name for where in your filesystem the stake verification key is located. Also, yes the guide is more involved than simple delegation, but manual delegation is part of the guide and can be used for more than just creating pools.

I still don't understand where the stake verification key comes from. I've tried going through the guide and was unsuccessful because it's incomplete.

Cardano has payment and staking keypairs (public and private) which you combine to build shelley-era addresses. You can create this keypairs manually using cardano-cli, or import them from an existing wallet

So you could generate a staking keypair for the purpose of registering and then discard the private key?

No, the staking private key is needed for delegating/redelegating to pools, as well as for withdrawing rewards to your main address. Read more about cardano keypairs here: https://developers.cardano.org/docs/operate-a-stake-pool/cardano-key-pairs/

This doesn't make any sense though because the staking key is disassociated with the wallet, it's just random

That article is stating that the stake key is derived from the wallet. So now I'm even more confused because this is contradictory to the information I was following in other articles.

This is what I was missing: https://cardano.stackexchange.com/questions/6045/get-wallet-skey-vkey-from-mnemonic
The stake key comes from the wallet itself.

Finally got it working!


text:
Selecting Your Own Keys
Is there a way I can specify the prime number product used to generate the public private key pair - on the creation of a wallet address?
I understand that the primes in the product would have to meet certain cirtiaera but that's okay.

What do you mean with "prime number product"? Can you give more details about what you know on that?

Yeah so vitalik was talking about having two primes he can easily generate to get his key. I thought it would be a nice idea to do this instead of seed phrases and have some easy to rember way to generate the primes.

Sorry but it's been almost a year and I can't remember the details, but the primes were used for the eliptic curve encryption scheme.


text:
Implementing CIP-008 (signData function) in Java
I'm trying to implement what's discussed in this topic: How to verify data signed with nami wallet in a node backend? but in Java.
Obviously I don't have the js/rust lib I can play with, so I have to implement/integrate all the bits myself.
While I've successfully implemented the code to use the Ed25519 standard, and in this repo there is the code and a few examples github I don't seem to be able to verify the data returned by the signData method of the wallet (that I assume uses the same standard).
Now it's my understading that the COSE object contains all that I need to at least verify the payload has been signed with the public key returned with COSE object itself. Looking at the sample in the post above, and using the https://cbor.me/ website, I guess that:

674D11E432450118D70EA78673D5E31D5CC1AEC63DE0FF6284784876544BE340 is the HEX of the signed message
68656C6C6F is the HEX of the message to sign
01D2EB831C6CAD4ABA700EB35F86966FBEFF19D077954430E32CE65E8DA79A3ABE84F4CE817FAD066ACC1435BE2FFC6BD7DCE2EC1CC6CCA6CB is the HEX of the Base Address of the wallet
A3B5ACD99DF5F3B5E4449C5A116078E9C0FCFC126A4D4E2F6A9565F40B0C77474CAFD89845E768FAE3F6EEC0DF4575FCFE7094672C8C02169D744B415C617609 is the HEX of the Public Key of the wallet.

Now, if I used the public key at (4) along with signed (1) and unsigned (2), and I test with the code (taht I know that works!) I wrong for the verification, it doesn't pass. So I guess one of the assumption i wrong.
I'm sure that (2) is the hex of the message to sign, so now either (1) is not the signed message or (4) is not the public key. Or they are in a different format
In java the code I'm running looks like the following
var msg = "hello".getBytes(StandardCharsets.UTF_8);
var publicKey = new Ed25519PublicKeyParameters(Hex.decode("A3B5ACD99DF5F3B5E4449C5A116078E9C0FCFC126A4D4E2F6A9565F40B0C77474CAFD89845E768FAE3F6EEC0DF4575FCFE7094672C8C02169D744B415C617609"), 0);
var verifier = new Ed25519Signer();
verifier.init(false, publicKey);
verifier.update(msg, 0, msg.length);
var outcome = verifier.verifySignature(Hex.decode("674D11E432450118D70EA78673D5E31D5CC1AEC63DE0FF6284784876544BE340"));
System.out.println("Outcome: " + outcome);

Any help would be greatly appreciated

After the CIP-0030 update you won't get the publicKey in the protected headers, but rather in the response object from signData directly, so the above answer won't work anymore.
Here is the example of the verification after the update: https://github.com/MartinOndejka/cip-0008-verification

First part of the solution can be found here:
https://github.com/bloxbean/cardano-client-examples/blob/cip008/src/main/java/com/bloxbean/cardano/client/examples/cip8/CIP8CBORParser.java
Code pasted here to keep track
package com.bloxbean.cardano.client.examples.cip8;

import co.nstant.in.cbor.CborDecoder;
import co.nstant.in.cbor.model.*;
import com.bloxbean.cardano.client.crypto.CryptoException;
import com.bloxbean.cardano.client.transaction.util.CborSerializationUtil;
import com.bloxbean.cardano.client.util.HexUtil;
import net.i2p.crypto.eddsa.EdDSAEngine;
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable;
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec;
import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec;

import java.security.MessageDigest;
import java.security.Signature;
import java.util.List;

public class CIP8CBORParser {
    private static final EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519);

    public void parse() throws Exception {
        //Payload = "hello"
        String coseSignMsgInHex = "845869a30127045820674d11e432450118d70ea78673d5e31d5cc1aec63de0ff6284784876544be3406761646472657373583901d2eb831c6cad4aba700eb35f86966fbeff19d077954430e32ce65e8da79a3abe84f4ce817fad066acc1435be2ffc6bd7dce2ec1cc6cca6cba166686173686564f44568656c6c6f5840a3b5acd99df5f3b5e4449c5a116078e9c0fcfc126a4d4e2f6a9565f40b0c77474cafd89845e768fae3f6eec0df4575fcfe7094672c8c02169d744b415c617609";

        //CBOR parsing starts here ###################
        List<DataItem> dataItemList  = CborDecoder.decode(HexUtil.decodeHexString(coseSignMsgInHex));

        List<DataItem> topArray = ((Array) dataItemList.get(0)).getDataItems();
        ByteString protectedHeaderBs = (ByteString) topArray.get(0);
        Map unprotectedMap = (Map) topArray.get(1);
        ByteString messageToSignBS = (ByteString) topArray.get(2);
        ByteString signatureArrayBS = (ByteString) topArray.get(3);

        byte[] message = messageToSignBS.getBytes();
        byte[] signature = signatureArrayBS.getBytes();

        System.out.println(new String(message));

        //parse protected header map bytestring
        List<DataItem> protectedHeaderMapDIList = CborDecoder.decode(protectedHeaderBs.getBytes());
        Map protectedHeaderMap = (Map) protectedHeaderMapDIList.get(0);

        ByteString publicKeyBS = (ByteString) protectedHeaderMap.get(new UnsignedInteger(4));
        byte[] publicKeyBytes = publicKeyBS.getBytes();

        ByteString addressBS = (ByteString)protectedHeaderMap.get(new UnicodeString("address"));
        System.out.println("Address >> " + HexUtil.encodeHexString(addressBS.getBytes()));
        //CBOR parsing ends her ###################

        //Create SignatureStructure. This is passed as message during signature verification
        Array sigStructArray = new Array();
        sigStructArray.add(new UnicodeString("Signature1"));
        sigStructArray.add(protectedHeaderBs);
        sigStructArray.add(new ByteString(new byte[0]));
        sigStructArray.add(messageToSignBS);

        byte[] messageToVerify = CborSerializationUtil.serialize(sigStructArray); //serialize
        //End SignatureStructure

        boolean verified = verify(messageToVerify, signature, publicKeyBytes);
        System.out.println("Verification status >> " + verified);
    }

    public boolean verify(byte[] message, byte[] signatureBytes, byte[] publicKeyBytes) {

        try{
            net.i2p.crypto.eddsa.EdDSAPublicKey publicKey = new net.i2p.crypto.eddsa.EdDSAPublicKey(new EdDSAPublicKeySpec(publicKeyBytes, spec));
            Signature signature = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm()));
            signature.initVerify(publicKey);
            signature.setParameter(EdDSAEngine.ONE_SHOT_MODE);
            signature.update(message);
            return signature.verify(signatureBytes);
        }catch(Exception e){
            throw new CryptoException("Extended signing error", e);
        }
    }

    public static void main(String[] args) throws Exception {
        new CIP8CBORParser().parse();
    }
}

Kudos to @Satya
Second part missing is the adderss verificaiton/validation.
Will add as soon as it's done.


text:
I got error while building package plutus-core-0.1.0.0 when installing cardano-wallet using stack
I'm using MacOS Monterey with M1 chip and trying to install cardano-wallet. I've already installed pre-requisites cardano-node and cardano-cli no problem, and already synced with the testnet.
I was following this guide
https://developers.cardano.org/docs/get-started/installing-cardano-wallet
At step $ stack build --test --no-run-tests, I got the following error happening at 443/460

This is after I tried running $ stack build --test --no-run-tests again right after

Can somebody help me?

I'm not a Mac guy but the error looks like a mismatch between x86 and ARM arch code. Maybe look more into using Rosetta (Intel emulation).
This might help too: https://cardano.stackexchange.com/questions/4035/installing-cardano-node-on-an-m1-mac

Did you build cardano-node or download the binary?

@MC_Brisbane Thanks, but I will try to follow the Github guide first on cardano-wallet repo itself, since the Cardano Developer website seems outdated.
I built the cardano-node from the source using cabal, didn't download the binary

Ok good, since you built the node from source that is a good sign that your env is/was working ok without fundamental issues.


text:
Starting a new Plutus Project
I've read a few threads on Cardano Stack exchange on how to start a new Plutus project, but there doesn't seem to be a satisfying answer. I've read the following:

plutus starter course
How to Start a New Project

The answers suggests that we copy the Plutus Pioneer course and use the cabal.project file as a base to build on top of. But what if we the Plutus Pioneer course is over, surely there has to be a way to determine what the correct cabal.project file and its dependencies should be?
Another answer says to follow the plutus-starter repository: https://github.com/input-output-hk/plutus-starter. However this repository doesn't seem to be fully updated. The cabal.project file there hasn't been updated for the past 5 months.
So, the question is, when starting a new Plutus project, especially getting the correct dependencies and tags in the cabal.project file, ensuring that the correct tags are used for the repositories within it, what's the procedure to do this?
Thanks

Please take a look at this answer.

Great point, unfortunately IO has been a bit behind in regards to updating some of its skeleton repos as you've already pointed out.
In regards to the correct tags for repos - there is actually only one thing you have to be make sure is matching up and that's making sure the cabal.project file defines a plutus-apps dependency which references a git tag. That must match the commit you check out after cloning the plutus-apps repo.
After that you're pretty safe to run nix-shell in the plutus-apps repo and switch back to your project.
I've used the pioneer program cohort #3 as template.

The plutus starter is the ideal template to start with new Plutus projects and like William said the IOG repo is quite outdated at this time.
I have created an updated branch for the plutus-starter. I have been using it and it works. I made a PR for the IOG repo, but seems it yet to get attention :)
Here it is if you'd like to use.
https://github.com/gannith/plutus-starter/tree/track-plutus-apps

The official plutus-starter has a new release. https://github.com/input-output-hk/plutus-apps/releases/tag/v2022-04-06


text:
Plutus Pioneer Cohort 3, Mac M1 cabal build error: Failed to build small-steps-test-0.1.0.0. , symbol not found in flat namespace '_sodium_free'
I'm using MacOS Monterey with M1 chip, and trying to build plutus-app using Nix
Entering $ nix-shell using the specified tag from week01 is working fine, hence I can enter into the shell. The problem starts when I run $ cabal build inside plutus-pioneer-program/code/week01
I'm encountering this issue where it seems like libsodium isn't installed correctly.
Installation guide I follow: https://github.com/renzwo/cardano-plutus-apps-install-m1
This solution isn't working for me either, or rather, because of different topic (it discussed about plutus-starter, whereas this is for Plutus Pioneer 3): Cabal build all failing with error: Symbol not found: _sodium_free
Additional info:

running nix-shell in specified tag commit for week01
running nix-shell no problem with IOHK binary cache already specified in nix.conf
I've reinstalled nix and tried it again, but it still give me the same result.

I'm stuck here, and don't have any other machine to spin up Ubuntu at the moment.


text:
How many validator nodes on cardano
How many validator nodes are there that verify 1 transaction block on cardano?

That question is a little confused/confusing.
So far (at mainnet chain tip), there are over 2500 block producers that have created at least one block.
For epoch 329 (last complete epoch) there were 1102 distinct block producers.
Does that answer your question?


text:
Is it possible to specify a Windows named pipe for Daedalus?
I'm on a Windows machine and would like to use cardano-cli to interact with the Cardano network. I have Daedalus running which is running an instance of cardano-node. In order for the CLI to find the node, I have to specify the CARDANO_NODE_SOCKET_PATH environment variable to point to the named Windows pipe (for example, \\.\pipe\cardano-node-mainnet.15992.0).
The problem is that every time Daedalus is closed and re-opened, it will use a different named pipe. Therefore, I need to update the CARDANO_NODE_SOCKET_PATH each time.
Is there a way to specify the Windows named pipe for Daedalus such that it would be static?

It's not possible to configure the pipe name used by Daedalus.
But you could use powershell to find it. Something like:
$Env:CARDANO_NODE_SOCKET_PATH = "\\.\pipe\cardano-node-mainnet.$( (Get-Process -Name daedalus).Id ).0"

Here is a similar question with extra details: https://cardano.stackexchange.com/questions/287/can-daedalus-be-used-to-query-the-blockchain-like-a-passive-node/7398


text:
Can a contract update the metadata of the NFTs in an entire policy or does this have to be done by a node manually?
Given a policy with a list of non-fungible tokens,

Could a smart contract update the metadata of all NFTs in the collection, under certain conditions?
If not, could this be done "manually" by a node?

On a side note, does my question make any sense or am I missing a fundamental aspect on how the whole protocol works?

On-chain metadata can't be changed, I think the answers in this post may help answer your questions.

Great link resource, but as far as I know on-chain metadata can be changed depending on how you mint it. If you use timelocks native scripts or plutus you can indeed change NFT's metadata - just burn and remint them with new metadata attached.
That's been done before. If you really want to ensure immutability right from the beginning you will have to use plutus and the UTxO based approach to mint NFTs one-time-shot.
That was part of the PPP lecture 5/6 I believe

Depends on what you count as metadata, if you're talking about a datum in a smart contract that changes based on who owns an NFT for example yes metadata can change. Of course you can burn and re-mint but that's not changing the metadata in-place on the chain of an NFT, you're burning that NFT and minting a new NFT entirely.

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes or disappears.

If the policy allows you to mint and burn those same tokens (or NFTs) again, you can update the linked metadata for those NFTs by creating a new minting transaction with the updated metadata and then burning those newly minted tokens.
According to CIP-25 the "valid" metadata for an NFT is that of the latest minting transaction, so just by creating and deleting an exact copy of an NFT you will have "updated" its metadata, since metadata is always connected to transactions, and not to the token itself.
https://cips.cardano.org/cips/cip25/#updatemetadatalinkforaspecifictoken

So one way you could do it is by minting NFTs that have a URL in their metadata that links to your server hosting the corresponding metadata - not IPFS.
Then you can easily change the metadata independently of what's on-chain.
It is not very decentralized, since if you're server goes down the NFT's corresponding metadata is not accessible but it gives you the ability to update them without having to create another transaction.
Alternatively, you can use a so called time-lock based minting policies which allows you to change or update tokens up to a certain deadline.
That way you could burn and re-mint a given NFT in the future to update its metadata. But again, trust is required since you basically are in control of the NFTs at all times.

This re-minting is allowed in any policy which is not locked yet? I thought locking policies would only limit more NFTs to be added in the policy

The time based lock just uses some slot deadline - once that slot has passed any tokens minted under that policy are immutable. No further changes can be made to existing token's metadata etc. + no burns/ additions of tokens


text:
Cardano Serialization Lib Usage
I am going through Cardano developer docs and the different APIs used to interact with the Cardano network. In the list is Cardano Serialization Lib which has the description,

This is a library for serialization & deserialization of data structures used in Cardano’s Haskell implementation of Shelley along with useful utility functions.

I am not sure I understand its intended use. Is it an API similar to Blockfrost, Dandelion or cardano-wallet-js? If it's different, what is the intended application?

Generally I think you can say the point of the serialization lib is to help you manage the off-chain aspects of preparing transactions before you submit them to the network.
It's a standalone library that does not interface with the blockchain, but it provides a lot of data structures and functions to make it easier to build and sign transactions, manage keys, generate and attach scripts and metadata etc..
In contrast, a service like Blockfrost (or Dandelion) directly interfaces with the blockchain and can, for example, take care of submitting the transactions you prepared with the serialization lib.
On the other side Blockfrost can also query on-chain data (eg. fetch a list of utxos belonging to an address) that you can then use to compose your transactions with the serialization lib.
So a typical scenario could be:
1. Blockfrost: Get current network parameters
2. Blockfrost: Get UTXOs by address
3. Serialization Lib: Create a transaction with these inputs and these outputs
4. Serialization Lib: Attach this script and some metadata
5. Serialization Lib: Sign the transaction with this key
6. Serialization Lib: Build the final transaction data structure
7. Blockfrost: Submit the transaction to the network
8. Blockfrost: Check the status / block confirmations etc.

I haven't used cardano-wallet-js, but its an SDK that internally makes use of the serialization lib package, and also connects to your own cardano wallet server (which interfaces with your node / the network) - so in a way you can probably call it a hybrid or a higher abstraction layer, that should simplify things even more, if you're running your own wallet server / node.

Thanks! This is most helpful. So I guess, ideally, I could call/use this library if I was creating a wallet and wanted to handle the transaction building part..

Serialization Lib is the Web3.js or Ethers of Cardano. :)


text:
What is the numerator (supply) when calculating the pool saturation level?
The pool saturation level is calculated by dividing supply by the K parameter. What exactly constitutes supply in this equation?
We have the following pots of Ada (from the db-sync ada_pots tables):

UTXO
Reserves
Treasury
Rewards
Deposits
Fees

Obviously, reserves are not counted towards available supply but I'm not sure about the rest of these. Intuitively I would guess that only the "stakeable supply" should count leaving only UTXO and rewards but I'm not sure.

I think what you're looking for is the formula used here to calculate the "circulating supply" from the UTXOs plus "withdrawable rewards" (rewards minus withdrawals). (You should also find the "withdrawal" table in db-sync.)
https://github.com/input-output-hk/cardano-graphql/blob/831e74b8f19b67bb36ab667609ee2a294551ef44/packages/api-cardano-db-hasura/src/HasuraClient.ts#L122
cardano-graphql exposes it through this query:
query adaSupply {
  ada {
    supply {
      circulating
      max
      total
    }
  }
}

https://github.com/input-output-hk/cardano-graphql/blob/f76e944b70c3419ce5c4b56c6a35cdd904afccf0/packages/api-cardano-db-hasura/src/example_queries/ada/adaSupply.graphql
This will currently be 32167734340, and devided by k=500 gives you the current saturation level above ~64M.


text:
Is it possible to get root key from CLI generated private key?
Objective
To load a private key generated by cardano-cli into cardano-serialization lib
Details
Using cardano-cli cardano-cli address key-gen, we get this:
{
    "type": "PaymentSigningKeyShelley_ed25519",
    "description": "Payment Signing Key",
    "cborHex": "582099n3n930d9n31b5b102h3vd9csa290c14e0898sn1d278f1939f3e4bed890675a"
}

Are we able to derive the root key? for example in this format:
xprv17qx9vxm6060qjn5fgazfue9nwyf448w7upk60c3epln82vumg9r9kxzsud9uv5rfscxp382j2aku254zj3qfx9fx39t6hjwtmwq85uunsd8x0st3j66lzf5yn30hwq5n75zeuplepx8vxc502txx09ygjgx06n0p

or seed phrase? for example:
bawdy identify skin design ... squash elbow aloof plain nerve verse reply near

You can use that key to sign transactions in cardano-serialization lib, but I believe you can't go back to a seed phrase or root key / other key derivations from it.
To use it for signing transactions, you can unwrap and create the PrivateKey like so:
const cbor_hex_key = "582019544c6b8de8e697c6efa3a1ea728559b063f77f52314fcd2fbce3b692c3e99f";
const unhex = Buffer.from(cbor_hex_key, "hex");
const decode = cbor.decode(unhex);
const privKey = PrivateKey.from_normal_bytes(decode)
console.log(privKey.to_bech32()) // ed25519_sk1r92yc6udarnf03h05ws75u59txcx8aml2gc5lnf0hn3mdykrax0smqv6uc

(the cbor package for decoding is here: https://www.npmjs.com/package/cbor, the serialization lib pkg I use from here: https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs)
If you do need to start from a root key starting with "xprv...", you can generate an extended key with the CLI using

cardano-cli address key-gen --extended-key

and then use that cborHex value in the serialization lib like so (it will be much longer than the one above):
const cbor_hex_ext_key = "5880a83391da55604678e05489ccb29cee99c238b224b29ef21f98dfd2b121155d5c9dfe7157214cd61c6522aaabb3a5707ae176b220516a51c2cc4f651a3c0dc21c0596b0c11795a9a42cf7ba0014fa402195900813942d66ba3c9b8c175e58fd5ac9e1dfa7008b77af7616ab23a9250374d7c4d39041874cfad9116c204e9b372a"
const ext_unhex = Buffer.from(cbor_hex_ext_key, "hex");
const ext_uncbor = cbor.decode(ext_unhex);
const ext_key = Bip32PrivateKey.from_128_xprv(ext_uncbor)
console.log(ext_key.to_bech32()) // xprv14qeerkj4vpr83cz538xt988wn8pr3v3yk200y8ucmlftzgg4t4wfmln32us5e4suv53242an54c84ctkkgs9z6j3ctxy7eg68sxuy8xfu806wqytw7hhv94tyw5j2qm56lzd8yzpsax04kg3dssyaxeh9gtrw423

But from there also you won't be able to go back to a seed phrase, but in case you're coming from a seed phrase (eg generated via "cardano-address recovery-phrase generate") you can decode it in the lib like so:
const entropy = mnemonicToEntropy("theme debate amateur pudding young deal wealth bag neck victory language abandon tribe unlock rabbit fix visual spawn broom advice anger foam strong document");
const root = Bip32PrivateKey.from_bip39_entropy(
    Buffer.from(entropy, 'hex'),
    Buffer.from(''),
  )
console.log(root.to_bech32()); //xprv1xqdaf53cvc8cdnmx6wf0gz3pxq0kk7rfu7sfkac99tadxs2j0prqe3n20emyw8vv7r8435lw2h4lgar2jwzdyfha7facnln0mhw22dlxgpgw38pt0vus0lyq9rs5rnws79x4dswwyklyklvyuyslh65c4ykl0hr4

Good source for all this: https://github.com/Emurgo/cardano-serialization-lib/blob/4f717ac97bd768168ab273dacd9e43cb6b4aa4ec/doc/getting-started/generating-keys.md)

thanks for the comprehensive answer, it confirmed my understanding.


text:
First epoch slot and stability window
I am building a Cron job to check leader-slots and during testing/learning phase I saw that the command will not start if the slot isn't greater than first slot of the epoch + stability window slots amount or 1.5 days.
Reading around the web I found out that stability window could be edited by the protocol in some cases (please correct me if I am wrong), and so my question is:
Is there a way to query the first block of the epoch and the current stability window? This way I can check those parameters first and then run leadership-schedule command.
Or can you advise other ways to run the leadership-schedule command with a cronjob and being sure that it will run?
Thanks for your time. Have a great day.
EDIT:
what I am currently doing is reading gLiveView code and understanding it.
I found out that there is a function called getEpochStart and I could use it with epoch % of completion to find out when run the job, this way I wouldn't need the Stability window slot amount.
From what I understood, the math that I would need to do is:
timestamp = byron_genesis_start_sec(1563999616) + ((epoch_no(197) * BYRON_EPOCH_LENGTH(21600) * BYRON_SLOT_LENGTH(20000)) / 1000)

By doing the math, I got that epoch 197 of Testnet started on timestamp: 1649103616 which sounds odd to me cause it would be at 08:20PM UTC and from what I know, epoch starts at 09:45PM UTC.
Am I missing something?
Edit2:
Here's the script that I built after the answer was given to me.
I am not an expert on BASH but I does the work, feel free to contact me if you need help with it or have any improvement/suggestions.
Link to the script

Your calc looks ok. Testnet started epoch 0 at 2019/07/24 20:20:16 according to https://explorer.cardano-testnet.iohkdev.io/en/browse-epochs?page=0&perPage=10
Mainnet is 2017/09/23 21:44:51

That's exactly what I needed, thanks so much.
I'll upload the script once finished in case someone needs it :-)
Also if you add your comment to your answer I can mark it as correct

You can check the next epoch once the current epoch is 70+% (3.5 days) through, eg:
cardano-cli query leadership-schedule --mainnet ...... --next
You can then:

Use cron and date checking to run this query every 5 days to coincide with being say 75% through the current epoch, or
Check chain/epoch details to determine % through the current epoch and then run the query.

Edit - Added details from comment:
Your calc looks ok.
Testnet started epoch 0 at 2019/07/24 20:20:16 UTC according to https://explorer.cardano-testnet.iohkdev.io/en/browse-epochs.html?page=0&perPage=10
Mainnet started at 2017/09/23 21:44:51 UTC


text:
StateMachines on Testnet : How to step a client?
I want to run a statemachine on testnet.
The SM runs in the emulator, and I can initialize on testnet,
but if I try to make a new client it throws an error.
The error comes from transition failure, but this is due to the PAB not being able to re-establish state.
I find this pretty hard to debug, but as far as I can see we have the following:

The SM has the function getState function (here)
This calls typeScriptTxOut (here) which expects a value Right Datum or else errors.
The ChainIndexTxOut (Here) has the value type Either DatumHash Datum
the PAB ask the relies on the chain-index for this data.
The chain-index seems to return only Left DatumHash (here)

The chain index does know the datum from the hash.
However this requires an additional query to the datum table or equivalent join.
Has anyone else had this problem / solved this problem/ able to explain how I've got it wrong, and there's no problem here?
(plutus-apps tag:7ed28bd67d7653b3ffe08b45848134380a738148)

Maybe a bit obvious but what constraints did you use in the endpoints? Did you use MustHashDatum or MustIncludeDatum in the construction of the transactions? The former only adds the hash of the datum to the output (and thus results in a Left DatumHash. The latter actually adds the datum to the transaction which creates the utxo (and thus results in a Right Datum).

Don't think I understand the comment. Constraints for SM datums are handled by the SM framework (https://github.com/input-output-hk/plutus-apps/blob/fdb0eec477fc0f99f5edfdbc11c041dbd35ca6bb/plutus-contract/src/Plutus/Contract/StateMachine.hs#L538).
The problem above has now been fixed. (Checkout the issue linked below and the referenced PR)

85% sure this is a bug introduced by changes to the chain index.
A work around is to mod the StateMachine.hs file
getDatum ::
    ( AsSMContractError e)
    => Tx.ChainIndexTxOut
    -> Contract w schema e Tx.ChainIndexTxOut
getDatum tx = mapError (review _SMContractError) $ do
    case Tx._ciTxOutDatum tx of
         Left dh -> do
            dM <- datumFromHash dh
            case dM of
                 Just d -> return (set Tx.ciTxOutDatum (Right d) tx)
                 Nothing -> return tx
         Right _ -> return tx

{-| Get the current on-chain state of the state machine instance.
    Return Nothing if there is no state on chain.
    Throws an @SMContractError@ if the number of outputs at the machine address is greater than one.
-}
getOnChainState ::
    ( AsSMContractError e
    , PlutusTx.FromData state
    , PlutusTx.ToData state
    )
    => StateMachineClient state i
    -> Contract w schema e (Maybe (OnChainState state i, Map TxOutRef Tx.ChainIndexTxOut))
getOnChainState StateMachineClient{scInstance, scChooser} = mapError (review _SMContractError) $ do
    utxoTx_ <- utxosAt (SM.machineAddress scInstance)
    utxoTx <- sequence (Map.map getDatum utxoTx_) -- FETCH DATUMS
    let states = getStates scInstance utxoTx
    case states of
        [] -> pure Nothing
        _  -> case scChooser states of
                Left err    -> throwing _SMContractError err
                Right state -> pure $ Just (state, utxoTx)

Not pretty but I think it works.
Alternative is to mod the chain index code emulating the old behavior.
https://github.com/input-output-hk/plutus-apps/issues/398

My first sugestion would be to avoid using the out-of-the box statemachine from the plutus library at the moment.  In it's current form it is highly inneficient and you will quickly run into maxTx size limits on testnet.   If you want to run a state machine, it is best to build your own so it can be as efficient as possible.   Also, chain index and pab is a nightmare when trying to test on testnet, so it is probably best to use a service like blockfrost.
I have just release The Open Source Cardano Lottery project, which has source code that implements a state machine as well as how to test on testnet (and devnent).   It is a beta non-prod release, so there is room for improvements, but it is fully functional on the testnet.
You can find the source code here:
https://github.com/lley154/cardano-lottery


text:
Can UTxO sit at a minting policy (currency symbol), like at a validator script address?
Both minting policy and validator script are on-chain code. Validator script can be used to lock fund sitting at its validator script address. A transaction can consume the UTxO only if the validator script successfully passes the validation.
Is it possible for an UTxO sitting at a minting policy (i.e. its currency symbol), so that a transaction that successfully consumes the UTxO by passing the minting policy can mint some native tokens?
My understanding is no because minting policy is only a part of a minting transaction but is not supposed to be the script address of an UTxO. Minting native tokens does not work the same as consuming an UTxO sitting at a script address. But I am not sure about my understanding.
Hope someone could help clarify.

As you said, minting policies is part of a transaction and and is not part of a script address UTxO, so it doesn't make sense saying "UTxO sitting at a minting policy", since the minting policy simply allows the minting / burning of native assets or not, it doesn't sit anywhere.
The answer to your question, though, is unexpected. You can create a minting policy that only validates if a certain script is being consumed. You would just need to confirm (in the minting policy) that a certain script is present in the input.


text:
How can a validator script be used to mint native tokens, in addition to perform other checks?
Suppose we want a smart contract (validator script) that locks a user' fund (e.g. ADA) that she deposits and releases it back if she withdraws it. Suppose when she deposits some fund into the validator script, we want in the same transaction the validator script sends her wallet some native tokens as a proof of deposit.
In this scenario, how can the validator script mints some native tokens in the same transaction as a user sends some fund to the validator script?

You need a separate minting policy to mint the tokens.

we want a smart contract (validator script)

I tend to think of smart contracts as including a set of validators and policies, not just one script. It's typical to use multiple in concert.
Essentially the validator holds an NFT with a datum tracking the contract's state. The validator constrains any transaction spending the datum, and checks that the transaction

deposits/withdraws the correct amount,
mints/burns the correct amount, and
replaces the NFT + datum with updated state

The the minting policy will only mint if the NFT is spent--all the logic is on the validator side.
Check out the discussion on "dummy nfts"/"access tokens" here to get a better idea of how that would work.

Great explanation, I am a little confused why you'd put all the logic in the validator.
In the case of depositing money at the contract address, I'd expect the minting policy to run as well + make sure a corresponding output with ADA is created at the script address or did I misunderstand? I don't see how else the validator script would run if there is no output spent in the case of a depositing action.

Hence, I'd almost say the minting policy could do most of the logic except for validating withdraw ownership based on simple pubkeyHash comparison. But it could certainly ensure deposits to be correct (output at script address with equal amount to minted native token). And also burns which check if a corresponding withdraw is done too...
Please let me know if I misunderstand the context.

"make sure a corresponding output with ADA is created at the script address"--that's what I'm saying with "replaces the NFT + datum." Datums must exist on an output. If the validator is already checking that, it would be redundant to have the policy check it again. You could definitely have the minting policy check other things, but remember policies don't have any state, just tx context. There is no datum on the policy. So, if you ever want minting to rely on some state, you need need some validator to manage that state for you. I think it's best to keep all the logic in one spot.


text:
How do I make a Sidechain
I want to make a side chain on Cardano to so something that the protocol says should be done on a sidechain, but how do I make one?
Can I use Plutus or am I limited to the CLI?

To create a side chain, you need a smart contract language both on the Cardano side and also on the side chain side. You also need off-chain code (e.g. a website) for people to interact with those contracts. The general idea is on the Cardano side you create a native token (or use one already in existence), and you have a smart contract that burns that native token, and a corresponding smart contract on your chain that mints that token, and vice-versa. Each chain is independent aside from the interaction of the two smart contracts. You probably also want some logic that prevents the user from minting funds until the other chain can guarantee there won't be a rollback, etc... On the cardano side, that would be the security window of 3k/f slots or 36 hours to have an absolute guarantee that transaction is permanent.

Can you please link to a github or other example so I can figure it out? thanks.

There aren't any :) You're treading new ground! I'm just explaining from a high level how it is designed to work.

Okay idint know that sorry. I was waiting to accept the answer with the link, but inlight of your comment I should change that.


text:
How to integrate ADA Handle into website?
My project allows for users to authenticate with one or more wallets. I would like them to be able to set an ADA Handle they own as their username. What would be the best way to do this?
More specifically, I'm looking for a way to either:

query all ADA Handles owned by a staking address, or
verify that an ADA Handle belongs to a staking address

Edit
Added answer for what is possible now (without setting up a full node and db-sync). Can find handles associated with wallet, but there's no way to detect when the handles are moved to a different wallet. In 2 weeks, it should be possible with Tango, so I will complete my answer then :)

To me your plan sounds like the way to go. Just in case you missed it, theres some documentation here on how to resolve handles to addresses and get all handles by address:
https://docs.adahandle.com/reference/api-reference/cardano-node
But since you're specifically asking about stake addresses (which I think makes good sense for your case of user authentication), your approach should be better suited.
Also just to add you can find the official policy ids here (might make your life easier for testnet at least, since you already found the mainnet policy )
https://docs.adahandle.com/official-policy-ids

Thanks, I did entirely miss those docs I was checking on their discord for something like that, but couldn't find it

I've (sort of) figured it out now. This approach is able to query the Handles associated with a wallet. However, there doesn't seem to be a clean way to check when the Handle has been moved to a different wallet (besides querying again every x hours). For changes to be real time, we have 2 options:

Instead of using Blockfrost, host a Cardano node and db-sync.
Wait for Tango to release NFT webhooks, which are supposedly being released in 2 weeks!

Once I complete one of those options, I will update this answer to make it more useful.
With that disclaimer out of the way, here is the process:

Create a Blockfrost API key and store it in your .env file. If you're using docker, you must also add this key as an environment variable to the correct container in docker-compose.yaml (or Dockerfile).
Use this link from Sean's answer to find the correct policy ID for ADA Handles. I'm using mainnet, so this is f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a.
Authenticate the user's wallet with your backend, and store the wallet's staking key in your database. I have detailed instructions here for how to do this.
Convert the staking key to Bech32. I do this using cardano-serialization-lib, which was set up in step 1:

import * as Serialization from '@emurgo/cardano-serialization-lib-nodejs';
...
export const serializedAddressToBech32 = (address: string) => {
   const addressBytes = Serialization.Address.from_bytes(Buffer.from(address, 'hex'));
   return addressBytes.to_bech32();
}
...
const bech32Wallets = wallets.map(wallet => serializedAddressToBech32(wallet.stakingAddress));

Query Blockfrost for all assets belonging to the user's staking address. If the user's account has multiple wallets, this must be called for each one:

import { BlockFrostAPI } from '@blockfrost/blockfrost-js';
...
// Initialize blockfrost client
const Blockfrost = new BlockFrostAPI({
    projectId: process.env.BLOCKFROST_API_KEY ?? '',
});
const handles: string[][] = await Promise.all(bech32Wallets.map(async bech32Wallet => {
    let handles: string[] = [];
    try {
        const data = await Blockfrost.accountsAddressesAssets(bech32Wallet);
        ....
    } catch (err: any) {
        if (err.status_code !== 404) {
            ...
        }
    } finally {
        return handles;
    }
}

Note that 404 errors are ignored. These are thrown when a wallet has no transactions.

Filter assets and return the names of each one with the matching ADA Handle policy (done inside the try-catch):

// Each asset will look something like this:
// {"unit":"de95598bb370b6d289f42dfc1de656d65c250ec4cdc930d32b1dc0e5474f4f5345","quantity":"1"}
// The unit is the concatenation of the policy ID (56 characters long) and the asset name (hex encoded)
handles = data
    .filter(({ unit }: any) => unit.startsWith(policyID))
    .map(({ unit }: any) => {
        const hexName = unit.replace(policyID, '');
        const utf8Name = Buffer.from(hexName, 'hex').toString('utf8');
        return utf8Name;
    });

Store these handles somewhere, so when the user selects which one they'd like to use, you don't have to query again for verification.
That's it!


text:
Maximum allowable length of a chain fork
Where can you check the maximum allowable length of a chain fork for the current era? And past/future eras?

The security window on Cardano is defined as 3k/f, where 10k/f is epoch length. The security window is the farthest one can rollback under normal circumstances. On mainnet this is 36 hours.

thank you!
reference found: https://docs.cardano.org/core-concepts/chain-confirmation-versus-transaction-confirmation


text:
Relay Node on Cardano
Hello I have recently set up a relay node. Is there a helpful guide/video i can access to create a wallet and send transactions on the relay node? Thanks in Advance?

Thank you for your answers. I shall try these

Here are your options:
Either you create payment keys using the cardano-cli which let's you generate them. Then you create an address from those payment keys and fund it with ADA. Lastly, you can use the cardano-cli to create & submit txs to your node.
https://developers.cardano.org/docs/stake-pool-course/handbook/create-simple-transaction/
Or secondly, you use a light wallet like Nami and connect it to your relay node to submit transactions.
https://forum.cardano.org/t/setting-up-a-custom-node-for-nami-wallet/94333

is it better to link nami to daedalus node or relay node? Thanks

doesn't really matter, Daedalus runs the same node software but also comes with a HD wallet and some other components.

@Cardanofan if you like my response you can mark it as answer!

do you use CNTOOL or you want to do all this steps by commands, manually?
take a look here,
https://developers.cardano.org/docs/integrate-cardano/creating-wallet-faucet

i will search for another resource and come back to you


text:
Is it possible to send funds to a scriptAddress using a lightweight wallet?
I would like that an user using Yoroi/Nami/etc could send funds to a script address which expected an empty datum: ().
EDIT (Pretty obvious, but the UTxO should be spendable later by a transaction)
I guess that this is possible using cardano-cli, however, could an user do that with a lightweight wallet at the time being?
Thanks in advance!

This answer will surely age fast.
At the time of writing both Nami V3.2.0 and Yoroi Nightly 4.11.501 allow you send to script address, but neither advertise any options of setting datums. Nami allows you to add a note, but that's just for the Tx metadata.
The transactions will succeed, and display in blockchain explorers such as cardanoscan. However the outputs will be stranded: no datum at a script address ==> stranded.
Interestingly, these seem to never make it into the chain-index db. Since they are unspendable this is sensible.
For the time being you'll need the Tx to be built using something like the cardano-serialization-lib or equivalent and handed over to the wallet.


text:
Is there a way to set a trigger on Blockfrost to know when an asset has been moved?
With Blockfrost, I can easily query which assets belong to a staking address using /accounts/{stake_address}/addresses/assets. I would like to use this approach to allow users to associate their accounts with an ADA Handle. However, I don't see an easy way to check when the Handle has been moved to a different wallet (besides querying Blockfrost every x hours). Is there a better approach using Blockfrost? Should I look into hosting a node instead?

Using Tango (so not Blockfrost), this should be possible in two weeks. See here.

I don't think Blockfrost offers event based callbacks like that. You might want to look into tangocrypto, but as far as I can tell they also don't offer webhooks for this specific type of event: https://docs.tangocrypto.com/notify/notify/using-webhooks#types-of-wehooks
Maybe it's worth getting in touch with them as I think it could potentially be an interesting addition for their service.
The other option would be to set up a cardano node, as you said, and connect a db-sync (postgres) instance which you can query.

I contacted both Blockfrost and Tango about this feature, so hopefully at least one of them will consider adding it. In the meantime, looks like I'll be setting up a node and db-sync. Thanks for your help!


text:
What is the mkValidator Script
In Plutus scripts there is a mkValidator where it takes in the datum , redeemer , and script context. In the plutus-pionner-program , the plutus scripts they show us uses these three parameters to decide if a transaction will go through. I am looking at the the plutus-use-cases repo and in it most of the scrips dont do it the same why they do it in the lectures. How does this mkValidator work , what is the purpose of it , and is there additional resources that I can read or watch on this

A validator script locks transaction outputs. This function is where you define conditions to unlock them. https://plutus.readthedocs.io/en/latest/tutorials/basic-validators.html

Heads up that the link is dead now.

Link has been corrected

On Cardano logic can be enforced on how UTxO's are spend by attaching a "script" to the transaction + some inputs that will be used to run the script (the datum, redeemer and context). Visualize this script as a black box where the inputs go in and a boolean is the output. If given the inputs the black box return true, then the UTxO may be consumed (the enforced logic of the script is met).
In it core this script is generated from a haskell function that in the plutus-pioneer-program we often call the mkValidator function (it can have any name). This function should have at least 3 inputs, namely the datum, redeemer and context. But note that it can have more inputs that you could define! This mkValidator function is then compiled to a script that is used on the blockchain using template haskell. In this stage all function inputs are filled in expect the datum, redeemer and context (these should be filled in the usage on the blockchain when a UTxO connected to this script is consumed).
Hope this helps


text:
Script to only accept payments in 100 Ada
How do i create a simple script that users can deposit ada into but only 100 ada per transactions , nothing less than that and nothing more. The transaction will not go through if it is not 100 Ada.

Cardano is a decentralized system, anyone can send anything to any address with any datum attached to it (no one can be censored). There is no way of stopping anyone from sending something to an address, and thats a good thing.
What you can do however is enforce the "spendabilty" of a script address that you created. So an UTxO at an address can only be spend if it sends 100 ada to a predefined address. What are you trying to achieve? If it is something along the line of; I want some to logic to be performed only if 100 ada is payed, then just add the above condition in that plutus validator.

Yeah , thats what I was trying to do. I only want to perform certain action if 100 ada is payed.


text:
What is the data type returned from the function utxosAt scriptAddress
I want to use the value returned from the function utxosAt scriptAddress. What is the value that this function will return ? Is it going to be in a list , json etc.....

A (Map TxOutRef ChainIndexTxOut) see here.
A good example can be found in the pioneer program of how to utilize that
function:
{...}
utxos <- Map.filter (isSuitable pkh) <$> utxosAt scrAddress
{...}
where
   isSuitable :: PubKeyHash -> TxOutTx -> Bool