text:
I have a smart contract in Ethereum. Is there a way to migrate it over to Cardano?
I have a smart contract for an NFT in Ethereum and I'd like to put it in the Cardano eco system as well. How can I do that? Is there any 'smart contract bridge' through which I can port it over?

Since I don't know your Smart Contract I am sorry if I am stating the obvious: you know you don't need a smart contract for minting NFT on Cardano, right?

Yes. My requirement is that - I need to deploy an NFT collection which will be generated programmatically. I guess my thoughts were to somehow connect it to the Cardano eco system such that the public can view what's in it to be transparent. My assumption was that such a capability would require programmability over a zero code solution.

You can either rewrite your smart contract in Plutus (haskell) or you can wait for the ERC20 Converter. I haven't heard much about it lately, but the latest status update (October) shows there is progress towards a public testnet deployment:

The team is making continued progress towards public testnet deployment as they parallel track some additional mainnet optimizations. DevOps has completed the first round of testing on an internal environment and is now addressing some fixes prior to redeployment. Once the fixes are confirmed, SingularityNET will do additional testing prior to determining a confirmed release date.

Hope that helps a bit.

A query on the second part of the suggestion: NFTs are minted using the ERC721 protocol right? So does an ERC20 converter help in moving NFT issued on the Ethereum network to Cardano eco system? TBH I doubt it.
My main goal to do this is to save gas fees and eventually sell it off via CNFT platform. Re-minting all of it again seems tedious atm.

Just a couple of weeks ago there was an announcement about IOHK and Bondly partnering up to create a bridge for Ethereum based NFTs to move them over to Cardano.
https://bondlyfinance.medium.com/io-global-and-bondly-announce-development-of-bridge-from-ethereum-to-cardano-networks-3a829e56b5e9


text:
How to send a transaction for native assets via cardano-wallet CLI
To send ada with cardano-wallet cli, you can do
cardano-wallet transaction create <WALLET_ID> --payment <AMOUNT>@<ADDRESS>

But there is no documentation on how to send native assets.

Please refere this API documentation for cardano-wallet https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/constructTransaction
The
{
  "transaction": "string",
  "coin_selection": {
    "inputs": [
      {
        "address": "addr1sjck9mdmfyhzvjhydcjllgj9vjvl522w0573ncustrrr2rg7h9azg4cyqd36yyd48t5ut72hgld0fg2xfvz82xgwh7wal6g2xt8n996s3xvu5g",
        "amount": {
          "quantity": 42000000,
          "unit": "lovelace"
        },
        "assets": [
          {
            "policy_id": "65ab82542b0ca20391caaf66a4d4d7897d281f9c136cd3513136945b",
            "asset_name": "",
            "quantity": 0
          }
        ],
        "id": "1423856bc91c49e928f6f30f4e8d665d53eb4ab6028bd0ac971809d514c92db1",
        "derivation_path": [
          "1852H"
        ],
        "index": 0
      }
    ],
    "outputs": [
      {
        "address": "addr1sjck9mdmfyhzvjhydcjllgj9vjvl522w0573ncustrrr2rg7h9azg4cyqd36yyd48t5ut72hgld0fg2xfvz82xgwh7wal6g2xt8n996s3xvu5g",
        "amount": {
          "quantity": 42000000,
          "unit": "lovelace"
        },
        "assets": [
          {
            "policy_id": "65ab82542b0ca20391caaf66a4d4d7897d281f9c136cd3513136945b",
            "asset_name": "",
            "quantity": 0
          }
        ]
      }
    ],...

In the above example given on the page, the native assets are included in the transactions.

it is for the REST api, right? As far as I understand, cli is a wrapper on top of the api. But it is unclear how to do the same from cardano-wallet cli
with cardano-cli, you can do
cardano-cli  transaction build --tx-out <ADDRESS>+<AMOUNT>+"<TOKEN_AMOUNT> <POLICY_ID>.<TOKEN_NAME>"

This does not answer the question of how to do it with the cli

source: Stack Exchange

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

sort: votes


text:
Is it possible to have an On-chain Set data structure?
As the title of the question says, is it possible for me to use a Set data structure for the Datum and/or Redeemer?

Any type that works with PlutusTx.unstableMakeIsData (or its equivalent) should work, since Datum & Redeemer are wrappers for BuiltInData which is a "wrapper" for Data.
EDIT:
I tried the following example:
data MySampleType = Dummy (Set Bool) deriving (Show)

instance PlutusTx.FromData (Set Bool)
instance PlutusTx.UnsafeFromData (Set Bool)
instance PlutusTx.ToData (Set Bool)
PlutusTx.unstableMakeIsData ''MySampleType

but got the following error messages:
GHC Core to PLC plugin: E042:Error: Unsupported feature: Int: use Integer instead
Context: Compiling type: Data.Set.Internal.Size
Context: Compiling data constructor type: Data.Set.Internal.Bin
Context: Compiling type: Data.Set.Internal.Set GHC.Types.Bool
Context: Compiling data constructor type: SampleStateMachine.Dummy
Context: Compiling type: SampleStateMachine.MySampleType
Context: Compiling type: SampleStateMachine.MySampleType
                         -> Plutus.V1.Ledger.Contexts.ScriptContext
                         -> GHC.Types.Bool
Context: Compiling type: Model.Bid.OrderBid
                         -> SampleStateMachine.MySampleType
                         -> Plutus.V1.Ledger.Contexts.ScriptContext
                         -> GHC.Types.Bool
Context: Compiling type: Model.Order.Order
                         -> Model.Bid.OrderBid
                         -> SampleStateMachine.MySampleType
                         -> Plutus.V1.Ledger.Contexts.ScriptContext
                         -> GHC.Types.Bool
Context: Compiling definition of: SampleStateMachine.mkValidator
Context: Compiling expr: SampleStateMachine.mkValidator
Context: Compiling expr at "sample-0.1.0.0-inplace:SampleStateMachine:(206,9)-(206,48)"

Which, to the best of my understanding, means that it's not a valid On-Chain code.
Fazit: It's currently not possible. But you could create an issue here and request the feature :)

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


text:
Design considerations when automatically signing and submitting Cardano transactions
Automating transactions (eg an Oracle that regularly publishes meta data to the blockchain) require that we balance the necessity to sign each transaction using a signing key with the security of the keys themselves.
What approaches have you and your projects used to tackle this problem? And, how does the approach change as an application's developer team grows?


text:
Extracting metadata info of cardano tokens
I am currently working with cardano-db-sync and I am doing research to extract the metadata of all the native tokens. I found out the policy id and asset name can be extracted from cardano-db-sync but the remaining metadata info should be queried from the metadata server. I am not able to find anything useful related to metadata server. I mean to say what metadata server should I use or setup?

The current off-chain metadata registry is hosted by the Cardano Foundation.
Their endpoint is https://tokens.cardano.org/metadata and you can find the registry itself along with the documentation hosted on github.com.
Right now, the software does not support setting up a mirror of the current registry, which might be annoying as their rate-limiting is pretty strict. At Blockforst, we have developed a tool to convert the current registry files to the output you are expecting - it is called metadada and is open source.

Thank you for your reply but i was trying to get the onchain metadata and i don't seem to get it from cardano dbsync. I need to fetch every data and stored it in a table.

In that case, you might refer to the NFT metadata according to CIP-25? If that is the case, your question is misleading as it talks about the metadata server for native assets , which is what I described in my answer. You might want to submit another question if it is about an SQL query in cardano-db-sync.


text:
Lost our IOHK delegation for SPO
So we run plebpool.com [PLBPL]. We received IOHK delegation and our pool has gone from strength to strength. We are south african based and ran the Johannesburg leg of the cardano world summit. We have been supporting a local organisation called https://www.lifechangersa.org/ which helps homeless people in South Africa. We recently lost our delegation of 3.2M ADA which moved to another pool that already had 2.4M ADA staked. We know this is fair and within any ones rights to move delegations we just want to know, did we do something wrong? It would have been nice for a heads up of some kind as now we have to goto our charity and say we can help nearly as much as before, and why did the delegation move to a pool that seemigly already has established itself as a successful SPO. We were helped out but the move doesnt make too much sense, just looking for some answers as we are left a little perplexed. Thanks community!

IOG as well as the Cardano Foundation run a process for the so called delegation support. Every ~3 months, they choose new pools to delegate to. You didn't do anything wrong, my friend. The whale just moves on, as they always do. :)
As for IOG they usually open up an online form to apply for their delegation and was announced in Sept: https://iohk.io/en/blog/posts/2021/09/01/cardano-stake-pool-operator-delegation-a-new-round/
IOG and CF are not aligned in how they choose pools. You can read the latest statement about the CF delegation here: https://forum.cardano.org/t/cardano-foundation-announces-its-delegation-methodology-closed/41090

Looks like Delegation has rotated. This is a normal behaviour form IOG, as Delegation is not meant to stay forever to one pool.
But the lucky thing is that you can reapply for another round next time the window open up!

you were so lucky that you had it at least once.
some other pools, like our TTS17 is waiting
we will try again next time.
have a nice Cardano Journey mate.
TTS17


text:
Command to transfer funds Faucet
I have the cardano-wallet and cardano-node running on the testnet, but I can't seem to figure out how to transfer tADA into a wallet from the cardano-faucet
Anybody?

You can visit https://testnets.cardano.org/en/testnets/cardano/tools/faucet/ and enter your wallet address. The faucet gives 1000 tADA per day


text:
Multisig Script Syntax Error
I am trying to build a muiltsig address using shelley simple scripts (https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md)
The purpose of this scheme is to have a regular 2-of-2 multisig address backed by a third emergency key that is only valid after a certain slot number.
Here is my script syntax in json form:
{
  "type": "any",
  "scripts":
  [
    {
      "type": "all",
      "scripts":
      [
        {
          "type": "sig",
          "KeyHash": "0d4db33028a10e797670509faf8f8d0d42e35c1d6e78cb5d78403f2d"
        },
        {
          "type": "sig",
          "KeyHash": "69ad5d0ba81fbb859d613b776564596de660d88d032a923347646663"
        }
      ]
    },
    {
      "type": "all",
      "scripts":
      [
        {
          "type": "after",
          "slot": "40250000"
        },
        {
          "type": "sig",
          "KeyHash": "4b263032e57de4cd8a385bc19dbd12ed54499c7d1d483134e616e2dc"
        }
      ]
    }
  ]
}

However, when building the script address, I get the following error:
Command failed: address build  Error: multitest/multisig.json: Syntax error in script: Error in $: "atLeast" script value not found

Kindly explain what am I doing wrong?

You have a two errors:

Your slot number should be an integer
Key word keyHash should have k in lowercase

Using below version, it works.
{
  "type": "any",
  "scripts":
  [
    {
      "type": "all",
      "scripts":
      [
        {
          "type": "sig",
          "keyHash": "0d4db33028a10e797670509faf8f8d0d42e35c1d6e78cb5d78403f2d"
        },
        {
          "type": "sig",
          "keyHash": "69ad5d0ba81fbb859d613b776564596de660d88d032a923347646663"
        }
      ]
    },
    {
      "type": "all",
      "scripts":
      [
        {
          "type": "after",
          "slot": 40250000
        },
        {
          "type": "sig",
          "keyHash": "4b263032e57de4cd8a385bc19dbd12ed54499c7d1d483134e616e2dc"
        }
      ]
    }
  ]
}

At first glance, it might be few issues, as the cardano-cli errors tend to be ambiguous.

Your slot number is specified as a string, while it should be an intiger.
You might need to specify also before slot
You might be signing the with the wrong key

Out of those three points, only the first applies to actually building the script address from the JSON script file, which is what I'm having issues with.
I've changed the slot number to an integer value and I'm still getting the same error:
[Command failed: address build  Error: multisig.json: Syntax error in script: Error in $: "atLeast" script value not found]
Really weird... have I discovered a bug?


text:
Plutus Pioneers Week 01 - How to open EnglishAuction shell?
I was wondering how to get the EnglishAuction shell open so I can run these commands from the first lecture?

Basically you should follow instructions for Excercise Week 01 in order to: setup the plutus repo, nix, cache, etc, as Mitchell said.

Clone the The Plutus repository, check out the correct commit as specified in cabal.project.
Install NixOS cross-referencing the following resources.
Set-up IOHK binary caches How to set up the IOHK binary caches. "If you do not do this, you will end up building GHC, which takes several hours. If you find yourself building GHC, STOP and fix the cache."

Then:

cd /your-repo/plutus
nix-shell
cd /your-repo/plutus-pioneer-program/code/week01
cabal repl

That would be the Cabal REPL. The command is cabal repl.
You need to be sure you are in the correct context for this to work. If you haven't done that, I'd recommend following the Nix setup instructions in the Plutus repo. Once you have nix-shell running you can switch to the Pioneer Program repo and run cabal repl.
Here are some additional community-made instructions that can help fill in the gaps, but I don't think it covers some important stuff like the cache, so I'd start with the official docs.

Thank you so much! :) Finally worked after I followed the Github steps about the IOHK binary caches


text:
How to create private relay, so we are save against DDOS attack if our public relays goes down
I'm planning to build private relay, in case if my public relay will go down due an attack.
Based on my understanding I do not need register that relay when I register pool using command cardano-cli stake-pool registration-certificate
Additionally seems I do need to run topologyUpdater.sh to let other know that they can connect to my pool. Without this I assume there will be no incoming connections and no blocks can be pulled from private relay right. Is it correct?
Do I need to run relay-topology_pull.sh to pull list of relays?
So it means my private relay should be build completely in same way as normal relay, I just do not register it with command cardano-cli stake-pool registration-certificate.
Correct?

Do I need to run relay-topology_pull.sh to pull list of relays?

Yes.

So it means my private relay should be build completely in same way as normal relay, I just do not register it with command cardano-cli stake-pool registration-certificate.
Correct?

Yes, that's right. You want your relay to work just like your other relays. The only difference is that this relay is not identifiable as yours.


text:
StateMachine validation failing
Transition function throws an error. Here it is.
transition :: FreelanceContract -> State FContractDatum -> FContractRedeemer -> Maybe (TxConstraints Void Void, State FContractDatum)
transition fc s r =
    case (stateValue s, stateData s, r) of
        _ -> Just (Constraints.mustBeSignedBy (freelancer fc) , State (FContractDatum 1 (Just 0)) (lovelaceValueOf 2))

Here is the wallet code for submitting the transaction
    case m of
        Nothing             -> throwError "Contract ouput not found"
        Just ((o, _), _) -> case tyTxOutData o of

            FContractDatum 0 Nothing -> do
                logInfo @String "Contract found. Accepting..."
                void $ mapError' $ runStep client Accept
                logInfo @String "Contract Accepted"

            _ -> throwError "unexpected datum"

And here is the error that is thrown when I run my trace.

I have boiled this code down to its simplest parts, but still, the error persists. :/

How about troubleshooting by replacing Constraints.mustBeSignedBy (freelancer fc) with mempty? The Wallet sending the transaction might not belong to freelancer fc

I tried that too! Same error. Maybe my StateMachine setup is where the bug is...

Did you implement the smCheck function?

The problem is most probably caused by an omitted check function. Even if you do not use it, you have to specify it.
Example:
check :: FreelanceContract -> FContractDatum -> FContractRedeemer -> ScriptContext -> Bool
check _ _ _ _ = True

...

fCStateMachine :: FreelanceContract -> StateMachine FContractDatum FContractRedeemer
fCStateMachine fc = StateMachine
{ smTransition = transition fc
, smFinal = final
, smCheck = check fc
, smThreadToken = blah blah
}

with the assumption that the function pointing to your final state is final and your ThreadToken "blah blah" :)

Great minds think alike ;)

True that!!! xD

My StateMachine does not need any additional checks with the smCheck so I completely removed the field. The compiler complained only a little bit and gave me a warning that I had an uninitialized field. Turns out, this field is required for any transitions to be valid.
I added in this function which always returns True and the error was fixed.
check :: FContractDatum -> FContractRedeemer -> ScriptContext -> Bool
check _ _ _ = True


text:
Deploy a smart Contract on Alonzo testnet
Hi I have written a contract in Plutus and test it with PAB and Playground simulations.
The problem I am facing is I cannot find any proper documentation on how to deploy a contract on the test/main net.
I understand that we have serialized the Haskel Script and submit it with the transaction but I am very unclear how to do this step.

Have you checked this tutorial yet?


text:
Impossible to use extended keys with cardano-cli transaction build --required-signer flag
We are implementing the vesting contract from Plutus use cases via cardano-cli
In the validator script we have the pubKeyHash of the pubKey authorized to retrieve the funds.
When the owner of this key wants to retrieve funds, the validator script checks into TxInfo and compares the pubKeyHash of the signer with its hard coded pubKeyHash.
To build such a transaction with cardano-cli we have to use the --required-signer flag to tell cardano-cli we need this key to sign the Tx because the validator script requires it.
We successfully built transaction using "normal" Shelley keys "PaymentSigningKeyShelley_ed25519" (generated with cardano-cli address key-gen --normal-key).
But it doesn't work using extended keys "PaymentExtendedSigningKeyShelley_ed25519_bip32" (generated either using cardano-cli address key-gen --extended-key or converting a cardano-address key using cardano-cli key convert-cardano-address-key --shelley-payment-key).
cardano-cli excludes extended keys from required signers (https://discord.com/channels/826816523368005654/900330165941436427/900330567416029206)
As BIP 32 is THE standard for wallets we want users to be able to interact with the vesting smart contract using their BIP 32 wallets (such as Daedalus).
I have limited knowledge in cryptography so my questions are :

Why cardano-cli is excluding extended keys ?
Is it possible to derive a "normal" Shelley key from an extended one ?

EDIT
For now we have forked cardano-cli and authorized extended keys but it's a dirty hack and we are waiting for answers or solutions.
https://github.com/smart-chain-fr/cardano-node/pull/1

I'm working on similar problem, but i thing this answer should solve your problem: https://cardano.stackexchange.com/a/7428/7022

As of GitHub commit: cc9b567f3acd813c81e105c074ebd783719c74364c88a78c3c22638322354f6d you can specify extended keys as required signers.


text:
How to validate someone delegates to your stakepool, while preserving their privacy?
Say you had a "stake pool paywall" for your website, where you offer your content, but only to those who delegate to your stake pool.
What's the best way to validate someone has delegated to your stake pool, while preserving their privacy?
Ideally this would be some kind of login info they provide (public address paste in?), that automatically checks and unlocks website content access if True.
Ideally, this "proof" would unlock the website "paywall" so they can access your content, knowing they contribute to your pool.  You could potentially unlock "levels" of content for duration of staking.

This is not a complete solution but it may possibly work. But, before that some context on cardano addresses and the delegation process is required:
Cardano addresses are of different types as described on the Cardano Ledger Spec :

Base addresses, Addrbase, containing the hash of a payment credential and the hash of a staking credential. Note that the payment
credential hash is the hash of the key (or script)which has contol of
the funds at this address, i.e. is able to witness spending them. The
staking credential controls the delegation decision for the Ada at
this address (i.e. it is used for rewards, staking, etc.). The staking
credential must be a (registered) delegation credential.

Pointer addresses, Addrptr , containing the hash of a payment credential and a pointer to a stake credential registration
certificate

When a user delegates to a stake pool, a delegation certificate is posted to the blockchain. It contains:

The stake key registration certificate hash
The stake pool id (hash) the use has delegated to.

Assuming a base address is used in the delegation transaction, this means that the address is linked to the stake key hash contained in the certificate.
So a potential login solution would be have the user generate a pointer address in his wallet and paste it in a field on you webapp login page.
On the back-end, you could fetch the original delegation address and the stake key linked to it.Then check if the pointer address submitted is linked to the same stake key as the original address.
If there is a match it can only mean that the private key used to derive the original address is the same private key used to derive the pointer address, therefore the user submitting the pointer address must be the same user who delegated to you pool.
Some useful references related to this:

CIP-19
Formal Spec Doc of the Cardano Ledger
Engineering Design Specification for Delegation and Incentives in Cardano–Shelley

Thank you @Kelli this is awesome.

I don't know if this is a great solution to this, but what you could do, is make logins for your users based off of their Staking Address (stake address = username) and then to validate it you could have them send 1 ADA to you from that Address. Then on your website's backend, you will need to look for that new transaction to your wallet to finish the validation. Once validated, they can set their password, thus protecting others from using the same public stake address. Not a perfect solution but it should work for this.

Thanks for the input @Anton !

You could have a registration / login system set up in this way:
Registration part
In order to get registrated user must input: Name, Email, Stake address, Password. User will be then asked to send a small amount of ADA from the Address associated to that Stake Address (You can query this endpoint to validate the addresses)
Login part
A normal login system. Nothing special about it.

Thanks for the help, sounds like a solid simple approach.  Appreciate it @Dark345


text:
Cabal build all failing with error: Symbol not found: _sodium_free
Attempting to build the cardano-node on Mac OS Big Sur while following the instructions found here: https://developers.cardano.org/docs/get-started/installing-cardano-node/#macos
When I hit the cabal build all step I'm given the following error:
[ 14 of 193] Compiling PlutusCore.Pretty.Readable ( plutus-core/src/PlutusCore/Pretty/Readable.hs, dist/build/PlutusCore/Pretty/Readable.o, dist/build/PlutusCore/Pretty/Readable.dyn_o )
<command line>: dlopen(/Users/sanfordleach/.cabal/store/ghc-8.10.4/lib/libHScrdn-crypt-clss-2.0.0-a62d56db-ghc8.10.4.dylib, 5): Symbol not found: _sodium_free
  Referenced from: /Users/sanfordleach/.cabal/store/ghc-8.10.4/lib/libHScrdn-crypt-clss-2.0.0-a62d56db-ghc8.10.4.dylib
  Expected in: flat namespace
 in /Users/sanfordleach/.cabal/store/ghc-8.10.4/lib/libHScrdn-crypt-clss-2.0.0-a62d56db-ghc8.10.4.dylib

Note: I have the environmental vars.  Not sure how to check that libsodium is installed correctly but I ran the steps in the instructions.
Please help? Thank you!
EDIT 1: I see the libsodium files in my /usr/local/lib so I believe it's installed correctly
EDIT 2: At this point I've already created a node on an Ubuntu instance and it's working fine... not sure if its an issue with Mac OS but I recommend doing the same if you run into this issue.

Do you have a libsodium.so file in your $LD_LIBRARY_PATH (/usr/local/lib)?

I don't believe I do... is that something that's supposed to happen on the install?

I see libsodium.23.dylib, libsodium.dylib,  libsodium.a, libsodium.la in my /usr/local/lib but not libsodium.so....
libsodium.pc is present in my pkgconfig

@sandy-leach did you find any solution?

I was running into this problem on MacOS Monterey (M1 Pro) while building plutus-starter.
Just like OP, I seemed to have installed libsodium correctly as I had all the libs in my PATH. Then I stumbled upon this thread that solved it for me. What I needed was to add a cabal.project.local file in the root of my project with
package cardano-crypto-praos
  flags: -external-libsodium-vrf

which I think makes the VRF not be bundled, and thus ignored as we can do without it anyway.
Also, before that, I rebuilt using libsodium-1.0.18-stable.tar.gz from https://download.libsodium.org/libsodium/releases/, which may also have helped.
Perhaps all of that is useful to someone!

I'm having the same issue but sadly this solution didn't work for me.

If libsodium.so file is missing from /usr/local/lib, the problem here is that libsodium is not correctly installed on your Mac OS X environment.

Did you compile and install libsodium?
Did you check environment variable to see that this is added?

Yep, env vars are there and I ran all of the steps to run libsodium that are in the instructions

I've been trying to run the leader logs script, which happens to depend on libsodium. I run on OSX and this problem has had me dweling on the same questions many asked above.
If you are using OS, you should use the .dylib files as reference. I've found a few open source examples that opted for a best effor library detection mechanism (see https://github.com/papacarp/pooltool.io/blob/master/leaderLogs/leaderLogs.py#L109), which points to using libsodium.23.dylib for OSX.
Unfortunately, I  had an additional problem before being able to run the leaders log. I installed libsodium with brew, which installed the official libsodium project, but the code I needed to run required extra APIs that are only in the IOHK version of the library, so once I downloaded, compiled and installed the source code from this version, everything worked like a charm.
So, a couple of things:

Make sure your configs point to the appropriate path of libdsodium (in OSX /usr/local/lib/libsodium.23.dylib).
Depending on the version you had compiled and installed you might be missing APIs/functions. Check you have the correct version of the library.

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.


text:
How do I mint an NFT without any image and and just some text?
I have made a script here to mint NFT as per the official docs. : https://github.com/nateshmbhat/cardano-nft-minter
But there is no mention in the doc to mint an nft with just some text description and a name.
How would the metadata.json structure for it be ? How does one browse or see that nft once its minted ? can someone please explain ?

If you want to keep the CIP 25 - NFT Metadata Standard, an image is required.
You can, however, add some text to the description property.


text:
tADA not reflecting in wallet after funds request with faucet
As hinted by the title, I've requested 1000 tAda from the faucet and according to what's here the funds is in the wallet.
But when I query the address on my testnet, it returns no result.
What am I possibly missing?

If one of the output address matches your wallet address, then most probably your node is not fully synchronised.

I had this happen yesterday and been troubleshooting since. Turned out my node was technically "synced" but spitting out errors in the log. (above 90%) I have a question out there about the error but have a hunch its because I need to update the cli/node to the latest verified release. Which I'm doing now. Below I outline a method you can use to run and verify your node is running properly. Pre-reqs is you already have the node dependencies installed as outlined in the dev portal.
If you want to see the logs I use nohup and "&" to run the node in the background (On linux, I'm running Debian). I put my cardano-node command in a script like this and name the file run-node.sh
#!/bin/bash

cardano-node run \
   --topology $YOURPATH/cardano/testnet-topology.json \
   --database-path $YOURPATH/cardano/db \
   --socket-path $YOURPATH/cardano/db/node.socket \
   --host-addr 0.0.0.0 \
   --port 1337 \
   --config $YOURPATH/cardano/testnet-config.json

Then you make sure the file is executable by running
chmod +x ./run-node.sh

Then you can run your script and get logs using this command...
nohup ./run-node.sh &

Then you can just run the following to check the logs and verify if there are any errors. (Ctrl-C to exit)
tail -f nohup.out

Oh and if you want to kill that process you can run
ps -aux

which will lay out all your processes. Use the PID of your cardano-node command and kill the process. Simple way to do that is to run
kill -9 $YOUR_PROCESS_PID

Sorry if this answer is a little overkill.

For anyone wondering, this problem did resolve itself after I updated the node and CLI to the latest verified release.

First thing to do is look up the transaction on the testnet explorer.
https://explorer.cardano-testnet.iohkdev.io/en.html
It should have given you the transaction id from the faucet after you made the tAda request.
If you find that transaction on the explorer, it should tell you how many
confirmations have been completed. 30 confirmations are required for a transaction to be fully processed. Only then will the UTxO show up in your wallet.
If there have been 30 confirmations, then you can lookup your wallet address on the explorer and see if it has been updated.
If you can see the UTxO in your wallet on the explorer, then it should be queryable with cardano-cli, as long as your node is synced. At this point, if you can't see the UTxO in your wallet using the cardano-cli after a few minutes, then it means there is a problem with your node.
If there is a problem with your node, then make sure you are using the correct version. The testnet currently requires cardano-node v1.30.1
You can check which version you are running by typing cardano-node --version from the bash shell.

Just in case, are you querying the right testnet?

testnet explorer https://explorer.cardano-testnet.iohkdev.io/
alonzo purple explorer: https://explorer.alonzo-purple.dev.cardano.org/en.html

If you are following alonzo-testnet program, maybe you are not querying the right testnet.


text:
Send-tip to pooltool.io
I am trying to send tip info to pooltool.io.
I have already created an account on pooltool.io site and transferred the 1.056 Ada from my stake pool's wallet and I have access to the "manage" tab for my pool.  I have the apiKey and poolId.
When I submit the json data to pooltool.io I get an error response.
This is my bash command used to send the tip information:
RESPONSE="$(curl -s -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "$JSON" 'https://api.pooltool.io/v0/sendstats')"

This is the contents of the $JSON variable:
{
  "apiKey": "xxxxxxxx-modified for privacy-xxxxxxxx",
  "poolId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "data": {
    "nodeId": "",
    "version": "1.30.1:0fb43",
    "at": "2021-10-21T14:20:38.46Z",
    "blockNo": "6399612",
    "slotNo": "43259747",
    "blockHash": "641da85f02d37759fa6bb7e2e9691c2a06728baa2441706c997bc894d276420e",
    "platform": "send-tip"
  }
}

And here is the $RESPONSE value returned:
{"success":false,"dev":true,"message":"Unknown API ID"}

I can't see what the problem is.  Any ideas?
Has there been any change to the web address to send to?

By the way, I do have the correct values for poolId and apiKey.

I can not see anything wrong there. I'd suggest you open an issue on Github and see what they say: https://github.com/papacarp/pooltool.io/issues

It seems that the problem has now resolved itself.  Maybe pooltool.io changed something to activate my apiKey???.  With the exact same code, I am now getting $RESPONSE:
{"success":true,"dev":true,"message":null}

great! thanks for the info.

there was a problem on PoolTool recently and some keys had to be reactivated manually by the operators. I'm sure they probably sorted out yours as well!


text:
Testnet Node Error - [cardano-:cardano.node.DnsSubscription:Error:211493]
Currently running a test node and when it gets synced this error happens. So far I deleted the db/ folder and ran cardano-node again. Everything was going well but when it syncs this happened again. Node was running fine and observability looks good. Has anyone run into this issue? Any help would be appreciated.
Cardano CLI Version: 1.29.0
Node Specs:
OS: Debian
Disk-Size: 50GB (Utilization under 50%)
CPU: 4vCPUs (At peak was at 63% Utilization)
Memory: 16GB (under 10%)

You need to update your node(s) to version 1.30.1. I am pretty sure doing so will resolve your issue.
https://github.com/input-output-hk/cardano-node/releases

Ended up having to upgrade to 1.31.0-rc1. Sucks for anyone who didn't build from src and instead just downloaded the binary from IOHK. Fortunately I had built from source so it wasn't a big deal. Do you know where we go to see the release cadence? So we can update nodes preemptively?

So a couple of ways to stay up to date with this. IOG has a discord channel with an SP announcements channel : link Then they also will make updates on the cardano_updates twitter: link


text:
How to list all wallet UTxOs with cardano-cli?
How to list all wallet's UTxOs with cardano-cli utility? Not only address UTxOs via:
cardano-cli query utxo --address <ADDRESS> --mainnet

Wallet does not contain UTxOs, only addresses do. Therefore, you first need to derive all your addresses for your wallet and then check it one by one using the command in question.


text:
Error When Running stack ghci on my MacOS Terminal
I am getting this error when I try to run stack ghci on my Mac Termina. How do I resolve this? I've run stack upgrade and stack update.
Downloading lts-18.13 build plan ...RedownloadFailed Request {
  host                 = "raw.githubusercontent.com"
  port                 = 443
  secure               = True
  requestHeaders       = []
  path                 = "/fpco/lts-haskell/master//lts-18.13.yaml"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}

Is your Mac an M1 Chipset? If so, I think there is a chance that is the issue. If it is an M1, you could run it under Rosetta and that should work.

My Mac has Intel and not M1 Chip.


text:
What is the relation of "ptr" with UTXO?
I am working on an app, I am using Nami wallet and cardano-serialization-lib.
When I query UTxO and decode it using cardano-serialization-lib, I get an object with only attribute is something called "ptr", ptr is a number I was expecting an actual UTxO... I want to know how can I get the UTXO because I want it for using it inside a policy script.
Edit:
Extended explanation: I run the following comands in my browser:
window.cardano.enable();
window.cardano.getUtxos();

I get this :
Promise {<pending>}[[Prototype]]: Promise[[PromiseState]]: "fulfilled"[[PromiseResult]]: Array(1)0: "82825820eef507b798abbb8a1360efbd113f51eda22e2fbaae3cc32c78724c8644c164a40082583900756e62ff9667b187209b6fe1b577061491cf6f93a81e1f91741e2e3accb864ae67087f69bbd9ab74f71781d13ae40aab86e1de30ca7e21171a1dcd6500"length: 1[[Prototype]]: Array(0)

when i decode it using the library in NodeJS with the following script:
const S = require("./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js");
const _Buffer = require("buffer/").Buffer;
const rawUtxo =
  "82825820eef507b798abbb8a1360efbd113f51eda22e2fbaae3cc32c78724c8644c164a40082583900756e62ff9667b187209b6fe1b577061491cf6f93a81e1f91741e2e3accb864ae67087f69bbd9ab74f71781d13ae40aab86e1de30ca7e21171a1dcd6500";

const utxos = S.TransactionUnspentOutput.from_bytes(
  _Buffer.from(rawUtxo, "hex")
);

console.log(utxos);

I get this:
TransactionUnspentOutput { ptr: 1179656 },

It looks like you are looking at a pointer address. But you really need to expand your question as it is not clear.

Yes as far as i underestand ptr is some kind of pointer, I edited explaing more details as you suggested. Thank you!

I'm use cardano-serialization-lib.
How to get key hash ?
Thank.

The serialization lib is written in Rust and compiled to web assembly. Rust manually manages its memory, and I'm assuming that you need to do the same here. If you look at the typescript types you can see that every object has a free() method.
The ptr is a pointer to memory. If you need to access information of the UTXO you need to use the provided functions. So for example, this will construct the TransactionOutput from the CBOR hex string
const fromHexString = hexString =>
  new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));

const utxos = await cardano
        .getUtxos()
        .then(cborUTXOS =>
                cborUTXOS.map(cborUTXO =>
                        CardanoWasm.TransactionUnspentOutput.from_bytes(fromHexString(cborUTXO))
                    )
             )

And you can see how many lovelaces an output has like this:
utxos[0].output().amount().coin().to_str()

As far as i underestand you are telling me to do the same i did using a map function and a hex decoder explicit ... in fact i got the same ptr than before.

when i do .coin() i get coin is not a function...  where can i read about ehis objets? .output() for example?

The cardano serialization lib exposes some typescript definitions, so you can see what methods are available for each object. If you install the library with npm you can see the .d.ts type definition in node_modules

@AliciaBasilio hello were you able to find an easy way to look at the content inside these pointer objects? I noticed not all types have these methods to look at


text:
Yoroi mobile app isn't showing Add wallet (Shelley era)
I have a question regarding Yoroi mobile. My friend has been using Yoroi Mobile from official source since May 2021. Today, she opened her wallet and did not see "Shelley Era" next to the word "Add wallet" (see attached image).
She double-checked the updated version and made sure she has been using the latest one. After she restored the old wallet on that Yoroi Mobile by entering 24 recovery phrases, it didn't show the wallet name.
So is there anything abnormal?
Does anyone know what's going on with Yoroi Mobile?
Thanks!

You're right, the new update from Emurgo has slightly changed Yoroi app's UI. However, regarding wallet recovery, I wanna say the following: the wallet's name is always stored in the wallet itself and not recovered when you enter a mnemonic phrase. So in this sense, everything is OK. In Yoroi, you can give a new (or the same) name to your old wallet.

Thanks so much for your help


text:
How to get list of wallets generated by PAB
I'd like to know what endpoint to call to get the list of wallets generated by PAB during initialization (after calling cabal run myapp and seen after ending PAB - by pressing enter)

As I know, there is no such endpoint call.
What you can get is all contract instances:

By wallet: /api/contract/instances/wallet/<wallet-id>
Or general: /api/contract/instances

Check here all PAB endpoints:
PAB API endpoints


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

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

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

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

Regarding tools, well there are in random order:

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

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

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


text:
Does cardano-graphql limit the amount of data processed per single query?
I'm working on an application which for some of its features has to calculate the total balance of a wallet for a given time range. Here's a query that I've written (I don't have access to the original code at the moment, the following snippet was copied and adjusted from this example, which I also used originally, so it might contain some mistakes if you actually try to run it):
query getBalanceBetweenBlocks($address: String!, $min: Int!, $max: Int!) {
  blocks(where: {number: {_gte: $min, _lte: $max}}) {
    transactions(where: {_or: [
      {inputs:  {address: {_eq: $address}}}
      {outputs: {address: {_eq: $address}}}
    ]}) {
      inputs_aggregate(where:  {address: {_eq: $address}}) {aggregate {sum {value}}}
      outputs_aggregate(where: {address: {_eq: $address}}) {aggregate {sum {value}}}
    }
  }
}

It works correctly, but only if the [$min; $max] range is fairly small, for example $max = $min + 2000. If I try to increase it to, say, $maxblock = $minblock + 5000 the aggregated result is wrong, and I believe it's happening because the [$min; $max] range is actually cut off at some point artificially limiting how much data can be processed per single GraphQL query.
Also, I've tried writing the same query in SQL to interact with cardano-db-sync, and it does work correctly. Unfortunately, I cannot use cardano-db-sync directly which is why I'm using cardano-graphql in the first place.
Does anybody know if that's a problem with cardano-graphql or maybe some other thing on top of it (GraphQL, Hasura etc.), and if there's a way to deal with this problem? While it does perform fairly well, I'd like to see whether aggregating all the inputs/outputs at once is more efficient than doing so in batches (which would also let me simplify the application code in the process).

cardano-graphql has, according to their wiki, a query result limit of 2,500 items and depth limit 3.

Thanks for the info. For some reason, this isn't mentioned on the "main page" of the github repo, and I didn't search any folders for further information.


text:
Is there a way for a validator to get the current time?
Is it possible for a validator to get the current time without it being passed in via the redeemer? My validator is heavily dependent on the time being correct so it would probably be a bad design choice to allow the wallet to pass in the time, as it can lie about the current time.

The usual way to handle time in Plutus is using Slot ranges. This means that the script does not query the time. Instead it checks that the validation happens in a given slot interval that corresponds to a time.
You can have a look at the notes about slots from the Plutus Pioneers Course.
With these slots, you can ensure that the validation takes place before, after or in a certain slot interval. And when you are sure that the validation takes place in a specific time interval, you also know the corresponding time. Each slot corresponds to one second as described here.

Perfect. Your response captures everything I questioning!

How about parameterizing the validator with Slot or POSIXTime and passing the current time from the contract to the validator script using Contract.currentTime or Contract.currentSlot?
That way, the wallet has no influence on it.

I could do this, but the issue is that the contract I am creating has quite a lot of different deadlines floating around. So asking for all of these up front would be annoying for someone using it and could allow for more mistakes/vulnerabilities.


text:
How to validate the correctness of another parameterized script address on-chain
I would like to write a factory script that can initialize another parameterized script address by sending it an NFT. The factory validator gets the parameters of the target script as redeemer and has to check if the NFT is actually sent to correct script address.
Testing this with EmulatorTrace gives me an error that lets me doubt if calculating/validating a parameterized address is possible on-chain.
Writing it in Plutus looks like this:
{-# INLINABLE validateCreate #-}
validateCreate :: Factory
               -> [TargetParams] -- Datum: List of already created scripts
               -> TargetParams   -- Redeemer: parameters for new script to be created
               -> ScriptContext
               -> Bool
validateCreate factory existingScriptParams newScritpParam ctx =
    someOtherValidationLogic &&
    Constraints.checkTxConstraint ctx
      (MustPayToOtherScript (Scripts.validatorHash $ targetInst newScritpParam)
        calculateDatumLogic nftValue)
  where
    someOtherValidationLogic :: Bool
    calculateDatumLogic :: TargetDatum
    nftValue :: Value

With the targetInst function looking pretty standard:
{-# INLINABLE targetInst #-}
targetInst :: TargetParams -> Scripts.TypedValidator Target
targetInst p = Scripts.mkTypedValidator @Target
    ($$(PlutusTx.compile [|| mkTargetValidator ||])
    `PlutusTx.applyCode` PlutusTx.liftCode p)
    $$(PlutusTx.compile [|| wrap ||])
  where
    wrap = Scripts.wrapValidator @Integer @TargetAction

This loads in cabal repl without problems. But when executing the EmulatorTrace, it yields the following error:
*** Exception: Error: Unsupported feature: Type constructor: GHC.Prim.ByteArray#
Context: Compiling definition of: Target.targetInst
Context: Compiling definition of: Factory.validateCreate
Context: Compiling definition of: Factory.mkFactoryValidator
Context: Compiling expr at "ProjectName-0.1.0.0-inplace:Offchain:(84,9)-(84,52)"

I do not know what is going on in the template Haskell of targetInst. It looks to me like the calculation of a script address with the parameters given in the redeemer is not possible in the on-chain validator.
This raises a couple of questions for me:

Is it just a stupid mistake on my side?
Is there another way to calculate or validate script addresses with parameters given at runtime?
Would another architecture be better for what I am trying to accomplish? My goal is to separate different instances of my target script while ensuring that there is only one for each set of parameters.

I think this question is related to this one. But there were no helpful answers and I would like to give a more detailed description.
Thanks for your help.

You are asking a couple different questions here.

This loads in cabal repl without problems. But when executing the EmulatorTrace, it yields the following error:

*** Exception: Error: Unsupported feature: Type constructor: GHC.Prim.ByteArray#

Does your Target script include ByteArray? I believe this is saying it's not INLINABLE, and thus can't be compiled into Plutus. GHC wouldn't see any issues with it, that's why cabal repl doesn't complain.

Would another architecture be better for what I am trying to accomplish? My goal is to separate different instances of my target script while ensuring that there is only one for each set of parameters.

Generally the way these sort of access NFT validators would be written is the NFT isn't sent to some target address, but rather must be included in the txn (and returned to the validator in the same txn with a new datum). The target script can then just check that it's included in the txn.
You say you want "a factory script that can initialize another parameterized script". What is to stop you from sending any arbitrary token to "initialize" instead of your desired NFT. There are no constraints on Datum creation for a script (anyone can initialize a script) there are just constraints on who can spend the Datum UTxO with a Redeemer.
I'm not sure what behavior you want from your Target scripts, but as a rule of thumb I'd recommend:

Add constraints to the Factory script to ensure the NFT is returned to itself with a new Datum rather than sent to some param address
Use the params to ensure the rest of the txn is valid to spend some Datum at the Target address
Then have Target just check that the NFT is included in the txn--if the NFT is spent, then that means Targets requirements are met


text:
How to verify a user owns an NFT?
Let's say I have the asset string representing an NFT. How can I verify that a user signed in with Nami wallet owns that NFT? Is there some sort of signature they can provide?

This depends a bit on your use case.
If you just want to look it up on the blockchain: You can query the node with cardano-cli query utxo --mainnet --address <address-to-check>. This gives you all UTXOs at the address and the value and NFTs contained in it.
If you want a smart contract to validate that the user has the NFT: The UTXO with the NFT would need to be part of the transaction and then sent back to the owner. Then some validator can check the context of the transaction if the NFT is included.

The blockchain stores the proof that a particular NFT belongs to a wallet. Whoever controls the wallet own the NFT. Wallet control is determined by access to its private key(signing key). If someone presents a text or number signed by wallet private key then he proves that he controls that wallet.
This is how websites are being connected to wallets.

Thank you! This makes sense to me.


text:
Is there a "Moore's law" type function, that has been fitted to the Cardano blockchain size as a function of time?
In technology, when something is growing quickly and monotonically over time, we often fit the data over time to a curve and make claims like "the doubling time of the number of transistors in a computer is about 2 years", the most famous case probably being Moore's law, in which graphs like these are constantly being updated:

In quantum computing we have Rose's law, which talks about the doubling of the number of qubits in the D-Wave quantum annealers:

When drafting my answer to this question: Why Is Daedalus Mainnet taking so long to Sync My Transaction History with the Blockchain?, I found a related question on the Cardano Stack Exchange: How big is the Cardano blockchain (now and in the future)?, and it seems that this question is asked over and over and over again, at least on Reddit:

I was quite intrigued, that at the time of the Stack Exchange question in May 2021, the answer was only 8.5GB, and now in October 2021 it's about 16GB. Therefore, since people have asked the same question on Reddit so many times, I'm sure I could plot the Cardano blockchain size over time myself, but I wonder if anyone's been doing it at somewhat regular intervals, or if there's even been a "curve of best fit" done for such data?

Really interesting question, I guess it remains open until some brave techie brain dives into data mining. We have Cardano data queryable through BigQuery now so... https://iohk.io/en/blog/posts/2022/07/01/cardano-data-on-bigquery/


text:
How to search for an NFT asset name?
Let's say, I have created an asset with name 'xyz' and I want to search for all the nfts with this asset name on the chain. How and where do I do that ?

May I ask why you'd want to do this?
It will be much easier for you to store the name of your NFT's in a database somewhere and query that instead of the blockchain. The blockchain is very quick at looking up NFT's under a given policy_id or asset string. Custom metadata? Not so much.


text:
2 stake pools using the same ticker name
we registered our pool on 2021-02-16 at 03:24:16. But unfortunately we noticed after our pool registration, that there was a second pool which has been registered with the same ticker 13 minutes later. It results in some confusion when users try to search for us in Daedalus or Yoroi to delegate their stakes.
I’ve read that when it comes to tickers attribution, we are going with a “a first take, first serve…” basic rule so obviously we are the most legitimate to use this ticker as we registered first, aren’t we ? I followed the recommendation by sending an e-mail to adapools at cardanians.io 1 to explain the situation but I would also be glad to have your recommendations.

The 'a first take, first serve' rule you mentioned is for the ITN (Incentivized Test Net) only.
Once registered, your Stakepool metadata including your ticker is inserted and stored in the SMASH (Stakepool Metadata Aggregation Server), an off-chain metadata server maintained by IOHK used by default by Daedalus wallet or Yoroi wallet to load stake pool names and details.
So when ADA hodlers are looking for a pool to delegate their stakes by typing a name in the Daedalus or Yoroi search bar, it is in the SMASH database that they are looking at. Sending an email to adapools won't solve your problem.
There are a few exceptions where IOHK will be able to remove a ticker from SMASH (not the network). In short, if both of you don't meet these few exceptions, there's a good chance you will be sharing that same ticker unless one of the two pools changes it.

So let me ask a follow up question, if there are no rules to using the same ticker, what prevents people from piggybacking off of someone else's marketing work by using the same ticker? Seems like someone could easily copy logos and cause a lot of confusion to newcomers who wouldn't know how to check which one was legitimate. (Or I guess original might be a better word). Thanks!

Yes I had the same question.

Hello@Anton, the case you are referring to is one of those exceptions for IOHK to remove the pool from SMASH. it is called impersonation: stake pools that attempt to impersonate other individuals, groups, or organizations in a manner that misleads, confuses, or deceives others. For example, a successful stake pool called POOL being obviously impersonated by another called P00L (by linking to the same website).
Now in the case of the original question, it seems it was pure coincidence. You can have a look at this link docs.cardano.org/getting-started/operating-a-stake-pool/SMASH –


text:
How to publish a smart contract on the blockchain?
Let's say I have a Plutus contract written up. How do I actually submit it to the blockchain and start interacting with it?

The plutus contract that you have written is in template haskell. Now to convert this to something that can be used on chain one needs to compiled it to plutus core.
From an educational point of view I'll explain how this is done with a concrete example. Take for example the lobster smart contract's used in naming the lobster [1]. Note that this project folder structure contains at least the following 3 files,

A .cabal file in ./
A main.hs residing in ./app/
A smart contract residing in ./src/Cardano/PlutusLobster/

Now what are those files? The .cabal file is a configuration file that tells the compiler how to build the general haskell program at hand. If you look in it you will see all the dependencies listed for building something to plutus core. Also in the end of this file there are three executable defines, that of the 3 yet to build contracts. Now in this file is also a reference to the smart contact in the ./src/... path. Lastly the .cabal file also references the main.hs files for each of those 3 to build contract. If we look into that main.hs file it is some general format that tells the compiler exactly how to compile the plutus script to plutus core (and the serialization of that).
So now you can test it out! Git clone this repo and type cabal run all to build all 3 contracts or cabal run "a name of a executable" as defined at the end of the .cabal file. This will result in 3 contracts in the /scripts/ directory. Note that building this has to be done with ghc version 8.10.4.
Hopes this helps.

Makes sense! Appreciate the detailed response. I totally missed the lobster challenge when it came out, I'll give it a go right now.

As Fermat said, you can follow the lobster example.
Another option is the Exercise 4 of Alonzo-testnet.
Exercise 4 - Solution
There you can find:

Compile hs file
Build script address
Build transactions to interact with the validator script
Sign transactions
Submit transactions

Got it, thank you very much!


text:
Does Plutus support floating-point arithmetic for on-chain code?
Plutus provides arithmetic functions for Integers through the modules PlutusTx.Prelude and PlutusTx.Builtins. Are there floating-point arithmetic functions which can be used on chain? If not, why is it so?

My opinion would be that:
Floating point operations are typically resource-consuming and expensive to compute.
I mean, even 1 ADA had to be made a million Lovelace in order for the possibility to have fractional amount of ADA.
I'd suggest you follow the same approach

Let the onchain code deal with Integer and carry-out floating point operations off-chain.

I used before this for operate with some divisions between Integers and then to truncate to closes integer again.
https://playground.plutus.iohkdev.io/doc/haddock/plutus-tx/html/PlutusTx-Ratio.html#t:Rational
Like this:
number1 = 10
number2 = 3
result = TxRatio.truncate ( TxRatio.unsafeRatio number1 number2)

I think its just too expensive to operate with them on chain, ill not recommend, but you can if you need it.

Floats are well known to be the wrong datatype for encoding anything resembling money, fixed points should be used for such purposes.
Encoding them by Integer (with some hardcoded number of fractional decimals) is prone to errors by mistake, so you better wrap it into custom newtype. That is actually what Plutus Lovelace datatype does.
I am not aware of implementation for full-featured Decimal datatype in Plutus, but they are usually can be avoided in smart-contract logic.


text:
How to get the final balances using the PAB+ the simulator?
I'm using the GuessGame:
https://github.com/input-output-hk/plutus/blob/a36af17fd38db591865679916c819079ad51fda2/plutus-playground-server/usecases/Game.hs
under the simulator, with this code
main = Simulator.runSimulationWith handlers $ do

     cid <- Simulator.activateContract (Wallet 1) GuessGame

     waitNSlots 3
     callEndpointOnInstance cid "lock" LockParams{secretWord="world", amount= Ada.adaValueOf 200}

     waitNSlots 3
     callEndpointOnInstance cid "guess" GuessParams{guessWord="world"}

  where
  handlers :: SimulatorEffectHandlers (Builtin TestContracts)
  handlers =
    Simulator.mkSimulatorHandlers def def
    $ interpret (contractHandler (Builtin.handleBuiltin @TestContracts))

The traces included in the GuessGame code, indicates that the transaction has been done, but how I can display the final balances of the the simulated accounts?

Does this answer your question? How to get list of wallets generated by PAB

You need to include these lines at the end:
Simulator.logString @(Builtin TestContracts) "Balances at the end of the simulation"
b <- Simulator.currentBalances
Simulator.logBalances @(Builtin TestContracts) b

Thanks a lot. It works!

@agocorona Glad to help!


text:
How to solve "cabal: Could not resolve dependencies" when building cardano-cli cardano-node
I'm a newbie to Cardano. I'm trying to set up a stake pool as this link explained.
https://www.coincashew.com/coins/overview-ada/guide-how-to-build-a-haskell-stakepool-node
I stuck with cabal build cardano-cli cardano-node step with the following error.
Warning: Requested index-state 2021-04-30T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2021-04-29T23:07:55Z).
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: Win32-network-0.1.0.0 (user goal)
[__1] trying: base-4.14.1.0/installed-4.14.1.0 (dependency of Win32-network)
[__2] trying: lobemo-scribe-systemd-0.1.0.0 (user goal)
[__3] next goal: libsystemd-journal (dependency of lobemo-scribe-systemd)
[__3] rejecting: libsystemd-journal-1.4.5 (conflict: pkg-config package
libsystemd>=209, not found in the pkg-config database)
[__3] rejecting: libsystemd-journal-1.4.4 (conflict:
base==4.14.1.0/installed-4.14.1.0, libsystemd-journal => base>=4.6 && <4.13)
[__3] skipping: libsystemd-journal-1.4.3, libsystemd-journal-1.4.2,
libsystemd-journal-1.4.1, libsystemd-journal-1.4.0, libsystemd-journal-1.3.4,
libsystemd-journal-1.3.3, libsystemd-journal-1.3.1, libsystemd-journal-1.3.0,
libsystemd-journal-1.2.0, libsystemd-journal-1.1.0, libsystemd-journal-1.0.0
(has the same characteristics that caused the previous version to fail:
excludes 'base' version 4.14.1.0)
[__3] fail (backjumping, conflict set: base, libsystemd-journal,
lobemo-scribe-systemd)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, libsystemd-journal,
lobemo-scribe-systemd, Win32-network
Try running with --minimize-conflict-set to improve the error message.

Anyone can enlighten me to solve this, please?

Are you running the command in nix-shell?
If not, I'd suggest you clone the Plutus project, run nix-shell from within the Plutus repository.
Afterwards, try building the libs again

Oh, I also newbie for nix-shell. I gonna try, thank you.

@Aoaddeola I do not think he's trying to set up the Plutus environment.

@Kelli Ahh, yes, I just trying to set up a stake pool.

It looks like the issue is with Cabal and its dependencies versions, specifically the packages (base, libsystemd-journal,lobemo-scribe-systemd and Win32-network).
I think this link will help:
https://forum.cardano.org/t/error-message-trying-the-comand-cabal-build-installing-my-cardano-node/41605/8
Other similar issues:
https://stackoverflow.com/questions/68558825/could-not-resolve-dependencies-while-installing-libraries-with-cabal
https://stackoverflow.com/questions/67154347/how-can-i-fix-haskell-version-conflicts-with-dependencies


text:
Are there any APIs for Cardano NFT ticker?
I am very new to Cardano NFT. I am trying to find an API to get the Cardano NFT live ticker.
Please help me.

Hi @Surabhiv, could you elaborate a bit more on what you mean exactly? I am not sure what you mean by "NFT live ticker". I think it might be better to explain what you want to achieve.

Hi, @LACEpool thank you for your reply. Actually we need API to get Cardano's current price, current Marketcap, Volume, Supply,7 days price for graphical representation.

Actually we need API to get Cardano's current price, current Marketcap, Volume, Supply,7 days price for graphical representation.

this kind of information is not directly related to Cardano in the sense that it is not on-chain data. I'd suggest you check out different providers and choose what fits you best. I haven't used any of the following, but a quick search in Google resulted in the following list:

https://coinmarketcap.com/api/documentation/v1/#section/Endpoint-Overview
https://www.coingecko.com/en/api
https://www.coinapi.io/
https://docs.coincap.io/
https://polygon.io/crypto

This is just an excerpt of my search for "crypto market api" and "blockchain market api" and you can find many other providers.


text:
How to get Policy Script for a specific policy-ID
how can i get the script information for a given policyID. I am mostly interested in the "invalidAfter" Slot number.
So far i could not find any option for example by using Blockfrost API.
Background: i minted a token and appropriate policy on testnet. Never published the policy-Script. The cardanoscan is able to show it to me, question how does it work?
https://testnet.cardanoscan.io/tokenPolicy/c958da9d1ba00cbd58019a45cb1481e2ef3be4406c1d80cb3fdacf3d
Thank you and Greetings
Andro

When minting a token in Cardano, we sign (witness) the transaction with the input credentials for consuming the input, and ALSO it is required to provide the minting native script (token policy) as a witness to the transaction.
We read the witnesses from the transactions on the chain and parse the script for the tokens. Unfortunately, currently, there is no easy way that you can follow to get this information.

Thank you very much for that explanation

As stated in other answers the minting policy script is used as a witness in the minting transaction and thus available on chain. Community members made tools for extracting such data. Here is a great forum post about the same question and links to different sources where you can find such scripts!
The post
All scripts onchain (credits to Brain W Bush)
You can parse the scripts in the above link by transaction hash.

Thank you very much for directing me to already discussed thread in other forum. Very much appreciated!

You can't get that information, unless the creator publish it because the policy id is the hash of the policy script.
For example, here: Spacebudz policy and here Spacebudz FAQ - Is this actually an NFT
Creator already published it on pool pm, so you can find all details there.

Thank you, i got it. Remains the question how does cardanoscan gets the script information e.g here:
https://cardanoscan.io/tokenPolicy/c6c7aa8eb132557fa0307217cd207f60b90f16032441ce74b7acebc7
also i minted a token to test-net, never published my policy script but cardanoscan is able to show it:
https://testnet.cardanoscan.io/token/c958da9d1ba00cbd58019a45cb1481e2ef3be4406c1d80cb3fdacf3d486f646c657230327833?address=addr_test1qzgv3rszerajmlcp9ga60khrwf4wsrf969mrzkn5jhvprasp7k0q7cdp9ffzdxxdk3ergfwepxvw26635h20kk9w0wns2jfdgf

You're right. Can you please update your question to add these details regarding to cardanoscan. Thanks.


text:
Should I use Marlowe or Plutus to create my native token?
Should I use Marlowe or Plutus to create my token?
I also want to create a TCG in which my token will have an utility.
Where should i start? (tutorial, how-to, examples ...).

Both, Plutus and Marlowe are smart contract languages. Plutus is a library built on top of Haskell, while Marlowe is based on Plutus. Marlowe should be used by business engineers or financial experts rather than developers. Marlowe is like a financial constructor with a browser-based Contract Editor and simulator. The answer is obvious – for trading card game (TCG) development use Plutus.
Non-fungible token (NFT) in Cardano, however, doesn't require to create smart contact. It's minted as its native asset.


text:
Block missed despite no problem on servers
My pool missed a block but looking at the server logs everything was fine at this moment.
Here are the Cardano logs :
{"thread":"1734","loc":null,"data" {"kind":"TraceStartLeadershipCheck","chainDensity":4.882958e-2,"slot":40969729,"delegMapSize":861059,"utxoSize":3467585,"credentials":"Cardano"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.LeadershipCheck"],"at":"2021-09-25T02:13:40.00Z"}
{"thread":"1734","loc":null,"data":{"val": {"kind":"TraceNodeNotLeader","slot":40969729},"credentials":"Cardano"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.Forge"],"at":"2021-09-25T02:13:40.00Z"}
{"thread":"1734","loc":null,"data":{"kind":"TraceStartLeadershipCheck","chainDensity":4.882958e-2,"slot":40969730,"delegMapSize":861059,"utxoSize":3467585,"credentials":"Cardano"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.LeadershipCheck"],"at":"2021-09-25T02:13:41.00Z"}
{"thread":"1734","loc":null,"data":{"val":{"kind":"TraceNodeIsLeader","slot":40969730},"credentials":"Cardano"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.Forge"],"at":"2021-09-25T02:13:41.00Z"}
{"thread":"217610","loc":null,"data":{"kind":"ChainSyncClientEvent.TraceDownloadedHeader","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}},"slot":40969728,"block":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb","blockNo":6287888},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.ChainSyncClient"],"at":"2021-09-25T02:13:41.11Z"}
{"thread":"1736","loc":null,"data":{"peers":[{"length":"1","kind":"FetchDecision results","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}}}],"kind":"PeersFetch"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.BlockFetchDecision"],"at":"2021-09-25T02:13:41.14Z"}
{"thread":"1736","loc":null,"data":{"kind":"AddedFetchRequest","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}}},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.BlockFetchClient"],"at":"2021-09-25T02:13:41.14Z"}
{"thread":"217608","loc":null,"data":{"kind":"AcknowledgedFetchRequest","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}}},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.BlockFetchClient"],"at":"2021-09-25T02:13:41.16Z"}
{"thread":"217608","loc":null,"data":{"length":1,"kind":"SendFetchRequest","head":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}}},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.BlockFetchClient"],"at":"2021-09-25T02:13:41.16Z"}
{"thread":"217607","loc":null,"data":{"kind":"StartedFetchBatch","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}}},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.BlockFetchClient"],"at":"2021-09-25T02:13:41.22Z"}
{"thread":"1734","loc":null,"data":{"val":{"kind":"TraceForgedBlock","blockPrev":"78de58439fc25a623ca44b8b7945385a23a727dc81a562f8aea54b3fa8dce4e5","slot":40969730,"block":"e16eb1d6ff408c4ada4f9f2fbdf554f7821ccd8d6b4a302c93aab8c3be0b22ff","blockNo":6287888},"credentials":"Cardano"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.Forge"],"at":"2021-09-25T02:13:41.29Z"}
{"thread":"217607","loc":null,"data":{"kind":"CompletedBlockFetch","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}},"block":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.BlockFetchClient"],"at":"2021-09-25T02:13:41.32Z"}
{"thread":"217607","loc":null,"data":{"kind":"CompletedFetchBatch","peer":{"remote":{"addr":"10.45.129.61","port":"6000"},"local":{"addr":"100.64.5.177","port":"43899"}}},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.BlockFetchClient"],"at":"2021-09-25T02:13:41.32Z"}
{"thread":"1724","loc":null,"data":{"newtip":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb@40969728","chainLengthDelta":1,"kind":"TraceAddBlockEvent.AddedToCurrentChain"},"sev":"Notice","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.ChainDB"],"at":"2021-09-25T02:13:41.49Z"}
{"thread":"217591","loc":null,"data":{"kind":"ChainSyncServerEvent.TraceChainSyncServerReadBlocked.AddBlock","slot":40969728,"block":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb","blockNo":6287888},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.ChainSyncHeaderServer"],"at":"2021-09-25T02:13:41.49Z"}
{"thread":"217591","loc":null,"data":{"point":{"kind":"BlockPoint","headerHash":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb","slot":40969728},"kind":"ChainSyncServerEvent.TraceChainSyncRollForward"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.ChainSyncHeaderServer"],"at":"2021-09-25T02:13:41.49Z"}
{"thread":"1724","loc":null,"data":{"kind":"TraceAddBlockEvent.TrySwitchToAFork","block":{"kind":"Point","hash":"e16eb1d6ff408c4ada4f9f2fbdf554f7821ccd8d6b4a302c93aab8c3be0b22ff","slot":40969730}},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.ChainDB"],"at":"2021-09-25T02:13:41.49Z"}
{"thread":"1882","loc":null,"data":{"kind":"ChainSyncServerEvent.TraceChainSyncServerReadBlocked.AddBlock","slot":40969728,"block":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb","blockNo":6287888},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.ChainSyncHeaderServer"],"at":"2021-09-25T02:13:41.49Z"}
{"thread":"1882","loc":null,"data":{"point":{"kind":"BlockPoint","headerHash":"3e41596123fca52a1328fdf70c6986be9b57e9b3a5284d0232632aae4cf5affb","slot":40969728},"kind":"ChainSyncServerEvent.TraceChainSyncRollForward"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.ChainSyncHeaderServer"],"at":"2021-09-25T02:13:41.49Z"}
{"thread":"1734","loc":null,"data":{"val":{"kind":"TraceDidntAdoptBlock","slot":40969730},"credentials":"Cardano"},"sev":"Error","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.Forge"],"at":"2021-09-25T02:13:41.51Z"}
{"thread":"1732","loc":null,"data":{"txs":[{"txid":"txid: TxId {_unTxId = SafeHash \"b1733a284ed3d44aef1db34bbafee20f0882a2478bc3b694c67fcd7dacb7258d\"}"},{"txid":"txid: TxId {_unTxId = SafeHash \"f8c92325873b728b22655f91b9c330d1f8e69c7632d444e291c3955d50bc4f20\"}"},{"txid":"txid: TxId {_unTxId = SafeHash \"5600ecfce06658369f4ad4fa21c1f841b40a8e799116734e7bae81b4fd5c81e3\"}"},{"txid":"txid: TxId {_unTxId = SafeHash \"08cf32b2b8cb9b54f6894b784997a84a98db44783d60322d618f6b38be798e69\"}"},{"txid":"txid: TxId {_unTxId = SafeHash \"fafb77fe479b34041e38881639fd92a84d4910867ac9f10b792058214d1708e7\"}"}],"mempoolSize":{"numTxs":1,"bytes":1495},"kind":"TraceMempoolRemoveTxs"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.Mempool"],"at":"2021-09-25T02:13:41.79Z"}
{"thread":"1734","loc":null,"data":{"kind":"TraceStartLeadershipCheck","chainDensity":4.885721e-2,"slot":40969731,"delegMapSize":861059,"utxoSize":3467587,"credentials":"Cardano"},"sev":"Info","env":"1.29.0:4c594","msg":"","app":[],"host":"deploy-s","pid":"80","ns":["cardano.node.LeadershipCheck"],"at":"2021-09-25T02:13:42.00Z"}

I see that there is a "TraceAddBlockEvent.TrySwitchToAFork" event during my leader slot, is it the cause of my problem ? Can I do something to avoid that in the future ?

How do you see this skipping / missed? I see 40969729, 40969730, 40969731 is that the block serial? Seems legit. Maybe I don't know what slot is.

@Tomachi I have this in the logs {"kind":"TraceDidntAdoptBlock","slot":40969730}

Yes, if you forge a block in a slot but the node switches to a different fork before your block is propagated, your node with increment the metric tracking that it forged but didn't adopt it.

OK it sounds a bit like an "Uncle" block in Ethereum yes? AFAIK in Ethereum these get acknowledged in the next block but with lesser rewards, I guess it would make the chain harder to forge so makes sense. I wonder if Cardano uses these blocks? Or is the counter just for internal use to diagnose slow propagation issues maybe.


text:
checkMintedSymbol
What exactly this function is validating?
checkMintedSymbol :: Bool
checkMintedSymbol = case flattenValue (txInfoMint info) of
    [(cs', _, _)] -> cs' == ownCurrencySymbol ctx
    _             -> False

info :: TxInfo
info = scriptContextTxInfo ctx

ctx is a ScriptContext

At first glance, it appears to be some kind of redundancy. But I think it's used to ensure that the CurrencySymbol of the token (or Value) being minted is the same as the CurrencySymbol associated with the Validator/Minting Policy

It validates whether the minted value matches ownCurrencySymbol which in turn is a hash of the validator/minting policy.
The checkMintedSymbol function might be redundant as you cannot mint arbitrary currency without providing matching validator/minting policy.
Edit based on comments: it isn't redundant if there are multiple minting policies in the transaction and it ensures only one kind of currency is being minted.

It's not exactly redundant. It is saying you are only minting one kind (typically you can mint with other policies in the same tx, so in a way this is over-constrained), and it is also saying it doesn't care about the token name (as long as it's all the same) or the amount minted.

Oh, that makes sense now since the validator sees all the mints of the tx not only its "own".


text:
search for wallet address holding native tokens
One particular use case is as follows:

native token is issued and we would like to know the wallet addresses holding this native tokens.
And then use loyalty point based calculation to give rewards to the token holders as these tokens are both acting as governance and as value holding mechanism.

So the question is how would for a particular native token, minted on cardano create such a system. ALGO for example does this for their token. How can i query for a particular native token and get this information at any point in time ?

I would recommend db-sync, graphql or cardano-rosetta for this. The wallet is designed for tracking all addresses associated with one root key. From the perspective of someone wanting to give loyalty tokens to holders, all you care about is what addresses hold utxos containing your token. This has no bearing on if a holder has one address or multiple in a wallet holding the same native token.

If running db-sync is not a solution for you, try /api/v0/assets/{asset}/addresses endpoint at Blockfrost.io.


text:
Listing all cardano tokens using cardano db sync
I am currently starting out with cardano db sync and wanted to ask if it is possible to obtain all native and nft tokens and their metadata using cardano db sync? could someone guide me? I can't seem to find sufficient resources for beginner like me.

You can join the ma_tx_mint and ma_tx_out tables to utxo_view. This will only get you the policyid and asset name (hex encoded) for an asset though and you need to query the metadata server to get any other information about the tokens.


text:
Logging in validator
I'm working through the Plutus Pioneer program and I have a bug in my implementation of the validator for homework one. I'd like to add some logging to the validator to get more insight into what I'm doing wrong.
I've seen that the logInfo function is used in the wallet code and I've tried adding that to the validator like:
mkValidator dat _ ctx = do
    logInfo @P.String $ printf "deadline %s" (P.show $ deadline dat)
    False -- dummy value to figure out how to get logging to work

but when I do that I get the following error:
• Couldn't match expected type ‘Bool’
              with actual type ‘Contract w0 s0 e0 b0’
• In a stmt of a 'do' block:
    logInfo @P.String $ printf "deadline %s" (P.show $ deadline dat)
  In the expression:
    do logInfo @P.String $ printf "deadline %s" (P.show $ deadline dat)
       False
  In an equation for ‘mkValidator’:
      mkValidator dat _ ctx
        = do logInfo @P.String
               $ printf "deadline %s" (P.show $ deadline dat)
             False

Upon checking the type of logInfo I see that it has the type logInfo :: forall a w (s :: Row *) e. ToJSON a => a -> Contract w s e () which seems to match up with the error that's given.
How come I can't use this logging function if I'm later returning False? I suspect I'm misunderstanding something fairly basic about how haskell works.

I'll use this answer to log my journey as I try things out.
Tentative Solution/Answer
Looks like P.show can't be used in a validator based on https://discord.com/channels/826816523368005654/826829805387120690/892870961353879592
I'll wait for more confirmation before accepting this. I hope that's not the case.
Attempt 1
I've also tried using trace with
mkValidator dat _ ctx = do
    trace $ printf "deadline %s" (P.show $ deadline dat)
    False
but that also results in an error:

• Couldn't match expected type ‘Bool’ with actual type ‘a0 -> b0’
• In a stmt of a 'do' block:
    trace $ printf "deadline %s" (P.show $ deadline dat)
  In the expression:
    do trace $ printf "deadline %s" (P.show $ deadline dat)
       False
  In an equation for ‘mkValidator’:
      mkValidator dat _ ctx
        = do trace $ printf "deadline %s" (P.show $ deadline dat)
             False

Attempt 2
Looks like using do in a validator is a fools errand. Now I'm trying to add debug info to the trace message.
mkValidator :: VestingDatum -> () -> ScriptContext -> Bool
mkValidator dat _ ctx  = traceIfFalse (P.show $ deadline dat) False

but it turns out that P.show doesn't return the correct type (it returns [P.Char] when a BuiltinString is required). Trying to coerce [P.Char] to a BuiltinString using stringToBuiltinString from https://playground.plutus.iohkdev.io/doc/haddock/plutus-tx/html/PlutusTx-Builtins-Class.html#v:stringToBuiltinString results in a very large error that looks like linker problems:

GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable GHC.CString.unpackAppendCString# No unfolding Context: Compiling expr: GHC.CString.unpackAppendCString# Context: Compiling expr: GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime4 Context: Compiling expr: GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime4 (GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime3 (case GHC.Show.$w$cshowsPrec4 0# (x `cast` (Plutus.V1.Ledger.Time.N:POSIXTime[0] :: GHC.Types.Coercible Plutus.V1.Ledger.Time.POSIXTime GHC.Integer.Type.Integer)) Plutus.V1.Ledger.Time.$fShowPOSIXTime5 of { (# ww3 [Occ=Once], ww4 [Occ=Once] #) -> GHC.Types.: @ GHC.Types.Char ww3 ww4 })) Context: Compiling expr: \ (x [Occ=Once] :: Plutus.V1.Ledger.Time.POSIXTime) -> GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime4 (GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime3 (case GHC.Show.$w$cshowsPrec4 0# (x `cast` (Plutus.V1.Ledger.Time.N:POSIXTime[0] :: GHC.Types.Coercible Plutus.V1.Ledger.Time.POSIXTime GHC.Integer.Type.Integer)) Plutus.V1.Ledger.Time.$fShowPOSIXTime5 of { (# ww3 [Occ=Once], ww4 [Occ=Once] #) -> GHC.Types.: @ GHC.Types.Char ww3 ww4 })) Context: Compiling definition of: Plutus.V1.Ledger.Time.$fShowPOSIXTime_$cshow Context: Compiling expr: Plutus.V1.Ledger.Time.$fShowPOSIXTime_$cshow Context: Compiling expr: Plutus.V1.Ledger.Time.$fShowPOSIXTime_$cshow (case dat of { Main.VestingDatum _ [Occ=Dead] _ [Occ=Dead] ds_dLa0 [Occ=Once] -> ds_dLa0 }) Context: Compiling expr:

P.show will always fail inside a validator, because you can't use functions defined in Haskell Prelude, you need to use instead PlutusTx.Prelude

Does PlutusTx.Prelude include a show function? I couldn't find one but maybe I wasn't looking in the right place.

There isn't, since show transforms anything into a String and PlutusTx.Prelude only works with BuiltinString or BuiltinByteString

Same here. Get this error every time I there is a variable in the validator.

You're running into trouble because logInfo is meant to be used inside the Contract monad. The Wallet code uses the Contract monad but the validator code doesn't.
If you're not familiar with how monads and do blocks work, I'd check out Lecture #4
As for logging inside of validators, I'd look at using trace, traceIfTrue, or traceIfFalse. I've only used traceIfFalse though. Remember, validators are compiled into Plutus and run on the chain, so they aren't going to log like normal code. Whereas the wallet code is run natively on your machine.
Hope that helps.

Is it possible to use that combined with an arbitrary variable? For example, if I want to dynamically display the number of tokens that are missing for the script to validate.

Thanks for the great answer! I stumbled on that myself but it's good to know what I found myself is accurate. @Mateus I don't think you can log arbitrary variables within trace or it's derivatives because the Plutus Prelude doesn't offer a show function.

Validators are compiled into Plutus Core language which is human-unreadable. It's not possible to compile something that will be only available at run-time because it's literally not there to be compiled. You can log variables that are available at compiler.

GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function

This error means that you are trying to compile something that will be available at run-time.


text:
Question about Datum and DatumHash
I have a question about findDatum which is used in some of example contracts in Plutus Pioneer Program. According to those lectures, this method is used to get Datum from its DatumHash. I wonder if it is true that at anytime we can always get Datum from its corresponding DatumHash? For example, in the Lobster challenge, are we able to reveal ourselves the Datum from the given DatumHash? Please help me clarify this.

I wonder if it is true that at anytime we can always get Datum from
its corresponding DatumHash?

No, the transaction info TxInfo has an argument called txInfoData, defined as txInfoData :: [(DatumHash, Datum)]. Not necessarily your DatumHash will be inside this list, but what findDatum does, is to try to lookup the given datum hash, and if it's there, return the corresponding Datum.

For example, in the Lobster challenge, are we able to reveal ourselves
the Datum from the given DatumHash?

Yes, because the Lobster Chalange's txInfoData contains inside it's list the pair (DatumHash, Datum) corresponding to it's current data.

Thanks @Mateus for your reply. I understand in case there is no Datum provided then we can't look it up from the DatumHash because in that case it is always TxOutDatumHashNone. So as you said, we can get Datum from a corresponding DatumHash if it is present. Can you please tell me how can we get Datum of the Lobster Challenge Contract from its DatumHash which is "45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0"
Thanks again for your answer.


text:
How to upgrade my Cardano node to version 1.30.1 from a Coincashew install?
I installed and configured my node by following the tutorial from Coincashew.
Currently running with version 1.29.0, could someone give a procedure to upgrade my node to the higher version safely?

1.30.1 release note: All SPOs and node users must update to this (or a later) version prior to the HF to Alonzo PV 6, or risk not being able to sync to the network.
IMPORTANT: As usual, don’t forget to backup your nodes before starting these updates.
STEP 1 - Clone the latest source and checkout the branch 1.30.1
cd $HOME/git
git clone https://github.com/input-output-hk/cardano-node.git cardano-node2
cd cardano-node2/
git fetch --all --recurse-submodules --tags
git checkout tags/1.30.1

STEP 2 - Make sure to have at least ghc 8.10.4 and cabal 3.4.0.0
ghcup upgrade
ghcup install ghc 8.10.4
ghcup set ghc 8.10.4
ghc --version
ghcup install cabal 3.4.0.0
ghcup set cabal 3.4.0.0
cabal --version
cabal update

STEP 3 - Configure & Compile
cd $HOME/git/cardano-node2
cabal configure -O0 -w ghc-8.10.4
echo -e "package cardano-crypto-praos\n flags: -external-libsodium-vrf" > cabal.project.local
cabal build cardano-node cardano-cli

Now make sure that your version of your freshly built cardano-cli and cardano-node is correct (1.30.1):
$(find $HOME/git/cardano-node2/dist-newstyle/build -type f -name "cardano-cli") version
$(find $HOME/git/cardano-node2/dist-newstyle/build -type f -name "cardano-node") version

STEP 4 - Shut your node down, replace your old binaries with the new ones in your bin folder and start your node again
Stop the node
sudo systemctl stop cardano-node

Replace old binaries with the new ones
sudo cp $(find $HOME/git/cardano-node2/dist-newstyle/build -type f -name "cardano-cli") /usr/local/bin/cardano-cli
sudo cp $(find $HOME/git/cardano-node2/dist-newstyle/build -type f -name "cardano-node") /usr/local/bin/cardano-node

Double check the version
cardano-node version
cardano-cli version

Start your node again
sudo systemctl start cardano-node

Check the logs:
journalctl --unit=cardano-node --follow

Now clean your mess
cd $HOME/git/
mv cardano-node cardano-node-old
mv cardano-node2 cardano-node

Enjoy


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

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

Get some tech info:

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

Get ADA/tokens balance and Plutus stuff

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

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

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

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

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

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

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


text:
Will the variables of the gas calculation formula be able to be dynamically adjusted by the protocol on Cardano?
My curiosity prompts me to ask you a question...
We have seen with many L1 Blockchains a recurring problem: the transaction fees fatally get more and more expensive with the valuation of the native coin when measured in USD (not to mention the protocols that prioritize transactions with an auction system).
I read in the official documentation that the Cardano fee structure is quite simple and has 2 protocol parameters.

Fees are constructed around two constants (a and b). The formula for
calculating minimal fees for a transaction (tx) is a * size(tx) + b,
where:
a/b are protocol parameters size(tx) is the transaction size in bytes
Protocol parameters (a and b) Protocol parameters are values that can
be altered by Cardano's update system to react and adapt to changes in
transaction volume, hardware prices, and ada valuation.

Since a and b are protocol parameters, changing these parameters would require a kind of hard fork.
Do you think that in the near future, one could imagine that the protocol will monitor in real time the valuation of ADA as well as the prices of the material needs of SPOs and will automatically launch hardforks?

Protocol parameters do not require a hard fork. They require a governance model to submit an update proposal that changes the parameters, but they do not increase the protocol version like era transitions. All existing nodes will get the new protocol parameters at the epoch boundary the update proposal takes effect. In the future, there could be some potential process that automates this.