text:
How to architect a truly decentralized dApp on Cardano?
I have been doing some research on how to properly design and architect a dApp solution on Cardano and came across this nicely, written article (albeit on Ethereum) The Architecture of a Web3.0 Application. I was wondering if anyone could point me in the right direction for something similar on Cardano. How are mainstream dApps like Sundaeswap, etc. architecting their solutions? I think having such documents/diagrams/suggestions readily available in the Cardano community can be of great help! Possible design ideas are also welcome.
Thanks in advance for your responses.

My self have been looking for something similar to the Web 3 stack on Ethereum. I think I found an example of a dApp which illustrates the integration between a web application and the Cardano blockchain through not just one but three wallets (Nami, CCVault, Flint).
https://jsrepos.com/lib/dynamicstrategies-cardano-wallet-connector

Depending on how many features your dApp needs, most of it cannot be fully decentralized yet. The following is a non-exhaustive list of common components of an application, and how to decentralize them on Cardano:

Authentication - If you store additional data about a user - besides what can be determined from the contents of their wallet - you need a way to authenticate them with your backend. See the guide here.
One-time payments - You can use a wallet for payments to a smart contract or wallet. This can be accomplished by making the user send money themselves through their wallet app, or by using a wallet extension (which will only work on desktop currently, as mobile phones don't support browser extensions to my knowledge).
Recurring payments - I don't think this is possible in the traditional sense. You could allow users to send extra funds to give their account "credit", then subtract from this credit whenever your payment period starts. In the future, it would be cool if you could use a reputation system to create a "credit score" for a user, and allow users to build up debt if you trust that they will pay it.
Identity - The most well-known decentralized identity system being built on Cardano is Atala Prism. It's still in develop from what I understand, but you can join their pioneer program if you'd like to integrate it into your application. Identity will be the basis of reputation systems, as over time they can generate a web of trust.
Public time-series data - Public data from sensors, IoT devices, drones, price feeds, etc. will be best suited to store on oracles. There are many companies creating oracles on Cardano. You can find a list here. I don't believe any of these are fully working yet.
Random numbers - This is also a service handled by oracles. Here is how Chainlink does it.
Small, unchanging public data - Probably something that should be stored on-chain or on IPFS.
Large, unchanging public data - IPFS may be suitable for this, but I'm not sure.
Private data - This can be as simple as using the FileSystem API (which I believe only works on Chrome - not even Brave) to read/write data locally on the user's machine. You can also use a service like Storj for private cloud data. Ideally, there would be some program that users can run on their local machine that syncs data between their local file system, their backup drives, and the decentralized cloud so applications don't need to set up access to their cloud account directly. But such a service does not exist.
NoSQL database - I don't think any decentralized databases are stable enough for a production application yet, but you could look into OrbitDB.
SQL database - No decentralized SQL database architectures exist, unfortunately.
Hosting - The only decentralized hosting platform I know of being built on Cardano is NuNet. They are in private alpha, so you can't use it yet. Alternatively, you can host your application using Akash. The only downside is that this is on the Cosmos blockchain, so if you're hoping to pay for your website automatically from user payments in Ada, good luck.
Certificates - Likely every dApp is using Let's Encrypt, which is great because it's free, automated, and open-source (I think). But I don't believe it is decentralized.


text:
How to get tAda?
Currently tAda faucet is down ("We are curently experiencing techincal issues with the faucet"). Please bear with us while we get this sorted"). Is there any alternative to get tAda?
If anybody can help by sending me tAda, below is my address :
addr_test1qzea2taqlalpquy8mysrzu399lrqwyn3rh0j6uxlhrlrm8kdvc7hex6r9hyqh0pfwa4creandeuv0cv8slyj5qrwzurqk3a0gn

The faucet worked for me just now, even though it shows the message: "We are curently experiencing techincal issues with the faucet. Please bear with us while we get this sorted".
It only took about 1 minute to complete.
I've sent you 750 tADA anyway, just in case.

Thank you so much, received tAda you sent.

Also I've just tried the faucet, it works now. Thank you.

It works fine. Just the API on the wallet is responding really slowly because the tx history has ballooned recently. We'll fix this when we get a chance but ignore the server error for now. I've tested it a couple times and eventually received the funds about 10 minutes after I requested.

Here the screenshot of the faucet experiencing server error

great reaction Samuel,
thanks for the update and verification.

please find here all info,
and you can request them
To request tokens using the faucet:
https://testnets.cardano.org/en/testnets/cardano/tools/faucet/

The problem is currently the faucet in that link is down. Is there any alternative?

another try i would do by join the groups below, - either telegram, https://t.me/CardanoStakePoolWorkgroup - or cardano forum forum.cardano.org/ - and ask people if they have to share them with you.

source: Stack Exchange

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

sort: votes


text:
Is there a limit to the number of tokens you can have at 1 single UTXO?
I believe this situation applies to both native tokens and NFTs.
I'm aware that at a single UTXO we can have multiple tokens. For example:
20000 lovelace + 10000 policyid1.tokenname1 + 1000 policyid2.tokenname2

I am aware that there is a transaction size limit but will anything up to that limit be valid?
I'm wondering if it's better to purposely just split it up into multiple tx-outs and create multiple UTXOs so when the UTXOs are spent those transactions will be much smaller. In this case something like:
    1000000 lovelace + 10000 policyid2.tokenname2
    1000000 lovelace + 10000 policyid1.tokenname1

Both methods are perfectly fine to implement, but your answer to the limit is correct. Any number of tokens up to the TX size limit will work. For NFTs you'll want to factor in the size of the metadata as well - that increases the overall TX size.

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


text:
how can I increase the address gap limit in daedalus?
Problem: Payments to a wallet don't show in a daedalus wallet, because it was sent to an address that exceeds the gap.
How can I increase the gap so I can see (and consume) that utxo?

I'm not sure I am following.. Can you provide more information? Is the problem that Daedalus isn't synced? It will need to be in order to see accurate balance data.

daedalus is fully synced

https://forum.cardano.org/t/what-is-the-address-gap-limit-for-daedalus/28489

Should one of the answers be marked as accepted?

How can I increase the gap so I can see (and consume) that utxo?

Daedalus is simply a UI that (for wallet) serves the data provided by cardano-wallet component, you can either use the API to add address_pool_gap OR use cardano-wallet CLI to override the default address pool gap as below:
cardano-wallet.exe wallet create from-recovery-phrase --address-pool-gap 100 --port XXX

With the reply to your question out the way, it is a very bad idea to use this component for anything beyond a very small centralised userbase service.

The bigger the address gap is, slower will be the performance to fetch details about UTxO, as they have to scan larger amount of empty addresses.
Resource consumption of cardano-wallet with larger amount of addresses will be another trouble you will encounter even if you're alright with using large address gap.

It isnt a new/unique problem, most exchanges who tried to use cardano-wallet face similar issues. They usually end up going with a more proficient solution based on querying a layer above dbsync. One common example, initially an attempt to provide a standard by coinbase - is Rosetta API (you can find cardano-rosetta implementation here, and a typical Construction overview here ). It might be a change in your plans from where you are now, but it's an investment well worth the time - countless folks have wrongly started on cardano-wallet API due to familiarity of a wallet, and had to migrate later - the sooner the better if you're aiming for your solution to cater for larger than few hundred users.

Need a bit of environment info first:

What operating system are you using and what version of Daedalus?
Roughly when was this transaction?
I presume mainnet not testnet?
Is the transaction not showing at all within Daedalus transaction list?
Can you see any transactions for the address via https://explorer.cardano.org/en ?

Via the command line you can view all utxo's for an address using:
cardano-cli query utxo --address addr1abc... --mainnet

Note: On Windows there are a few more steps needed first as per: Can Daedalus be used to query the blockchain, like a passive node?
From that output you can manually build a transaction and send your utxo, but there are a few steps to doing this via the command line.

We can get the UTXOs at an address with cardano-cli, but if we're doing 10,000 addresses, then we don't want to manually query those with the cli (even with a script it'd be too difficult). We want to have an automated monitoring system that can get all the transactions. We'd like to raise Daedalus from the 20 gap limit it has now to what CCVault has (200 address gap)... Also we've found an issue with Daedalus that it's stopping even before the 20 gap limit.

I'm not sure of the nature/scope of your project but here are a couple of thoughts.
Cycling through trxs/addresses/utxos and performing checks/alerts would seem better suited to automated scripts and API calls.
https://api.koios.rest/#overview is a great API resource for querying Cardano data.
If not suitable then you could grab the Daedalus source code and tweak whatever values you want then build and run locally.

Looks like the limit of 20 is built into cardano-wallet to adhere to industry standards.
This from github:
'Transactions on addresses that "belong" to the wallet but happen to be beyond its address_pool_gap will not be visible to the wallet. This is a technical limitation of the industry standard BIP-44. See also CIP-1852.'
Ref: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/getWallet
You might need to tweak it and build cardano-wallet locally.


text:
cardano-submit-api to allow local connections on LAN
I have a cardano-node 1.34.0 and the associated cardano-submit-api running on a home server, for some reason I cannot get the cardano-submit-api to listen for incoming API calls.

cardano-submit-api --socket-path /home/cardano/cnode/sockets/node.socket --port 6099 --config /home/cardano/cnode/config/tx-submit-mainnet-config.yaml --mainnet

results in the server apparently listening on the loopback 127.0.0.1
So to get it to listen for external connections I try:

cardano-submit-api --socket-path /home/cardano/cnode/sockets/node.socket --listen-address 0.0.0.0 --port 6099 --config /home/cardano/cnode/config/tx-submit-mainnet-config.yaml --mainnet

Result:

Mar 05 17:12:37 CARDANORELAY cardano-submit-api[46974]: [cardano-tx-submit:Info:12] [2022-03-05 17:12:37.65 UTC] Running server on 0.0.0.0:6099

Port scans from the LAN show no API port services available.  The servers firewall is disabled and no internal firewalls like UFW are operational, portscans show ports SSH, 3001, 8081 (Prometheus) etc as open, but not 6099.
Trying a transaction submit from Flint wallet just gives a server error, Flint custom server set to:

http://192.168.111.107:6099/api/submit/tx

Any help appreciated.
EDIT: Deeper port scans show TCP:6099 is open, not sure why that wasnt picking up before, so the server is actually listening.  Included a firewall rule and it seems the error may be on the Flint side, as no connection is being made to the cardano-submit-api server.

It seems the problem was with Flint wallet, Nami does connect to the cardano-submit-api.
The need to do the detailed port scan had thrown me off the track.


text:
How to properly format a tx for cardano-submit-api
The documentation for cardano-submit-api specifies the following:

Assuming data is a serialized transaction on the file-system.
curl -X POST
--header "Content-Type: application/cbor"
--data-binary @data http://localhost:8101/api/submit/tx

Does anyone have any idea what this 'serialized transaction' is supposed to be? What kind of datastructure should it be...?

You can transform the "tx.signed" signed transaction file to the cbor format like this on linux:
jq .cborHex tx.signed  | xxd -r -p > tx.signed.cbor

What are the contents of tx.signed?

tx.signed is the signed transaction (cardano-cli transaction sign command).

If you're using cardano-cli to build the tx anyway, then why not just use cardano-cli transaction submit instead of the cardano-submit-api?

You ask how to convert it to the cbor format to submit it to a cardano submit-api, and then you ask why you should do that? What could I answer to this? :)

More specifically I am asking what datastructure the cardano-submit-api takes so that I can build it without tools like cardano-cli. I am however interested in tangential questions like 'why would one ever use cardano-submit-api if they are forced to use cardano-cli to create the tx datastructure in the first place.

You can create and sign a transaction without cardano-cli. There are many examples or working projects on Github doing this using Javascript and the Cardano Serialization Library.


text:
What is the Address Gap Limit in Daedalus?
I saw another question posted about the gap limit, but I can't figure out what it is. Can you explain it, please?

Hierarchical Deterministic (HD) wallets allow for a very very large number of addresses/keys to be derived from a single master seed (mnemonic). However, it is computationally infeasible for wallet software like Daedalus to sync all the addresses, so it is limited by the address gap limit parameter.
By default, this limit is set to 20, so wallet software will check the first 20 addresses of a wallet (i.e. m/1852'/1815'/0'/0/0, m/1852'/1815'/0'/0/1, .... m/1852'/1815'/0'/0/19).
When an address containing UTXOs is found, it will sync another 20 addresses after the last address containing a UTXO. For example, if the highest used address is index number 17, then wallet software will query all addresses up to m/1852'/1815'/0'/0/37.
If you have UTXOs sitting at an address with a high index, you can either derive the key-pairs manually or set the gap limit to a higher number. Note: setting the gap limit too high can be strenuous for your computer depending on specs.

how can the gap limit be increased in daedalus? https://cardano.stackexchange.com/questions/7519/how-can-i-increase-the-address-gap-limit-in-daedalus


text:
I hear that Daedalus Is a Full Node Does That Mean I Can Set Up a DB Sync Server On Top of It?
The Daedalus wallet is said to be a full node wallet. Does that mean I can set up something similar to blockfrost on top of it? If so how?

Daedaldus consists of two processes, cardano-node and the wallet itself.
Yes, it is possible to connect a db-sync instance to the cardano-node.

How do you do this? Is there a youtube video I could follow or some docs?

I do not know of a YT video or any docs.
However, all you need is to find the cardano-node's socket file and then use the standard docs for db-sync to connect to that socket.


text:
Issues running Chain-index on WSL2 - fully syncing but not running the webserver
I've run into an issue with the chain-index while trying to run a PAB testnet environment. The index will start up, sync to 100%, update to new blocks, but the webserver will never start. In fact, the port that the chain-index is supposed to occupy remains empty throughout this process. Commmands like curl -s localhost:9083/tip | jq '.tipSlot.getSlot' return nothing.
After some debugging, I isolated this piece of code - this is the last piece of code that runs after starting the chain-index server:
withAsync (runLogEffects (convertLog PrettyObject trace) $ logProgress chan) wait

It seems to log the output of the chain-index's progress, but I'm not sure. I believe it's responsible for outputs like this on the console:
[chain-index:Info:39] [2022-03-06 10:13:17.47 UTC] Still in sync. Applied 13 blocks, 0 rollbacks in the last 300s. Current tip is Point(Slot 52192355, BlockId 1893367e3a8139b6866e4c6e81bb1d2ecfa80660b1b027785f05d3e309a2d6d6)
That was a real output from my chain-index server - and proof that it's updating to the current testnet slot (at the time of this post).
This is the full block of code with the problematic line:
runMain :: CM.Configuration -> Config.ChainIndexConfig -> IO ()
runMain logConfig config = do
  withRunRequirements logConfig config $ \runReq -> do

    putStr "\nThe tip of the local node: "
    slotNo <- getTipSlot config
    print slotNo

    -- Channel for broadcasting 'ChainSyncEvent's
    chan <- newBroadcastTChanIO
    syncHandler
      <- defaultChainSyncHandler runReq
        & storeFromBlockNo (fromCardanoBlockNo $ Config.cicStoreFrom config)
        & writeChainSyncEventToChan convertEventToSyncStats chan

    putStrLn $ "Connecting to the node using socket: " <> Config.cicSocketPath config
    syncChainIndex config runReq syncHandler

    putStrLn $ "Connected to node socket."

    (trace :: Trace IO (PrettyObject SyncLog), _) <- setupTrace_ logConfig "chain-index"
    putStrLn $ "Trace completed." -- Added
    withAsync (runLogEffects (convertLog PrettyObject trace) $ logProgress chan) wait
    putStrLn $ "Async completed." -- Added

    let port = show (Config.cicPort config)
    putStrLn $ "Starting webserver on port " <> port
    putStrLn $ "A Swagger UI for the endpoints are available at "
            <> "http://localhost:" <> port <> "/swagger/swagger-ui"
    Server.serveChainIndexQueryServer (Config.cicPort config) runReq

I have two theories, but otherwise don't really know where to go from here.

There are some issues with running an Async function in WSL2 (unlikely as I see Async functions in other, working Plutus apps)
The database is corrupted somehow, and the line of code shown above is parsing through it in an attempt to fix it. I've tried rebuilding the database three times (using different commits on Github) to no avail.

Node version:
cardano-node 1.33.0 - linux-x86_64 - ghc-8.10
git rev 814df2c146f5d56f8c35a681fe75e85b905aed5d


text:
Missing datums in db-sync
From time to time I encounter transactions which contain UTXOs associated to script addresses with datum hashes for which no corresponding entries are available in the datum table of a fully-synched cardano-db-sync postgres.
Here is a randomly selected example:
select data_hash from tx_out where tx_id = (select id from tx where hash = '\xfc6536534b03f818494f21698994d387c879a121b263153a06975d056d9cf13e');

This will output \x4a664c584e552af70dcc255921811b5f62637fd781a43e5c289d9e571a227117. Then:
select * from datum where hash = '\x4a664c584e552af70dcc255921811b5f62637fd781a43e5c289d9e571a227117';

finds 0 rows.
As datums values are included in the witness set of the corresponding transactions I would expect all hashes to have a matching entry in the datum table.

Is this a bug on cardano-db-sync?
Is there any other way to retrieve those datum values directly, maybe by using cardano-cli to query the blockchain directly?

As datums values are included in the witness set of the corresponding
transactions

This is not true all of the time. When you create a new script UTxO by sending some amount of tokens to it, you don't necessarily need to provide the datum, since there is no validation being made yet. You can if you want, though, by using (in cardano-cli) the tx-out-embeded-datum argument.
When you consume it, however, you'll need the actual datum, since the script validation depends on it. In your case, I assume you are inspecting an UTxO that didn't have any datum attached to it.


text:
Transaction lifecycle
Working to understand transaction lifecycle. Some understanding of Bitcoin transaction lifecycle perhaps helps here. That is, a transaction is originated from a client request to a node. This node then broadcasts the transaction to all nodes. Once a certain number (51%?) have affirmed that the transaction is valid (well-formed) then nodes may begin mining this transaction. (This step is of course different, as in Cardano the staking algorithm would run, not a mining algorithm.) However, once a successful block is mined/wins staking, the successful node broadcasts the block. All nodes then begin confirming the block (for example by hashing the chain plus the new block and comparing this value to one provided by the successful node). Once a certain number of nodes (51%?) have confirmed the block, all nodes sink the chain to their local database. Finally the mining/staking reward is awarded to the successful node.
Undoubtedly I have oversimplified and perhaps misstated some steps. But the question is: how close is this to describing transaction lifecycle in Cardano? Is it possible to verbally summarize transaction lifecycle in a way that is mostly comprehensive?

This is indeed oversimplified, but is in principle how a transaction makes it from node to mempool to block.
I addressed a similar version of this question here, and Andrew Westberg also made a great video explaining it.
You can read more about transactions on Cardano at Emurgo's UTXO blog post.

Accepting this answer. Thanks for the external links they are helpful.


text:
Overlap in epochs
Is there an actual overlap in epochs (see https://poolpeek.com/#/epochcalendar)? If so why? Or is this only an allowance for timezones, or are epochs somewhat unpredictable.  On a related note on https://adapools.org/epochs most epochs are 120 hours, but some are 119.9 hours. Why?
Sorry, Probably a noob question but Why do Daedalus Rewards Report Epoch End Dates differ from other sources? doesn't quite seem relevant to my question.

epoch and slots are effectively just ways to express time from start of the chain. What you're looking at on adapools is likely the difference between first and last block within an epoch. You can check the epoch start/end time of given epoch, as well as first/last block of epoch at koios

No, epochs do not overlap. They are also 100% deterministic and exactly 120 hours long (on mainnet).
I cannot answer questions about poolpeek.

The overlap shown is because of the display format of full days. The epoch transitions at 21:44:51 every 5 days, so for most of the day it will be previous epoch and last few hours it will be the new epoch.


text:
Stake Pool Locations. How is the best way to obtain a list of cardano stake pools by country?
I'd like to develop a list of cardano stake pools by country. A static list would be OK, but a repeatable method of developing an updated list by country would be much better. Is there a way of doing this? There are some groovy maps around like The https://input-output-hk.github.io/shelley-node-map/, but a live list by country? Pool explorers dont seem to offer it easily if at all.

In general I do not think there is a reliable way to do this.
The recommended best practice is to have the actual block producing node hidden behind two public relay nodes. If the BP and the 2 relays are in three different countries, which country are you going to assign it to?
If a pool operator says their node is for country X but they run their nodes from another country Y, which country are you going to assign it to?

Makes sense! I guess I am interested in the pools claim to be from country X. So back to the website for that - as you say not particularly reliable.

You may want to look at some of the web sites like https://pooltool.io which may have country information


text:
in plutus-pioneer-program iteration 3 not able to use --required-signer-hash in grab.sh so causing beneficiary's signature missing error (if remove)
Invalid option `--required-signer-hash'
Usage: cardano-cli transaction build
[ --byron-era
| --shelley-era
| --allegra-era
| --mary-era
| --alonzo-era
]
[ --shelley-mode
| --byron-mode [--epoch-slots NATURAL]
| --cardano-mode [--epoch-slots NATURAL]
]
(--mainnet | --testnet-magic NATURAL)
[--script-valid | --script-invalid]
[--witness-override WORD]
(--tx-in TX-IN
[--tx-in-script-file FILE
[(--tx-in-datum-file FILE | --tx-in-datum-value JSON VALUE)
( --tx-in-redeemer-file FILE
| --tx-in-redeemer-value JSON VALUE
)]])
[--required-signer FILE]
[--tx-in-collateral TX-IN]
[--tx-out ADDRESS VALUE
[ --tx-out-datum-hash HASH
| --tx-out-datum-hash-file FILE
| --tx-out-datum-hash-value JSON VALUE
| --tx-out-datum-embed-file FILE
| --tx-out-datum-embed-value JSON VALUE
]]
--change-address ADDRESS
[--mint VALUE
(--mint-script-file FILE
[--mint-redeemer-file FILE | --mint-redeemer-value JSON VALUE])]
[--invalid-before SLOT]
[--invalid-hereafter SLOT]
[--certificate-file CERTIFICATEFILE
[--certificate-script-file FILE
[ --certificate-redeemer-file FILE
| --certificate-redeemer-value JSON VALUE
]]]
[--withdrawal WITHDRAWAL
[--withdrawal-script-file FILE
[ --withdrawal-redeemer-file FILE
| --withdrawal-redeemer-value JSON VALUE
]]]
[--json-metadata-no-schema | --json-metadata-detailed-schema]
[--auxiliary-script-file FILE]
[--metadata-json-file FILE | --metadata-cbor-file FILE]
[--genesis FILE | --protocol-params-file FILE]
[--update-proposal-file FILE]
--out-file FILE
Build a balanced transaction (automatically calculates fees)
Please note the order of some cmd options is crucial. If used incorrectly may produce undesired tx body. See nested [] notation above for details.
Command failed: transaction sign  Error: tx.body: tx.body: openBinaryFile: does not exist (No such file or directory)
Command failed: transaction submit  Error: tx.signed: tx.signed: openBinaryFile: does not exist (No such file or directory)
grab.sh file
cardano-cli transaction build
--alonzo-era
--testnet-magic 1097911063
--change-address $(cat 02.addr)
--tx-in a6890c2f1bbcbff5dccbd1dfeb1725af1214757c3bbdc7a4b8dcea0228ba9d18#1
--tx-in-script-file vesting.plutus
--tx-in-datum-file unit.json
--tx-in-redeemer-file unit.json
--tx-in-collateral 7691a7e471f0842deb09da58ae4d4d3c4f59e52aa3bd1eabdaadd6b940714edd#1
--required-signer-hash edb335fdf7b7024f3ce25e556ba4cc9ea329561c16cf1a4b5353e463
--invalid-before 1646588049
--protocol-params-file protocol.json
--out-file tx.body
cardano-cli transaction sign
--tx-body-file tx.body
--signing-key-file 01.skey
--testnet-magic 1097911063
--out-file tx.signed
cardano-cli transaction submit
--testnet-magic 1097911063
--tx-file tx.signed
mkValidator :: VestingDatum -> () -> ScriptContext -> Bool

mkValidator dat () ctx = traceIfFalse "beneficiary's signature
missing" signedByBeneficiary &&
                        traceIfFalse "deadline not reached"
 deadlineReached
   where
 info :: TxInfo
 info = scriptContextTxInfo ctx

 signedByBeneficiary :: Bool
 signedByBeneficiary = txSignedBy info $ unPaymentPubKeyHash $
 beneficiary dat

 deadlineReached :: Bool
 deadlineReached = contains (from $ deadline dat) $
 txInfoValidRange info

so finally found the problem and solved it change --required-signer-hash with --required-signer 02.skey that will solve the problem

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


text:
What is an unbalanced transaction? How does adjusting an unbalanced tx actually work?
In Week06, there was an implementation of adjusting an unbalanced transaction in the plutus script.
Can someone explain what an unbalanced transaction really is?
And how does it actually work when we say adjusting an unbalanced transaction?
How do we basically identify that a transaction is unbalanced?
Thank you!

A transaction consumes a set of funds (so called UTxOs) and produces a set. Additionally, it can burn or mint native tokens. An unbalanced transaction is a transaction where the sum of fees and funds produced are not equal to the sum of input funds, minted tokens, and burned tokens.
The balancing takes care of this and adds necessary funds in the inputs and outputs to get to the equality.

Thanks! Oh so this is basically what Lars initially mentioned that the sums of the amounts that are used as inputs, should equal the amounts of the output? Adjustment then is basically the distribution of funds in order for those numbers to add up?

Balancing consists of two parts: i) adding additional inputs ii) distributing excess funds to outputs. Often both parts are needed but in some cases i) or ii) can also be needed alone.


text:
haskell quite hard
i'm newbie and trying to learn haskell, but i'm having a problem in the Data.List chapter of learnyouahaskell as follows:
let xs = [1..6] in sum xs / genericLength xs    -- > it works

Now I try to add the drop function to calculate the average for some elements t want:
let xs = [1..6] in sum xs / genericLength (drop xs) -- > it works
let xs = [1..6] in sum xs / genericLength $ drop xs -- > it doesn't work
let xs = [1..6] in sum xs / genericLength . drop xs -- > also not working

i want to know what is the problem?

What????
First of all, you should just use length instead of genericLegth.
λ > let xs = [1..6] in sum xs / length (drop xs)

<interactive>:7:42: error:
    • Couldn't match expected type ‘Int’ with actual type ‘[a1]’
    • In the first argument of ‘drop’, namely ‘xs’
      In the first argument of ‘length’, namely ‘(drop xs)’
      In the second argument of ‘(/)’, namely ‘length (drop xs)’

The problem is that drop takes two input arguments, not 1 as you have given it in all three examples (the last of which is just wrong).
λ > :t drop
drop :: Int -> [a] -> [a]

Fixing that problem, you get another:
λ > let xs = [1..6] in sum xs / length (drop 2 xs)

<interactive>:9:20: error:
    • No instance for (Fractional Int) arising from a use of ‘/’
    • In the expression: sum xs / length (drop 2 xs)
      In the expression: let xs = [1 .. 6] in sum xs / length (drop 2 xs)
      In an equation for ‘it’:
          it = let xs = ... in sum xs / length (drop 2 xs)

Now, you have a problem with the / operator not being usable with Int.
The solution is:
let xs = [1..6] in fromIntegral (sum xs) / fromIntegral (length $ drop 2 xs)
5.25

The reason this does not work:
let xs = [1..6] in sum xs / length $ drop 2 xs

is because it gets desugared to:
let xs = [1..6] in (sum xs / length) (drop 2 xs)

which does not make sense.

Thank you very much, you have explained it very clearly to me, have a good day, hope to get more help from you in the future.

one more problem, hope you can explain it to me, for example drop has its type defined as follows: drop :: Int -> [a] -> [a] if I want to redefine my own drop function: drop' :: Num -> [a] -> [a] ----> it doesn't work even though Num includes Int in it. sorry for the stupid question, i'm a newbie and learning it from scratch

Num is not a type, its a type class. I suspect what you want is:
drop' :: Num b => b -> [a] -> [a]

The part to the left of the => is a type constraint which says that b has to be a type that has a Num type class instance.

thank you very much, you clarified my problem, i got it. Have a nice day


text:
How to use a relay node as a wallet for faster transactions
So I have set a relay node up on a vps. Now I want to connect it to my wallets in order to send transactions faster. How do I do that? Thanks

It is a common myth inside the NFT community that a node sends transactions 'faster' than a wallet. Daedalus is a node itself so there is no difference between sending a TX via Daedalus and sending it via cardano cli wallet aside from a TON more manual effort in the latter and the risk you'll overwrite and lose your payment keys and permanently lose access to your funds... That said, it seems as though you've bought into this myth, so very well.. here are the answers:
First, you'll want to become familiar with the cardano-cli wallet commands. They can be found here, https://input-output-hk.github.io/cardano-wallet/user-guide/cli
Specifically, you'll want to 'create a wallet from recovery phrase' to restore a wallet into your VPS and then you'll want to use the "cardano-cli transaction" command to send a TX to the NFT vendor.
Examples:
cardano-wallet wallet create from-recovery-phrase [--port=INT] <name> [--address-pool-gap=INT]

cardano-wallet transaction create [--port=INT] WALLET_ID [--metadata=JSON] [--ttl=SECONDS] --payment=PAYMENT...

He only asked how to connect a wallet not necessarily create a new one.
If you have an existing node running and fully in sync, you can use Nami to point to your node under settings - then submitting any tx goes through your node and not blockfrost.

Before setting up your own cardano-node to use it as an submit-api endpoint, you might want to take a look at https://www.freeloaderz.io/.
This is a group of SPOs offering to the community submit-api endpoints that users can set in their wallets exactly for this purpose.

If you don't want to create an HD wallet using the command line and just want to submit transactions to your custom node from existing wallets, check this link out on how to connect Nami/ CCVault (Eternl) to your own node.
HowTo


text:
Why does building cardano-node require unreasonable amounts of disk space?
What is the reason behind the build process with nix requiring so much disk space when building cardano-node?
I totally understand when video games with 4K videos, high resolution textures, large trained neural networks etc take a lot of space. But shouldn't it just be "code" for cardano-node? Are there any big non-code assets or is there a lot of code duplication? (and anything which can be done about it besides buying a larger disk?)
Building with cabal seems to use a bit less space, but it's still GB's.

When using Nix, you need to download and install a huge amount of Nix related stuff that is not required if you are not using Nix.
I am sure you have heard the expression "the only reason I have seen so far is because I am standing on the shoulders of giants". This is also true for Cardano, which stands on the shoulders of a huge number of libraries.
There are a small number of assests like PDF files, but if you look in the git repos, you will see that they are well over 95% code. However, when you install Nix you are installing binaries (for everything down to the most obvious executables like ls).


text:
cbor encode and decode
hope you all are doing great.
I am looking for a way to encode and decode the cborHex. I've done the following:
cardano-cli text-view decode-cbor --in-file wallet.vkey --out-file tx.alonzo

and I get the hex binary format but not a utf8 (human readable) format, how can this be done?
for reference, I've followed this question How to decode cbor which is generated with cardano-cli build command?

I use python cbor2 library or https://cbor.me. In the case of a wallet vkey, it's just a hex value that it'll decode as. Something like a transaction will have more data types embedded in the CBOR.


text:
Nami wallet API implementation example for web app
Are there any examples out there for how to implement Nami wallet end to end for a website (with or without React)? For example, how can I create a button for my site which upon being clicked asks the user if they want to connect their wallet to the site OR if the user has already granted access, then their wallet is opened where they can create a TX, see their TX history, etc.

The best resource I am aware of for you to get started integrating with Nami wallet is this repository:
https://github.com/dynamicstrategies/cardano-wallet-connector
The sample (available via a Live demo) shows how integrations work with various wallets.
Several other resources I have found useful in developing my understanding of Wallet Integration and the Cardano Serialization Library (A utility to make working with Cardano data structures easier) are:

https://github.com/pyropy/full-stack-cardano - Simple next js integration

https://github.com/dendorferpatrick/nami-wallet-examples/tree/master - A Comprehensive and well-documented breakdown of Nami wallet integration with an applied real-world use case

https://github.com/tango-crypto/cardano-wallet-js - Superbly documented overview of using the Cardano Serialization Library

https://github.com/Felippo001/nami-wallet-api - Lightweight integration with Nami and Blockfrost

https://www.cardano-caniuse.io/ - Site that shows which wallets support various API commands

https://srdjanstankovic.com/2021/12/24/how-to-sign-and-submit-cardano-cli-transaction-using-nami-wallet.html - Nice blog post on signing transactions

Hope that helps!


text:
Can you burn/lock/self-destruct NFTs in a a smart contract?
I am involved in an NFT project where there is a policy locking date coming up, but I would like to give the option burn/lock/self-destruct the NFT through a smart contract (SC) at any time after that point, and create a new 'evolved' NFT to give to the holder.
Is this 'locking/burn' possible in Plutus?
I don't want to create a burn wallet as there are obvious security concerns there with private keys. So I think an SC is the only way to go.
I am rather new to plutus so any help is appreciated.

As @kindofdev points out, it is very simple to burn tokens with Plutus scripts. It is a little more involved if you want some kinda of side-effect/record of burning tokens. Still shouldn't be too difficult, although Plutus takes some time to learn.
Background
There are no bounds on what can be sent to a Plutus Script, i.e. the script doesn't do any checks on new UTxOs at the address. This means you can't make the script do something just by sending something to it. The script only sees what is included in transactions spending the UTxOs at that address or minted from the address. It can see the entire transaction though, so multiple scripts can ensure something happens in other scripts atomically before validating.
Why does that matter?
You mention that you want to, for example, send an NFT to be replaced with an "evolved" NFT. You can definitely do this. In the simplest case, you can have your minting policy check that the old NFT is being burnt, at which point it will allow minting an "evolved" NFT.
Minting policies can't track any state though. They don't have a datum. So if you want to include any additional context for when tokens can be minted or evolved, that state must be stored on a separate validator script. This will require (at the very least) one validator script and one minting policy:

A script for validating the burning of the original NFT
A minting policy for minting the new "evolved" NFT

A transaction for evolving your NFT would spend a datum at Script #1 and replace it with a new datum (either identical or with some book-keeping data). The transaction would also mint the new NFT with Minting Policy #2.
The minting policy will only validate if the Script #1 Datum is spent in the transaction and the script will only validate if the old NFT is spent to the script and the new NFT is minted + any additional constraints you want to include.
TL;DR
You can have your "evolve" minting policy check if the pre-evolution NFT is being burned. If you need to include additional state/context for when that can happen, you can include that data on a separate, but inter-dependent, validator script.
Hope that helps. Might be worth looking at these other questions to give you more ideas:
How to lock funds in a smart contract?
Ensuring NFT collection uniqueness using counter as asset name?
Can a smart contract only be interacted with once

I think you could also use two minting policies. One for the "normal" token that will enable it to be burnt and one for the "special" token that will only mint it if the normal token is burnt, no script involved. Both policies would be "invoked" in the same transaction

The problem I see is that neither scripts or policies have access to the tx metadata, where the NFT content is. This means the user could mint a special token with any characteristics he wanted (only constrained by the token name)

One for the "normal" token that will enable it to be burnt and one for the "special" token that will only mint it if the normal token is burnt, no script involved
Thanks. Good point. I'll note this. I think in many cases you'd want to follow the access token pattern to allow any bookkeeping, but there are cases where that is probably superfluous.
WRT metadata. I'm actually unfamiliar with how metadata works. But I'm certain you can put whichever constraints you'd want by recording in the Validator Datum. They might not live on the token directly, but can still be recorded and read.

One option would be to define a validator which always fails and therefore, funds sitting at its address will be locked forever, ie, burned.
{-# INLINABLE mkValidator #-}
mkValidator :: () -> () -> ScriptContext -> Bool
mkValidator _ _ _ = False

Then, you can create a transaction which sends the NFT to the script address using mustPayToTheScript.
Hope this will be useful.


text:
Unable to get transaction hash and index of the UTXO to spend
We are unable to get transaction hash and index of the UTXO to spend. Actually we are creating simple transaction and were using this link https://developers.cardano.org/docs/stake-pool-course/handbook/create-simple-transaction
but we are not getting transaction hash and index of the UTXO to create draft transaction. Please help us to resolve it and give me any suggestion to sort out it.
Thanks.

Why are you not getting it? What error are you receiving and what command are you executing?

Sounds like cardano-cli isn't running properly for you, so lets start with something simple to prove that it is working.
Can you successfully run 'cardano-cli --version' and get the version number?
Also, as others have mentioned here, 'cardano-cli query utxo --address $(cat payment.addr) --mainnet' is all you need to list the details.

Thanks for the quick response.
I am using below command but not getting any output. How could we create Draft the transaction without transaction hash and index of the UTXO. Please help me.
cardano-cli query utxo --address $(cat payment.addr) --mainnet
Thanks.

sorry my english is not so great and i loose it a bit your question. 1. i asked you please for an error message, 2. the "$(cat payment.addr) " , is that file in the same folder you are executing the command? 3. can you replace the "$(cat payment.addr)" with your address? and let us know if you still have an issue. last but not least :) if any question helps you, please vote with the upper arrow :)

Yes, payment.addr file in in the same folder from where we are shooting above command nor we are getting any error to run the command even we try to put direct address in the command but same result not getting any output. Output is coming blank without any error.

Please use reply within threads instead of creating new answer to the post, so that it's easier for you to answer respective queries (you have currently - possibly unknowingly - overlooked other questions). This is also easier for an onlooker to follow the flow of post

Okay, I am still struggling. Please help me on this.

Yes, payment.addr file in in the same folder from where we are shooting above command nor we are getting any error to run the command even we try to put direct address in the command but same result not getting any output. Output is coming blank without any error
Thanks.


text:
How to implement Vesting smartcontract with time period longer than 36 hours?
Context
In third weeks plutus pioneer lecture lars said that Vesting period shouldn't be longer than 36 hours. He argued that this is because time is calculated in slots on-chain and that this parameter might change in the future:

There is one slight complication that Ouroboros, the consensus protocol powering Cardano, does not use POSIX time; it uses slots. Plutus uses real time, so we need to be able to convert back and forth between real time and slots. Right now, the slot length is one second. Knowing that, it is easy to go back and forth between real time and slot numbers. However, this could change in future through a parameter change via a hard fork. And, of course, we can't know that in advance.

We do not know right now what the slot length will be in 10 years, for example. This
means that we must not have a definite upper bound. We know what the slot length will be
in the next 36 hours because if there's a change in protocol parameters, then we know that at least 36 hours in advance.You can not specify arbitrary time ranges in the transaction interval. It must only be at most 36 hours in the future, or it can be indefinite.

I would like to implement vesting smartcontract but for much longer time periods, for example 9 months.
Problem
Right now I see two ways to implement restriction by time:

Use txInfoValidRange by specifying transaction valid range. However I see a huge problem here or maybe I just dont' understand tx valid range correctly. Lets say that validator is of alwayssucceeds type but with added tx valid range check. I don't get it how to guarantee that funds are to be locked until specified SLOT, since in this case anyone can build transaction with w/e --invalid-before SLOT parameter they want.

data VestingDatum = VestingDatum
   { deadline    :: POSIXTime
   } deriving Show

{-# INLINABLE mkValidator #-}
mkValidator :: VestingDatum -> () -> ScriptContext -> Bool
mkValidator dat () ctx = traceIfFalse "deadline not reached" deadlineReached
 where
   info :: TxInfo
   info = scriptContextTxInfo ctx

   deadlineReached :: Bool
   deadlineReached = contains (from $ deadline dat) $ txInfoValidRange info

Provide some kind of time NFT from oracle.

Questions

What is currently the best way to implement Vesting with longer than 36 hours time periods?
How likely is 1 SLOT == 1 Second parameter to change in the future, when and by how much?
Does universal time NFT oracle exist in Cardano ecosystem?
Is there a way to provide restriction that for funds to be unlocked from the smartcontract transaction must have specific --invalid-before SLOT parameter?

Lars is right. There is no guarantee that 1 slot remains equal to 1 second because a parameter update could happen at any time and be applied for future epochs. There are currently no plans to change this and I don't know why it would be changed from 1 second. I also don't know of any specific time oracles, but you're right in thinking this is a viable option.

"anyone can build transaction with w/e --invalid-before SLOT parameter they want.".

This is not true. In your example, deadlineReached will return true provided the transaction's --invalid-before SLOT is equal to or greater than deadline (once converted) regardless of the transaction's upper bound. You cannot submit a transaction with a higher --invalid-before SLOT than the current slot because ledger's phase-1 validation, which is performed for free before any plutus validator script is run, would reject it.


text:
What is the exact transaction lifecycle?
Something which is still fuzzy to me. What is the exact transaction lifecycle?
What happens after we submit a transaction via the cli? Does the transaction get broadcasted to the nodes directly for the validation process to kick off?
Thanks!

I asked a similar question here. It’s great that this being discussed and the external links provided in the answers have been helpful. https://cardano.stackexchange.com/q/7537/4685

Importantly, a transaction, when sent, cannot be cancelled. One can only request forgetting about it in order to try spending (concurrently) the same UTxO in another transaction. But, the transaction may still show up later in a block and therefore, appear in the wallet.
Discovering a transaction happens regardless of a transaction being present or not as pending. Actually, only outgoing transactions are going through the pending state. Incoming ones or, outgoing ones that have been forgotten may be discovered directly in blocks.
please check here :
https://input-output-hk.github.io/cardano-wallet/concepts/transaction-lifecycle

Super thanks for this. This is really helpful.


text:
How to optimize Plutus smart contracts?
Context
I'm creating scripts with hardcoded parameters in my smartcontract and I would like to reduce footprint of them to reduce transaction fees. Right now i'm doing so using parameterized smartcontracts. I can't provide source but I read or heard somewhere that using parameterized smartcontracts use up a lot of ExMemory. When building plutus scripts i'm using evaluateScriptCounting which after compilation shows me ExCPU and ExMemory of my script. So far I have found the only way to hardcode parameters without using parameterized smartcontracts with BuiltinByteStrings is doing something like this:
{-# INLINABLE flattenBuiltinByteString #-}
flattenBuiltinByteString :: [BuiltinByteString] -> BuiltinByteString
flattenBuiltinByteString [] = emptyByteString
flattenBuiltinByteString (x:xs) = appendByteString x (flattenBuiltinByteString xs)

{-# INLINABLE getPkh #-}
getPkh :: PubKeyHash
getPkh = PubKeyHash { getPubKeyHash = flattenBuiltinByteString [ consByteString x emptyByteString |x <- [128,164,244,91,86,184,141,17,57,218,35,188,76,60,117,236,109,50,148,60,8,127,37,11,134,25,60,167]]}

I was expecting that this way I would get lower ExCPU and ExMemory units. But I did some tests and to my surprise my smartcontract without parameterized parameters was bigger!
Tests

ExCPU -> 8366313, ExMemory -> 28200. Plain always succeeds.
ExCPU -> 8366313, ExMemory -> 28200. BuiltinByteString, no checks, no datum.
ExCPU -> 9080865, ExMemory -> 30600. Parameterized no checks, no datum.
ExCPU -> 9438141, ExMemory -> 31800. Parameterized no checks, added typed datum with 4 fields.
ExCPU -> 10152693, ExMemory -> 34200. Parameterized 4 checks against typed datum.
ExCPU -> 11135202, ExMemory -> 37500. BuiltinByteString 4 checks against typed datum.

Questions

My flattenBuiltinByteString is doing the flattening foldr style which is ineffective and I suppose is why i'm having such big jump in ExMemory units. I was looking for foldl' in Plutus library but couldn't find anything. Does Plutus have something simillar to seq so that I could make my own foldl' implementation?
Are there other more effective ways to flatten BuiltinByteString list on-chain?
What over tricks I could do besides using BuiltinData types instead of my own custom typed data types to optimize my smartcontracts?
Should I even be bothering with optimizations like this, whats the upper ExCPU and ExMemory limit?

I am building a dApp myself and I am running into similar issues related to hitting the current mainnet's maxTxExUnits upper boundaries of exUnitsMem and exUnitsSteps.
In regards to question 4:
You can find the current upper limits by querying your cardano node for protocol parameters like so:
cardano-cli query protocol-parameters $MAGIC --out-file protocol-parameters.json

The limits can be found under: maxTxExecutionUnits
I resolved some of my issues related to exceeding the ExMemory upper limit by:

simplifying/ optimizing the contract logic
removing traceIfFalse statements or at least decreasing long log message string down to error codes
using Bang Pattern in let-bindings
avoid exhaustive case patterns and instead rely on Plutus' throwing an error for a missing pattern match

There are many more resources you can read below for further possible code improvements to optimize your script.
Sources:

MinSwap Article
Plutonomicon

The biggest decrease in mem usage I was able to achieve is by pattern matching against function inputs - especially when it comes to ScriptContext.
Try to always pattern match unless you really need every field inside a given type. Good examples for that are TxOut, Maybe types and any of your datums

Mlabs created excelent tool to quickly check and analyse size of smartcontracts. Github repo is here


text:
What happen with the tAda not returned to the testnet faucet?
After using tAda on the testnet, what happen with unused remnant if for any reason it is not returned to the testnet faucet ? what are the technical implications of not return it to the faucet?

There's no harm in holding small amounts of Ada in wallets for personal usage. If you're not going to play on the testnet anymore we ask you to return funds to the faucet. A few thousand isn't going to make much of a difference in comparison to 30 billion or so in the total system. If you're holding large sums though, please backup your wallet keys and return the funds if you retire a testnet pool, as a number of pools that have delegated stake don't make blocks anymore hurting the chain density on testnet. If we lose too much, we'll need to reset the public testnet from genesis again.

Thanks Samuel, i was just wondering what if the wallet keys get lost for whatever reason. So based on your answer i assume that little amounts do not harm, but is a good practice not poluting the testnet with any kind of lost or unused data.

My guess is that the tADA will remain in test wallets and the faucet will eventually run out.
Projects that are testing and accumulating a lot of tADA (eg a DEX) should send it back once they have completed their testing.
Individual users should send back their tADA if they are not planning on using it any time soon, and request some again when they do need it in the future.
If it doesn't get sent back then eventually a new token would probably need to be created and used for testing.

Thanks MC, i was just reading this other post (https://cardano.stackexchange.com/questions/648/how-will-cardano-address-the-ledger-growth-problem) about the consequences of the ledger getting too big, and although it refers to the main net, i'm still wondering what about the testnet. Anyways, it seems there is no enough practical knowledge in this topic yet for getting some real conclusions.

f that's why I can't request any tada to test my project. Every time I try to request some funds it says "I can't process this payment as there are not enough funds available in the wallet. I am missing: coin: 1000.000000 tokens"

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

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review


text:
Is there a Cardano Quickstart Application?
Me and my team are searching for a quickstart project for Cardano, such that we can start from such a project, understand its architecture, and evolve the base project into a real-life product.
So far, we've found only courses, eg. the Plutus Pioneers Program from IOG or the Gimbalabs Project-Based Learning. But none of the two above is a quickstart that enable us to Quickly have a running application and understand its mechanics.
Details
An example of what we would expect in a simple working application would be the following:

A simple contract (e.g. Gift: someone locks funds, someone else gets the locked funds)
A simple application backend that can run on localhost
A simple integration with Nami wallet to send the funds

There are a few example contracts in plutus-apps repo. AlwaysSucceeds is the simplest, allowing one to lock funds and another to unlock them. Make sure to check the spending script documentation to help with that.
The same repo also has a demo of the Plutus Application Backend (PAB) running locally and integrated with Nami to send some funds. See PAB-Nami simple demo.


text:
How do I get bids or listed NFTs using the cardano serialization libray?
We're building a marketplace for cardano and we're aware that the owned tokens/nfts can be fetched via the getBalance() function. How do we get the bids or lists (for sale) for a particular owner address? Is this stored and decoded somewhere in the blockchain much like the owned nfts? THanks

You cannot get the bids and the listings of NFTs directly from the wallet that is bidding or selling. You need to know which Marketplace (smart contract) has that wallet used and get the information from there.
For example, you can check the contracts of the most popular Marketplace in Cardano (jpg.store) here: https://github.com/jpg-store/contract-v2

Actually, you can't get bids information from blockchain itself.
Since those information are on marketplace smart contract (Jpg.store).
But you can get these information using some provided API.
For example, you can use api which is provided by CNFT.TOOLS.
https://cnft.tools/
Here is example of api.
https://api.cnft.tools/api/external/${policyId}/
This api will give you the current price, and whether nfts are on sale or not, and their metadata, etc...
Hope this will help you.


text:
relationship between seed phrase, wallet address, public key, UTxO, verification key, and signing key
Everything I read about cryptography talks about a "public key" and a "private key". However, the Cardano CLI reality appears more complex.
As I understand it, the 24 word seed phrase is sufficient to generate all the keys and wallet addresses necessary for a Daedalus wallet to function.
If I bypass Daedalus and the seed phrase process and instead generate a signing key (.skey) and a verification key (.vkey) using
cardano-cli address key-gen {parameters}

and an address from those using
cardano-cli address build {parameters}

what qualifies as the "public key"? The signing key (.skey) is obviously the private key. As far as I can tell, once the wallet address is generated, the .vkey file is no longer used. The wallet address of the sending wallet is not necessary for sending ADA. So it appears that the UTxO is the "public key". However, that is not reflected in the language of the articles I have read, which refer to the wallet address as the public key.
It does seems that the UTxO is cryptographically married to the (sending) wallet address, or at least the signing key (which is of course cryptographically married to the wallet address). I have tried sending test ADA thru the CLI from a UTxO from wallet B while signing with the skey for wallet A, and of course that fails. Does that digital marriage between UTxO and (sending) wallet address make it irrelevant which one is the public key?

Firstly, UTXOs are not “public keys” anymore so than mail is not your mailbox. Think of your wallet/address as the mailbox, the UTXO as the mail, and the .skey as the key to the mailbox. It is true that when a UTXO is sent to an address, the only way to unlock it is to use the corresponding address’s private key. However, this is an specific feature of cryptocurrency blockchains, and should not be confused with the “cryptographic marriage” that exists between public/private keypairs. Actually, this “marriage” is more like a parent-child relationship because the public key is derived downstream of the private key.
Second, when you use Cardano-cli to generate keys, it does so randomly, without following any hierarchical deterministic (HD) wallet derivation standards. To derive keys from a 24 word mnemonic, the HD standard is used by wallet software (like Daedalus).
In principle, the .vkey file is commonly used for a wide variety of verification purposes. It is used anytime a private key needs to be linked with something without exposing the private key itself (i.e. smart contract scripting, building addresses, message signing, e.t.c.)
In your case, if all you are doing is generating an address once and only once to use for basic sending/receiving, then yes, the .vkey is relatively obsolete (also if you ever need it you can re-derive it from the .skey with cardano-cli).

The seed phrase corresponds to the root key for derivation. From that root key you can derive account keys (unique wallets with their own payment/stake keys) and the account key typically derives a single stake key and numerous payment keys, 20 at a time. An address is the combination of some header information, the hash of payment public key and hash of stake public key. A utxo is created by sending funds to one of those addresses. The utxo is identified by the hash of the transaction sending the funds and the index of the output in the transaction. When those funds are sent elsewhere, that transaction is then spent and no longer a utxo or unspent transaction output. If you want to use CLI with a seed phrase you need to utilize cardano-addresses command. Here's a python library that shows how the two CLI commands can be used: https://github.com/input-output-hk/adawallet/blob/master/adawallet/adawallet/lib.py


text:
Cardano DB Sync - RTS Options
After successfully with previous question, where I tried to make cardano-node and cardano-db-sync run as a services, I tried to play around with +RTS ... -RTS option on cardano-db-sync, specifically to reduce the RAM consumption with some option.
Here's the RTS option I tried +RTS -N2 -A16m -qa -qb -qg -M6000M -RTS.
With cardano-node run ..., I can do above RTS options, but with cardano-db-sync ..., I couldn't, here's the sample command
...
...
...
PGPASSFILE=${PGPASSFILE} cardano-db-sync +RTS -N2 -A16m -qa -qb -qg -M4500M -RTS --config ${CONFIG} --socket-path ${CARDANO_NODE_SOCKET_PATH} --state-dir ${STATE_DIR} --schema-dir ${SCHEMA_DIR}

But, it fails, the error shown as below
Mar 08 09:54:54 cardano-db-sync: Most RTS options are disabled. Link with -rtsopts to enable them.
Mar 08 09:54:54 cardano-db-sync-run.service: Main process exited, code=exited, status=1/FAILURE
Mar 08 09:54:54 cardano-db-sync-run.service: Failed with result 'exit-code'.

I tried to add -rtsopts as suggested on that error, but it also fails
PGPASSFILE=${PGPASSFILE} cardano-db-sync +RTS -N2 -A16m -qa -qb -qg -M4500M -RTS -rtsopts --config ${CONFIG} --socket-path ${CARDANO_NODE_SOCKET_PATH} --state-dir ${STATE_DIR} --schema-dir ${SCHEMA_DIR}

Same error is shown
cardano-db-sync: Most RTS options are disabled. Link with -rtsopts to enable them.

Also, I tried to do that with another way (reference - on official documentation), -with-rtsopts="-N2 -A16m -qa -qb -qg -M6000M", but it also fails with error, as shown below
Invalid option `-with-rtsopts=-N2 -A16m -qa -qb -qg -M4500M'

Is it possible to add the options +RTS ... -RTS like I tried above?
Or, am I did wrong? Like, it must come sequentially right after/before some command?
Thanks in advance! And, have a great day!

*PS

The reason I did try to reduce the RAM consumption is because cardano-node run and cardano-db-sync keeps dropped (killed) from the services, since I had limited RAM (16GB) on my test server. I kinda aware with RAM requirement, but I tried to reduce it, due some circumstances, I can't upgrade RAM on my test server, since it has cardano node running too.

I'm not GHC expert or even linux expert. So, if there's some terms or RTS option that I use incorrectly, please let me know, so I can do in a correct way. :)

I am the main developer on db-sync. Trying to reduce the memory footprint of db-sync using RTS options will fail with 100% certainty.
The problem is that both node and db-sync have a data structure called ledger state (which is huge, like 8 Gigabytes huge) that is basically identical. Long term, we want to reduce that so that db-sync does not need to maintain that. Until then, you need to just live with the high memory usage.

Hi @ErikdeCastroLopo - thanks for your comment & explanation. Want to confirm for your statement - "Trying to reduce the memory footprint of db-sync using RTS options will fail with 100% certainty." - is that meant I couldn't use RTS options, like I used on cardano-node run? || And, "Until then, you need to just live with the high memory usage." - you mean, the only way is to upgrade RAM?

RTS options might allow you to shave as much as 20% off the memory usage at the cost of a performance hit (because the garbage collector will need to run more often). Unfortunately the only current solution is more RAM.

Do you know what RTS options that might be available for me to use? since, from what I test around from initial options +RTS -N2 -A16m -qa -qb -qg -M6000M -RTS it gives me error message Most RTS options are disabled. Link with -rtsopts to enable them.. Anyway, thanks for your comments.

Oh, sorry, RTS opts are disabled by default in the db-sync build.
To enable it add -rtsopts after -with-rtsopts=-N3 for the cardano-db-sync executable in the file cardano-db-sync/cardano-db-sync.cabal

Thanks for your guide! seems it kinda works, but unsure if it will fail or not, since I just started the cardano-node run again, so it needs time to catch-up. Have a great day! :)

It will like work really well for the vast majority of the mainnet chain. You are really only likely to run into problems later on the chain where there is just orders of magnitude more data on the chain.

Ahh yes.. I tried to tweak around the RTS options, but on some options, it will be dropped (service killed since it needs more RAM consumption). Anyway, your comment to add "-rtsopts" is correct, do you mind to post it as answer perhaps? so I can mark it as the correct answer on this post. :)

RTS opts are disabled by default in the db-sync build. To enable it add -rtsopts after -with-rtsopts=-N3 for the cardano-db-sync executable in the file cardano-db-sync/cardano-db-sync.cabal.

thanks for this! hope the others will got help in the future!


text:
setting postgresql for db-sync
I have followed the instructions bo build both the cardano-node and cardano-db-sync in the same folder.
I managed to fully sync the node, which is running when attempting to use dbsync.
When I try to follow the instructions to launch db-sync
PGPASSFILE=config/pgpass-mainnet cabal run cardano-db-sync -- \
    --config config/mainnet-config.yaml \
    --socket-path ../cardano-node/state-node-mainnet/node.socket \
    --state-dir ledger-state/
    --schema-dir schema/

I get the following error
[db-sync-node.Subscription:Error:51] [2022-03-09 21:22:29.03 UTC] Identity Connection Attempt Exception, destination LocalAddress "../cardano-node/state-node-mainnet/node.socket" exception: Network.Socket.connect: <socket: 22>: does not exist (Connection refused)
[db-sync-node.ErrorPolicy:Warning:6] [2022-03-09 21:22:29.03 UTC] IP LocalAddress "../cardano-node/state-node-mainnet/node.socket" ErrorPolicySuspendPeer (Just (ConnectionExceptionTrace Network.Socket.connect: <socket: 22>: does not exist (Connection refused))) 20s 20s

When I copy the lines from the postgresql setup command that seems to answer my issue:
~/cardano/cardano-db-sync$ PGPASSFILE=config/pgpass-mainnet scripts/postgresql-setup.sh --createdb

this error message is more telling
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  database "cexplorer" does not exist

I must admit I installed postgresql via sudo apt-get install and I don't know how to proceed properly from there. Do I have to set up a new datbase called cexplorer? should I create a new user for postgresql? for linux? should I edit permissions (i get a permission 600?
After running PGPASSFILE=config/pgpass-mainnet psql cexplorer i got the following error
WARNING: password file "config/pgpass-mainnet" has group or world access; permissions should be u=rw (0600) or less
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  database "cexplorer" does not exist

The documentation is so comprehensive and well done!, I don't understand why this very specific part is not in it (or I am not able to jauge my own incompetence;) )

edit: removed "mainnet" from the db-sync call parameters. Failing to find the .sql file from the restored snapshot lead the psql database to revert to  genesis. --state-dir ledger-state/mainnet(wrong)

should I edit permissions (i get a permission 600?

Yes, you need to reduce the permission down to 600. In addition you might also want to look at few things from a default Postgres deployment (authentication, contents of your private file, [unrelated to this issue - tuning], etc.)
Also, a sample of instructions going through above for setup of Postgrest itself can be found here - ensure you update the folder structure as per your environment, and steps post setup of Postgres instance and building cardano-db-sync here.

I recently set up everything and it works, but I used nix and not cabal as I assume from your PGPASSFILE command that you used.
Regarding the permissions, no, you do not need to do it, I had the same error and it doesn't affect anything. You can do it if you want to be sure.
Your last error regarding the socket is also perfectly normal. The database cexplorer gets created automatically for mainnet the moment you start DB sync and since you are not at that point yet you get this error. After DB sync has started you can use
psql cexplorer

and access the database (have in mind the command psql is followed by a database name, if none is given, the name postgres is the default and a postgres database already exists).
It says about the socket being down anyway, but also make sure to have the socket online by using
pg_lsclusters
pg_ctlcluster <Ver. number(1st column)> main start

If your socket 5432 is down, that might also explain the initial errors you get.

Seems like there was two missing parts:
First, add a new user to postgres:
(from https://cardano-community.github.io/guild-operators)
echo $(whoami)
# <user>
sudo su postgres
psql

CREATE ROLE <user> SUPERUSER LOGIN;
ALTER USER <user> PASSWORD 'PasswordYouWant';
\q

Not sure where to specify the password, so I used my account password (yikes!)
Second, create the database
with the db-sync provided script (dbsync)
cd cardano-db-sync
scripts/postgresql-setup.sh --createdb

Third, define the communication socket
My db-sync parameters points to a socket, but cardano-node doesn't seem to open the socket by default.
I added a the socket to the parameters when launching the node as follow:
cd cardano-node
cardano-node run --socket-path ./state-node-mainnet/node.socket

Then launched db-sync with the same exact parameters (other terminal)
cd cardano-db-sync
PGPASSFILE=config/pgpass-mainnet cabal run cardano-db-sync -- \
    --config config/mainnet-config.yaml \
    --socket-path ../cardano-node/state-node-mainnet/node.socket \
    --state-dir ledger-state/mainnet \
    --schema-dir schema/

note that both socket-path points to the same path
it works !
After a few minutes of verification and syncing the node created the socket!
Thanks for all your very helpful answers.
My next steps will obviously be security and tweaking.


text:
Stake Pool Pledge: Must the pledge amount be part of the active stake? Is Live stake okay?
I understand the pledge must be met by the stake pool owners. My question is basically if ada is added it takes 2 epochs to become active stake.
Can I increase the pledge amount immediately after the ada is added to the owner wallet or should I wait 2 epochs until the amount is active?

Can I increase the pledge amount immediately after the ada is added to
the owner wallet -

Yes.

or should I wait 2 epochs until the amount is active?

No.


text:
How to check whether my two pubkeyHash is different or not using Haskell?
I'm using this script to check but this doesn't works for me
import    Prelude  hiding (Eq)

mkPolicy :: PubKeyHash -> PubKeyHash -> TokenName -> BuiltinData -> ScriptContext -> Bool
mkPolicy owner1 owner2 name _redeemer ctx = checkOwnerHashDifferent

    checkOwnerHashDifferent :: Bool
    checkOwnerHashDifferent =  Eq owner1 owner2

can someone help me to resolve this?

Eq is a type class and hence will not work as you have used it above.
Assuming that PubKeyHash has an Eq typeclass instance you just need:
    checkOwnerHashDifferent :: Bool
    checkOwnerHashDifferent =  owner1 == owner2


text:
How to calculate the slot time of a given date?
I would like to know how to calculate the slot time for a particular date(e.g. 1/1/2023).

Please, check this: https://cardano.stackexchange.com/questions/7034/how-to-convert-posixtime-to-slot-number-on-cardano-testnet/7035#7035

This depends on the slot length which can be changed. You can't be certain about a slot number for sometime that is a long time in the future.
If you assume you know the slot config then you can use
https://github.com/input-output-hk/plutus-apps/blob/d637b1916522e4ec20b719487a8a2e066937aceb/plutus-ledger/src/Ledger/TimeSlot.hs#L130


text:
Getting TypeError: EC is not a constructor running pab-nami
When running npm, start inside a nix-shell of plutus-apps/plutus-pab-executables/demo/pab-nami/client

Actual steps would be helpful here so that the advice is crystal clear.

You're right. There's a bug open internally for this.
In future, it's best to raise questions here and bug reports over in the plutus-apps Github repo. I've also raised it there now: #357


text:
Is it me or is the tx_in table completely unnecessary in dbSync?
If I've understood the dbsync schema properly then the tx_in table is completely unnecessary. The two fields (tx_in_id & redeemer_id) should just be brought into the tx_out table and left null when a UTXO has not yet been consumed. This would be far more intuitive, or am I missing something?

db-sync is insert only. You need to be able to see what the state was at any particular point in time. If it modified rows that wouldn't allow you to do so.

Got it. But for my purposes (analysis) lt seems like can merge the tables without messing up the data. Cool.


text:
How to Ensure Constant Timing in Contracts Given Slots can be Changed?
The amount of time a slot represents can be changed. This means if I code a smart contract that has some sort of waiting function for N slots, the amount of time it waits for will change with the slot time.
How do I write my code to be independent of the slot time, and avoid this problem?

Can you explain the use case? A Contract has access to all the worlds resources, so you can access the slot config, and compute it that way with a function. Onchain scripts use POSIX time.

I am just asking the question to build out the Cardano docs with things I thought new devs would need in the future. I was going to answer this myself, but if you could explain the conversions and some best practices I can accept the answer and upvote it. The use case - I don't actually have one, its not a problem I'm facing.


text:
Disk Space of Cardano node & Cardano DB-sync
I recently installed the Cardano node and Db-sync and Postgres using nix. I use a server with 97 GB of space, node version 1.34.1 and DB-sync version 12.0. The node took about 70 GB after fully synced and DB-sync is still syncing on epoch 254. So far in total they have taken 88 GB of disk space.
My questions are:

Is this normal?
How much disk space is it expected to take when it is fully synced?
Does installing with cabal save up space? and how much?

Thank you for your answer!
Edit: For anyone interested, the cexplorer (i.e. mainnet) database at epoch 372 takes 221GB and the cardano-node folder 84GB (with nix installation).
The whole installation (node, db-sync, nix, Postgres) takes 338GB of storage.

As an FYI, the mainnet node DB/chain itself is currently using 41GB of disk on Linux.
$du -h db
38G     db/immutable
2.9G    db/ledger
163M    db/volatile
41G     db

Thanks for the info, but if I remember correctly the chain (up to epoch 324) took me about 60-70 GB. Definitely more than 41 GB. Can you tell me please where I can find the db folder?

I found the db folder, mine is named db-mainnet, and you are right. It is indeed 41gb and together with cardano-db-sync folder they are 44 gb. The Postgres cexplorer database is 15 gb. I am sorry for the possibly naïve question, I'm kinda new to cardano and Ubuntu, but where is the rest disk space taken from? Thanks again.

You can check disk usage with the Linux 'du' command eg 'du -h .' to get output of the current directory and sub-directories. You might have hidden directories too, so the command 'ls -la' will show you all directories, then you and do a 'du' on them eg 'du -h dir1'. If building from source then cabal and nix take up a lot of space.

Thanks for the follow-up! I just checked and although the node + db-sync + postgres take up 59 GB, nix alone takes 29 GB! That is extreme. Do you know if it safe to remove nix or will everything collapse? I think I will also make a new post about it.

Yeah probably best to accept an answer on this one and open a new question with more details. In short though, it will depend on what you want to use that system for.

The database for db-sync at chain tip is over 100GB.

Syncing on epoch 254. So far in total they have taken 88 GB of disk space.

Yep and by the time you get to epoch 323 (current tip) the database will need more than 100GB.

Is this normal?

Yes

How much disk space is it expected to take when it is fully synced?

Currently about 100-120 GB.

Does installing with cabal save up space? and how much?

Might save you as much as 10GB.

Thank you for answering! So far I'm at 92 GB with DB-sync at epoch 261 and syncing really slowly.
When you talk about the space needed, you mean for both the node and DB-sync right?
Cabal is definitely not worth re-installing then.

If you are happy with that answer, please consider accepting and up voting it.

I cannot upvote yet because I'm new. Despite I appreciate your answer, I would appreciate helping more, since you even took the time to re-comment, instead of reputation begging.

What is the current storage consumption for DB-sync? There's no "extended" version anymore either, right?

Yes, I believe there is no "extended" anymore. My latest install was through snapshot though and the "extended" parameter was not needed. The "epoch" table was still created. I assume that's the general case and not snapshot specific.

The cardano-db-sync folder is currently at 29GB (epoch 372).

For Epoch 359, cnode at 82G and db sync is 216G (sudo du -hd 1 /var/lib/postgresql/12). Looking  at the comments above it makes sense that the DB is way larger, 2.6x in this case.


text:
Do NIPoPoWs (Non-Interactive Proofs of Proof-of-Work) only apply to PoW blockchains or can it be applied universally to any consensus algorithm?
Here the link to the NIPoPoWs paper
The jargon and complexity of the topic is too difficult for me to parse.

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

By definition, NiPoPoWs are lightweight proofs for Proof-of-Work blockchains. In a nutshell, they operate by taking advantage of the fact that every so often, a block of highly unusual likelihood is mined. Here’s a quick summary:
In PoW, a miner is elected Block leader when they win a lottery by producing a block hash with a certain difficulty level. Let’s say (for arguments sake) the chances of producing such a block are 1/100. Every so often, a miner will produce a block hash with an unusually high unlikelihood (I.e. 1/10,000 chance). NiPoPoWs take advantage of this “super-unlikelihood” by recognizing these super blocks are produced at a regular cadence. So instead of validating the entire blockchain, one only needs to validate the superblocks, which may be a much smaller subset of the rest of the blocks.
Another way to think about this: lets say there is an engine running and you know that a every 1000 engine cycles, the piston makes an unusual noise. If I ask you to count how long 5000 cycles takes, instead of counting 5000 engine cycles, you can just count 5 of the “unusual” cycles.
Here’s a more beginner friendly article on the topic.

This is very surprising answer. Only in that in that it's so unexpected.  Thank you!

This is an amazing explanation of what NIPoPoWs is.  But I guess by superficial extrapolation it does answer my question ie. This sounds like a PoW version of PoS where stake pool with a small amount of delegation gets to create the next block.  Is this resemblance superficial or could it be applied to PoS too?


text:
Submitting Transaction with CSL Metadata Isn't Showing
I've forked a dApp Connector I found on Github and I'm trying to add some transaction metadata to the ADA transaction it builds. This is what I currently have:
buildSendADATransaction = async () => {
    //metadata
    const messageData = {
      receiver_id: "SJKdj34k3jjKFDKfjFUDfdjkfd",
      sender_id: "jkfdsufjdk34h3Sdfjdhfduf873",
      comment: "happy birthday",
      tags: [0, 264, -1024, 32],
    };
    const generalMetadata = GeneralTransactionMetadata.new();
    console.log(Buffer.from(generalMetadata.to_bytes(), "hex").toString("hex"));

    generalMetadata.insert(
      BigNum.from_str("674"),
      encode_json_str_to_metadatum(JSON.stringify(messageData))
    );
    const _metadata = AuxiliaryData.new();
    _metadata.set_metadata(generalMetadata);

    console.log(`the metadata is ${_metadata.metadata()}`);

    // build tx
    const txBuilder = await this.initTransactionBuilder();

    const shelleyOutputAddress = Address.from_bech32(
      this.state.addressBech32SendADA
    );
    const shelleyChangeAddress = Address.from_bech32(this.state.changeAddress);

    txBuilder.add_output(
      TransactionOutput.new(
        shelleyOutputAddress,
        Value.new(BigNum.from_str(this.state.lovelaceToSend.toString()))
      )
    );

    // Find the available UTXOs in the wallet and
    // use them as Inputs
    const txUnspentOutputs = await this.getTxUnspentOutputs();
    txBuilder.add_inputs_from(txUnspentOutputs, 1);

    // calculate the min fee required and send any change to an address
    txBuilder.add_change_if_needed(shelleyChangeAddress);

    // once the transaction is ready, we build it to get the tx body without witnesses
    const txBody = txBuilder.build();
    txBody.set_auxiliary_data_hash(hash_auxiliary_data(_metadata));

    // Tx witness
    const transactionWitnessSet = TransactionWitnessSet.new();

    const tx = Transaction.new(
      txBody,
      TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes()),
      _metadata
    );

    let txVkeyWitnesses = await this.API.signTx(
      Buffer.from(tx.to_bytes(), "utf8").toString("hex"),
      true
    );
    txVkeyWitnesses = TransactionWitnessSet.from_bytes(
      Buffer.from(txVkeyWitnesses, "hex")
    );

    transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());

    const txBodyFinal = tx.body();
    const signedTx = Transaction.new(
      txBodyFinal,
      transactionWitnessSet,
      _metadata
    );

    const submittedTxHash = await this.API.submitTx(
      Buffer.from(signedTx.to_bytes(), "utf8").toString("hex")
    );
    console.log(submittedTxHash);
    this.setState({ submittedTxHash });
  };

It constructs the transaction just fine with a wallet like Nami, but there's no metadata attached to that transaction. Any thoughts?

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

If you are open to integrating with wallets other than Nami Wallet,
Typhon Wallet DApp connector has simple, ready-to-call methods to build a transaction with metadata and/or tokens.
Below is transaction method that adds metadata to a transaction.
const auxiliaryDataCbor = typhonjs.utils
  .createAuxiliaryDataCbor({
    metadata: [
      {
        label: 674,
        data: {
          msg: ["This is a comment for the transaction xyz, thank you very much!"],
        },
      },
    ],
  })
  .toString("hex");

const paymentTransactionResponse = await typhon.paymentTransaction({
  auxiliaryDataCbor: auxiliaryDataCbor,
  outputs: [
    {
      address:
        "addr_test1qz7jw975stagnvs00wsjny6y6gpazn86yvwcm2vy02j3up7mt68vuzvz4nzgs00x0shrgywvy674v6r2zcs8fxvvq27qfjq8np",
      amount: "6000000",
    },
  ],
});

Example at https://docs.typhonwallet.io/examples/paymentTransaction.html#sending-metadata
https://typhonwallet.io

Yeah, I saw that -- but I'd prefer to stick with CSL, any thoughts?

This answer is refferenced from https://cardanoupdates.com/commits/6af4284b32841a13ebe86fdcc6f10dd1d74ddfdc and I have used similar code in production. I haven't tested this function but you should get the idea.
buildSendADATransaction = async () => {
const messageData = {
    receiver_id: "SJKdj34k3jjKFDKfjFUDfdjkfd",
    sender_id: "jkfdsufjdk34h3Sdfjdhfduf873",
    comment: "happy birthday",
    tags: [0, 264, -1024, 32],
};

const txBuilder = await this.initTransactionBuilder();
const shelleyOutputAddress = Address.from_bech32(
    this.state.addressBech32SendADA
);
const shelleyChangeAddress = Address.from_bech32(this.state.changeAddress);

txBuilder.add_output(
    TransactionOutput.new(
        shelleyOutputAddress,
        Value.new(BigNum.from_str(this.state.lovelaceToSend.toString()))
    )
);

/////////////////////////////////
// Add metadata here

txBuilder.add_json_metadatum(
    BigNum.from_str("674"),
    JSON.stringify(messageData)
);
/////////////////////////////////

const txUnspentOutputs = await this.getTxUnspentOutputs();
txBuilder.add_inputs_from(txUnspentOutputs, 1);
txBuilder.add_change_if_needed(shelleyChangeAddress);
const txBody = txBuilder.build();

////////////////////////////
// Create unsigned tx with metadata included

const unsignedTransaction = txBuilder.build_tx();
/////////////////////////////

const transactionWitnessSet = TransactionWitnessSet.new();
const tx = Transaction.new(
    txBody,
    TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes()),
    ///
    unsignedTransaction.auxiliary_data() // Include metadata

);
let txVkeyWitnesses = await this.API.signTx(
    Buffer.from(tx.to_bytes(), "utf8").toString("hex"),
    true
);
txVkeyWitnesses = TransactionWitnessSet.from_bytes(
    Buffer.from(txVkeyWitnesses, "hex")
);
transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());

const txBodyFinal = tx.body();
const signedTx = Transaction.new(
    txBodyFinal,
    transactionWitnessSet,
    ///
    unsignedTransaction.auxiliary_data() // Include metadata

);

const submittedTxHash = await this.API.submitTx(
    Buffer.from(signedTx.to_bytes(), "utf8").toString("hex")
);
console.log(submittedTxHash);
this.setState({ submittedTxHash });};


text:
How to get the address which locked the fund on a smart contract?
I have two users. The first user locks 1 ADA with a Datum at a script address. The second one unlocks the 1 ADA with the same Datum and should now send 5 ADA to user one.
Can I now implement a logic in my endpoints so that the second user can send 5 ADA directly to the first user. In order to do that the second user needs two know the wallet address of the first user, but how does he get this information?
Thanks!


text:
Is there any way to cancel pending transaction in CCvault or any cardano wallets
Hi i was swapping in sundaeswap and price went too far but my transaction is still pending in ccvault so can i cancel or remove pending transaction in ccvault before it goes to order and cancelling order with another fees.

I'd also like to know, I've just found out an address I've sent to is a scam address. How can I stop it?

You could try spending the same utxo the first transaction did and see if that one gets adopted in a block. If it does, that would make that one null and void. Also worth checking TTL on initial tx. It might already have failed and ccvault doesn't have TTL checking in it (I'm not aware of their design, just speculation on why it didn't get added to a block).


text:
Why can't the PAB webserver find a socket in PAB-Nami demo?
I'm trying to run the PAB-Nami simple demo in the Plutus Apps repo. When I run the PAB, either using cabal or with the nix-shell script, I'm getting the error:
plutus-pab-nami-demo: Network.Socket.connect: <socket: 18>: does not exist (No such file or directory)

I'm not sure what's going wrong, and there is no mention of configuring the socket in the README.
Any ideas?

Start up a Cardano Node.
Also, make sure to set the node socket path to to location of your node.sock file is:
export CARDANO_NODE_SOCKET_PATH=/cardano-node/example/socket/

It would make sense if it was looking for a Cardano Node, but the instructions specifically say, "It doesn't use a local Cardano node, nor the chain index." I might try it anyway.

I just needed to spin up a Cardano Node. Thanks.

I want to award you the answer, but we should probably only include the Cardano Node in the answer. The index and wallet aren't necessary, and it doesn't use the socket path env var.

I revised my answer.  Thanks!

The node socket  env var isn't used AFAICT. It uses the pscSocketPath value in plutus-pab-executables/demo/pab-nami/pab/plutus-pab.yaml. I actually have an PR up on the repo to fix the instructions:
https://github.com/input-output-hk/plutus-apps/pull/362

Although my answer helped you along, it seems like you've discovered the actual solution.  I'm not sure the best way to make the changes on this post.  I think I'll leave as-is for now.

Cool. I'll add an answer once my PR goes through, I guess. Thanks for your help!

The issue was I needed a Cardano Node running and I needed to point at the socket. To point your PAB at the socket, update the pscSocketPath value in plutus-pab-executables/demo/pab-nami/pab/plutus-pab.yaml. I got node running following the instructions here.

I created a PR to update the docs to include this information. That has been merged.


text:
Uninstalling Nix after Node, Db-sync & Postgres Installation
I have installed via Nix a cardano node, DB-sync and Postgres on a single server.
My plan is to pass my Postgres data into an Apache Kafka cluster.
My node is synced to tip and DB-sync is on epoch 264.
So far they have taken in total 93 GB of disk space.
I searched for what is taking the most space and I found out that the node & DB-sync are only taking 44 GB, while the Postgres database 15 GB. On the other hand the nix folder alone is taking 29 GB.
My question is, is it possible to uninstall/delete nix to save space or will the whole installation collapse?
Thank you for your answer!

You can garbage collect nix store with nix-collect-garbage tool. This is useful if you have multiple versions in the nix store to get rid of older ones.

Thank you for answering. I only have one version of nix installed and used. Can the garbage tool be of any use then?

No, the Nix database is required as long as you are using Nix.
At chain tip, the PostgreSQL database will take over 100G.


text:
Certification for Plutus Smart Contracts
What does the process look like for certification and auditing of Plutus Smart Contracts?  What are required steps to prepare your dApp for certification?

Too soon to say. The only public announcement so far is https://iohk.io/en/blog/posts/2021/09/22/bringing-certified-dapps-to-cardano