text:
Can the creator of the App provide collateral for the user?
Consider integrated devices that use the Cardano blockchain, where the user does not see the wallet, but the wallet is working in the background
Is it possible to have this type of app supply collateral on behalf of the user from a wallet that the app developer controls? So the user doesn't need to send collateral to their new wallet
Looking for ways to solve the degraded UX of having to add collateral to new wallets before interacting with smart contracts
Thanks

Yes, collateral is just an UTXO, the dApp backend could provide one to be used and sign the transaction on the backend.
Also, regarding the bad UX, with the changes in the last hard fork, there is no need to setup collateral anymore and dApps can use any utxo.


text:
Example of mesh using EvaluateTx
Can anyone link an example of mesh handling a tx with a plutus script requiring the calculation of fees?

Are you looking for something like this?
https://meshjs.dev/providers/tangocrypto#evaluateTx
https://meshjs.dev/providers/ogmios#evaluateTx

I'm looking for examples using these functions

source: Stack Exchange

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

sort: votes


text:
Unclear error during Plutus ScriptContext construction (force headList [])
I ran into an error while trying to autobalance a transaction body:
module Foo.Offchain where
import Plutus.V1.Ledger.Scripts (MintingPolicy)
import Plutus.V1.Ledger.Address (Address)

import Hydra.Cardano.API
import Hydra.Prelude
import Test.Hydra.Prelude
import Cardano.Api.UTxO qualified as UTxO

import Foo.Onchain(fooPolicy)

userAddress :: Address ShelleyAddr
...

txFoo = do
  let policyScript = fromPlutusScript @PlutusScriptV2
        $ getMintingPolicy fooPolicy
      policyId = PolicyId $ hashScript $ PlutusScript policyScript
      mintingWitness = BuildTxWith . Map.singleton policyId
        $ mkScriptWitness policyScript NoScriptDatumForMint (toScriptData ())
      mintingValue = valueFromList [(AssetId policyId "", 1)]
  ...
  pparams <- queryProtocolParameters networkId nodeSocket QueryTip
  systemStart <- querySystemStart networkId nodeSocket QueryTip
  eraHistory <- queryEraHistory networkId nodeSocket QueryTip
  stakePools <- queryStakePools networkId nodeSocket QueryTip
  utxoSet <- ...
  someUtxo <- ...
  someTxOut <- ...
  ...
  let unbalancedBody =
        TxBodyContent
          (withWitness <$> toList (UTxO.inputSet utxoSet))
          (TxInsCollateral [someUtxo])
          TxInsReferenceNone
          [someTxOut]
          TxTotalCollateralNone
          TxReturnCollateralNone
          (TxFeeExplicit 0)
          (TxValidityNoLowerBound, TxValidityNoUpperBound)
          TxMetadataNone
          TxAuxScriptsNone
          TxExtraKeyWitnessesNone
          (BuildTxWith $ Just pparams)
          TxWithdrawalsNone
          TxCertificatesNone
          TxUpdateProposalNone
          (TxMintValue mintingValue mintingWitness)
          TxScriptValidityNone
  let balancedBody = either (error . show) balancedTxBody $
        makeTransactionBodyAutoBalance
          BabbageEraInCardanoMode
          systemStart
          eraHistory
          pparams
          stakePools
          (UTxO.toApi utxoSet)
          preBody
          (ShelleyAddressInEra userAddress)
          Nothing

I got the following error:
TxBodyScriptExecutionError
  [ ( ScriptWitnessIndexMint 0
    , ScriptErrorEvaluationFailed
        (CekError An error has occurred:
           User error:
             The machine terminated because of an error, either from a built-in
             function or from an explicit use of 'error'.
           Caused by: (force headList [])
        )
        []
    )
  ]

The strange thing is that I still get this error even if I reduce fooPolicy
down to a trivial check that depends only the ScriptContext:
module Foo.Onchain where

import PlutusTx.Prelude
import Plutus.V1.Ledger.Api (BuiltinData(..), Data(..), MintingPolicy, ScriptContext, UnsafeFromData (unsafeFromBuiltinData), mkMintingPolicyScript)
import Plutus.V1.Ledger.Contexts (ScriptPurpose(..), scriptContextPurpose)
import PlutusTx qualified

{-# INLINEABLE fooPolicyValidator #-}
fooPolicyValidator :: BuiltinData -> BuiltinData -> ScriptContext -> Bool
fooPolicyValidator _ _ ctx =
  case scriptContextPurpose ctx of
    Minting _cSymbol ->
      traceIfTrue "Here" True
    _other ->
      traceIfTrue "There" True

fooPolicy :: MintingPolicy
fooPolicy =
  mkMintingPolicyScript $
    $$(PlutusTx.compile
      [||\y z -> checkBool
        (fooPolicyValidator
          (BuiltinData (I 0))
          (BuiltinData (I 0))
          (unsafeFromBuiltinData z)
        )||])

{-# INLINEABLE checkBool #-}
checkBool :: Bool -> ()
checkBool True = ()
checkBool False = traceError "Check error"

How can it be possible to get an on-chain script execution error when all that my on-chain code does is look at the script context?

The import is wrong, you likely were using Hydra.Cardano.Api from hydra-cardano-api package. Cardano.Hydra.API does not exist to my knowledge.

Yup, that was a typo

The problem was that I was mixing on-chain code written in Plutus V1 with off-chain code that expects Plutus V2. In particular, the off-chain code utilities in the hydra-cardano-api library assume that all scripts are written in Plutus V2.
The strange error manifests because:

The Plutus V1 on-chain code compiles and serializes just fine.
The Plutus V2 off-chain code is happy to put the Plutus V1 compiled on-chain code into a transaction if you tag it as Plutus V2 code (i.e. fromPlutusScript @PlutusScriptV2)
When the Cardano node tries to validate your transaction, it fails at constructing the ScriptContext because of a mismatch between Plutus V1 and V2.
Unfortunately, when ScriptContext construction fails, the library is not able to give a more informative error than Caused by: (force headList []).

Solution: make sure that your on-chain code and off-chain code match on the Plutus version. For hydra-cardano-api, use Plutus V2 for all on-chain code.

Yes. The documentation of hydra-cardano-api was not explicit about this. We will add it to the package README and the module documentation of Hydra.Cardano.API.

Thanks! That would be helpful

Another hint to let you know you are mixing V1 and V2 code is looking at the serialised version of the on-chain code - the .plutus file.
If the file has "type": "PlutusScriptV1", then the on-chain code complied as V1 code. Modify the imports.

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


text:
Error when compiling cardano-node 1.35.5
I am getting the following error when trying to compile the new version of the cardano-node:
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: cardano-api-1.35.5 (user goal)
[__1] next goal: base (dependency of cardano-api)
[__1] rejecting: base-4.17.0.0/installed-4.17.0.0 (conflict: cardano-api =>
base>=4.14 && <4.15)
[__1] skipping: base-4.17.0.0, base-4.16.4.0, base-4.16.3.0, base-4.16.2.0,
base-4.16.1.0, base-4.16.0.0, base-4.15.1.0, base-4.15.0.0 (has the same
characteristics that caused the previous version to fail: excluded by
constraint '>=4.14 && <4.15' from 'cardano-api')
[__1] rejecting: base-4.14.3.0, base-4.14.2.0, base-4.14.1.0, base-4.14.0.0,
base-4.13.0.0, base-4.12.0.0, base-4.11.1.0, base-4.11.0.0, base-4.10.1.0,
base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, base-4.8.1.0,
base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1,
base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0,
base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0,
base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from
non-upgradeable package requires installed instance)
[__1] fail (backjumping, conflict set: base, cardano-api)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, cardano-api

I am using ghc 9.4.4 and cabal 3.8.1.0

The solution to this error is to downgrade ghc to version 8.10.7 by running the following commands:
ghcup install ghc 8.10.7
ghcup set ghc 8.10.7

Then, you have to prepare the compilation for that specific compiler version, like this:
cabal configure -O0 -w ghc-8.10.7

Then you can run:
cabal build cardano-node cardano-cli

Unfortunately, cardano-node is not yet compatible with the latests versions of ghc (9.4.4 and 9.2.5 at the time of this post).


text:
Error when trying to build my Plutus project
I am getting the following error after trying to execute cabal build:
cabal: Could not resolve dependencies:
[__0] next goal: cardano-crypto-class (user goal)
[__0] rejecting: cardano-crypto-class-2.0.0.0.1/installed-iw7NtuXmRKLDXiVT5sxh
(constraint from user target requires ==2.0.0)
[__0] rejecting: cardano-crypto-class-2.0.0 (conflict: pkg-config package
libsodium-any, not found in the pkg-config database)
[__0] fail (backjumping, conflict set: cardano-crypto-class)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: cardano-crypto-class

I am using cabal 3.6.2.0 and ghc 8.10.7

You are missing libsodium :
[__0] rejecting: cardano-crypto-class-2.0.0 (conflict: pkg-config package
libsodium-any, not found in the pkg-config database)

The way I get around this is sudo apt install libsodium-dev and then create a top level file cabal.project.local containing:
package cardano-crypto-praos
  flags: -external-libsodium-vrf

Pretty sure this is documented somewhere in the cardano-node repository.

It is documented here: https://github.com/input-output-hk/cardano-node/blob/1.35.5/doc/getting-started/install.md#installing-libsodium

It is documented, but it no longer works. Builds are failing with the hack in place.

I just tried it and it works for me. What specifically is the problem you are seeing. Probably worth asking that as a new question. You need to specify what steps you are taking and what the error is.


text:
Error when trying to build my Plutus project using nix-shell
I am getting the following error after running cabal build using nix-shell:
cabal: Could not resolve dependencies:
[__0] next goal: Win32-network (user goal)
[__0] rejecting: Win32-network-0.1.1.0/installed-Cm3H3JOsc0sL7v05D4U9jQ
(constraint from user target requires ==0.1.0.0)
[__0] trying: Win32-network-0.1.0.0
[__1] trying: base-4.14.3.0/installed-4.14.3.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.3.0/installed-4.14.3.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.3.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.

I am using cabal 3.6.2.0 and ghc 8.10.7

The conflict suggests your ghc may be too new, try with 8.10.7

Hey James, thanks for your reply but that was actually a typo. I have just corrected the GHC version in the post.

In that case, try entering shell with nix develop as per the contributing doc: https://github.com/input-output-hk/plutus/blob/master/CONTRIBUTING.adoc

I am getting this error when I want to run nix develop: error: flake 'git+file:///home/matifalcone/Blockchain/Cardano/Plutus/plutus-apps' does not provide attribute 'devShells.x86_64-linux.default', 'devShell.x86_64-linux', 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'

Right, that's for plutus repo. For plutus-apps follow instructions in https://github.com/input-output-hk/plutus-apps/blob/main/CONTRIBUTING.adoc

Which instructions should I follow there? I don't see the nix develop option in this file.

You've not given much context so I don't know exactly what you were trying to build. If you're unable to build a project based on plutus-apps using the instructions in its contributing document then will need more details about what differences there are in your project.

This is the project I am trying to run: https://github.com/Falcon-Cardano-Stakepool/token-vesting-script

Rather than debugging this you should look at updating your dependencies within the last 6 months. Your targeting node 1.33.0 which is over a year old now and won't work on any current public testnet. Try target 1.35.4, as plutus-apps currently does, bring your index state and target commits a bit more up to date and it should make things easier.


text:
How to resolve this "(FromAlonzoUtxoFail (UtxosFailure (ValidationTagMismatch (IsValid True)" transaction submission error on mesh library
I am getting this error on transaction submission.
""transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (UtxosFailure (ValidationTagMismatch (IsValid True) (FailedUnexpectedly (PlutusFailure \"\\nThe 3 arg plutus script (PlutusScript PlutusV1 ScriptHash \\\"ae7b1ca9255aa4000270f38e5ee7d75b0af4955866123b5d794b54f0\\\") fails.\\nCekError An error has occurred:  User error:\\nThe machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.\\nThe protocol version is: ProtVer {pvMajor = 8, pvMinor = 0}\\nThe data is: I 0\\nThe redeemer is: Constr 0 []\\nThe context is:\\nPurpose: Spending (TxOutRef {txOutRefId = bac7a90f9efc79aa7af175d119bb55140423cea4f6b7c72f3141b96ccbc7e31c, txOutRefIdx = 0})\\nTxInfo:\\n  TxId: 2af255afcb495512d1aa502ae7c985f97c1e66ad97328c8d8db9555936b9839b\\n  Inputs: [ bac7a90f9efc79aa7af175d119bb55140423cea4f6b7c72f3141b96ccbc7e31c!0 -> - Value (Map [(,Map [(\\\"\\\",1000000)])]) addressed to\\n                                                                                ScriptCredential: ae7b1ca9255aa4000270f38e5ee7d75b0af4955866123b5d794b54f0 (no staking credential)\\n          , bac7a90f9efc79aa7af175d119bb55140423cea4f6b7c72f3141b96ccbc7e31c!1 -> - Value (Map [(,Map [(\\\"\\\",9993127795)]),(65b00f2037ae0e74172da23589a121a34861bfe51d4c436a21483cf5,Map [(\\\"myNFT2\\\",1)])]) addressed to\\n                                                                                PubKeyCredential: d38f63fe3306e5f63e0e29691f50b0357e2f6d56ab18bfbd9a97bc2f (StakingHash PubKeyCredential: e53568cb1de2a784ad8c67d3273057c714472528dd27b09cc7687b26) ]\\n  Outputs: [ - Value (Map [(,Map [(\\\"\\\",1000000)])]) addressed to\\n               PubKeyCredential: d38f63fe3306e5f63e0e29691f50b0357e2f6d56ab18bfbd9a97bc2f (StakingHash PubKeyCredential: e53568cb1de2a784ad8c67d3273057c714472528dd27b09cc7687b26)\\n           , - Value (Map [(,Map [(\\\"\\\",9992327046)]),
-> Just cut the half error as it full of numbers and unreadable.
My plutus script onchain has validation of we can unlock from the script by giving the redeemer 42. I am using mesh library to write the offchain code. My unlock function is here
  const utxos= await blockfrost.fetchAddressUTxOs (
    scriptAddress
  );
  const dataHash = resolveDataHash(datum);
  let utxo = utxos.find ((utxo:any)=>{
    return utxo.output.dataHash == dataHash;
  });

  return utxo;
}

async function unLock() {
  const assetUTXO = await _getAssetUTXO ({
    scriptAddress: scriptAddr,
    datum: 0,
  });

  const tx =  new Transaction ({initiator:wallet})
    .redeemValue({
      value: assetUTXO,
      script:fortyTwoScript,
      datum: 0 ,
      redeemer: 42,
})
    .sendValue(myAddress, assetUTXO)
    .setRequiredSigners([myAddress]);

  const unsignedTx = await tx.build();
  const signedTx = await wallet.signTx(unsignedTx, true);
  const txHash = await wallet.submitTx(signedTx);
  console.log ("txHash of unlocking= ", txHash);
}

I was wondering that may be there is an issue in my script, but i have tested my script by locking and unlocking ADA with cardano cli. And it all went good.
Please guide me with this error, I am stuck on this

Finally I got it and resolved. As I was locking lovelace in a script following the locking of assets. So i didnt made one change according to lovelace. So here is my modified function
  const assets = [
    {
      unit: "lovelace",
      quantity: 1000000,
    },
  ];

  const assetUTXO = await _getAssetUTXO ({
    scriptAddress: myScriptAddress,
    asset: assets[0].unit,
    datum: 0,
  });
  console.log("asset UTXO = ", assetUTXO);

  const myRedeemer: Partial<Action> = {
    data: 42,
  };
  const tx =  new Transaction ({initiator:wallet})
    .redeemValue({
      value: assetUTXO,
      script:myScript,
      datum: 0 ,
      redeemer: myRedeemer,
})
    .sendValue(myAddress, assetUTXO)

  const unsignedTx = await tx.build();
  const signedTx = await wallet.signTx(unsignedTx, true);
  const txHash = await wallet.submitTx(signedTx);
  console.log ("txHash of unlocking= ", txHash);
}


text:
Cardano-Node having errors at 84% sync

cardano-node 1.35.5
linux-x86_64
ghc-8.10
git rev 8762a10efe3f9f97939e3cb05edaf04250456702
Trying to connect to testnet

I downloaded the binary and configured it per instructions at lovelace academy.  I left it running as it was syncing successfully until it got to around 84%, then it stopped making progress and instead keeps spitting out errors and warnings based around "invalid block"
Some errors:
[Computer:cardano.node.DnsSubscription:Error:3207] [2023-02-02 03:26:52.54 UTC] Domain: "relays-new.cardano-testnet.iohkdev.io" Application Exception: 3.131.32.242:3001 InvalidBlock (At (Block {blockPointSlot = SlotNo 63419662, blockPointHash = 38dc2f5dbb184b504eda086a5f64c19931a985bf2246b74ed18e796712cff67a})) 708745ea94515b679223a5514e6e6dba068208e5b79780134206f74e1e79e727 (ValidationError (ExtValidationErrorLedger (HardForkLedgerErrorFromEra S (S (S (S (S (Z (WrapLedgerErr {unwrapLedgerErr = BBodyError (BlockTransitionError [ShelleyInAlonzoPredFail (LedgersFailure (LedgerFailure (UtxowFailure (MalformedScriptWitnesses (fromList [ScriptHash "eee7bfb25cfbbbcd31a1d5d648429ff919430ee5d06d8d056e48d605"])))))])})))))))))

[Computer:cardano.node.ErrorPolicy:Warning:81] [2023-02-02 03:26:52.54 UTC] IP 3.131.32.242:3001 ErrorPolicySuspendPeer (Just (ApplicationExceptionTrace (InvalidBlock (At (Block {blockPointSlot = SlotNo 63419662, blockPointHash = 38dc2f5dbb184b504eda086a5f64c19931a985bf2246b74ed18e796712cff67a})) 708745ea94515b679223a5514e6e6dba068208e5b79780134206f74e1e79e727 (ValidationError (ExtValidationErrorLedger (HardForkLedgerErrorFromEra S (S (S (S (S (Z (WrapLedgerErr {unwrapLedgerErr = BBodyError (BlockTransitionError [ShelleyInAlonzoPredFail (LedgersFailure (LedgerFailure (UtxowFailure (MalformedScriptWitnesses (fromList [ScriptHash "eee7bfb25cfbbbcd31a1d5d648429ff919430ee5d06d8d056e48d605"])))))])})))))))))))) 200s 200s

[Computer:cardano.node.DnsSubscription:Warning:85] [2023-02-02 03:27:12.21 UTC] Domain: "relays-new.cardano-testnet.iohkdev.io" Unsupported remote target address [2600:1f1c:d4f:6d00:0:1:0:4]:3001

It keep repeating these and other warnings over and over again.  I don't know how to fix the "Invalidblock" situation.  I tried rebooting but that didn't help.  Is there a way I can delete the invalid block or ledger entry, or delete all the synced data and try again?
Thanks

I don't think it should be possible to fully sync testnet with recent versions of cardano node. There was a divergence in ledger rules last year. For this reason, it is deprecated and no one should be using it.
Look at using either preview or preprod testnets. Config files can be found here: https://book.world.dev.cardano.org/environments.html

I'm syncing from genesis using 1.35.5 , currently at 27%. Will let you know how it goes.
The Cardano block chain DB is stored in state-node-mainnet directory or state-node-testnet dir if syncing testnet in the cardano-node root directory.
If you need to resync from genesis:

Stop the node
Delete the state-node- directory of corresponding network
Start the node again syncing from scratch

try this amazing tool :)
they take snapshot of the db
https://csnapshots.io/about
How does it work

Every day they are generating new snapshots and uploading to CDN service which redistributes the database to servers around the world for faster download speeds


text:
Detailed upgrade instructions for latest db-sync release 13.1
I was wondering if anyone knows where I can find the detailed upgrade instructions for db-sync 13.1.  I’m current on the previous release and think the upgrade shouldn’t be too difficult, but I can find any documentation for this.
All help is appreciated!
Nick

I think its just a matter of installing the new version. The database schema is compatible with the previous 13.0.* version.

Thanks Erik!  I really appreciate the quick response here.  All is back to normal, db-sync is up and running.  I followed the Guild Operators notes, so I had to perform an upgrade of the pre-requisite scripts then add the hash values back into the config.json file.

While upgrade of dbsync is straightforward (replace binary and schema folder reference), it is important to note that the upgrade will cause you to lose most of your unique indexes (and deletion of foreign key will have performance differences too). There isn't a clear one-to-one mapping documented yet, but recreation of unique indexes (subset) would be as below (only include what you really need):
CREATE UNIQUE INDEX IF NOT EXISTS unique_ada_pots ON public.ada_pots USING btree (block_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_col_txin ON public.collateral_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_col_txout ON public.collateral_tx_out USING btree (tx_id, index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_delegation ON public.delegation USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_epoch_param ON public.epoch_param USING btree (epoch_no, block_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ma_tx_mint ON public.ma_tx_mint USING btree (ident, tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ma_tx_out ON public.ma_tx_out USING btree (ident, tx_out_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_param_proposal ON public.param_proposal USING btree (key, registered_tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_owner ON public.pool_owner USING btree (addr_id, pool_update_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_relay ON public.pool_relay USING btree (update_id, ipv4, ipv6, dns_name);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_retiring ON public.pool_retire USING btree (announced_tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_ref_tx_in ON reference_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pool_update ON public.pool_update USING btree (registered_tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_pot_transfer ON public.pot_transfer USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_redeemer ON public.redeemer USING btree (tx_id, purpose, index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_reserves ON public.reserve USING btree (addr_id, tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_stake_deregistration ON public.stake_deregistration USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_stake_registration ON public.stake_registration USING btree (tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_treasury ON public.treasury USING btree (addr_id, tx_id, cert_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_txin ON tx_in USING btree (tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_tx_metadata ON public.tx_metadata USING btree (key, tx_id);
CREATE UNIQUE INDEX IF NOT EXISTS unique_withdrawal ON public.withdrawal USING btree (addr_id, tx_id);

CREATE INDEX IF NOT EXISTS idx_ma_tx_out_ident ON ma_tx_out (ident) ;

Diffing the schema, I found two more
CREATE UNIQUE INDEX IF NOT EXISTS unique_ref_tx_in ON reference_tx_in USING btree (tx_in_id, tx_out_id, tx_out_index);
CREATE UNIQUE INDEX IF NOT EXISTS unique_txin ON tx_in USING btree (tx_out_id, tx_out_index);
Related db-sync issue

Thanks, updated original comment


text:
Is there a way to get cardano-node version in Prometheus metrics?
Like the title says, does anyone here know of the proper way to go about adding cardano-node version to the cardano_node_metrics being exported by Prometheus to Grafana? I would like to add this information to the dashboard without having to create a whole separate set of scripts and services to obtain this information.
There is this Github issue with the same request, but it is marked as closed without any explanation/documentation.
Then there is also this, which seems to imply that it is possible and is somehow used by IOG for their internal operations or something. But it involves Nix, which is currently beyond my realm of understanding.
My solution is to use prometheus_client in Python to create a service on each node just to export the version. But if there is a cleaner way...please let me know.

On last your link "there is also this, which seems to imply...", if you look down OP mentioned that it is not native metric, but rather generated by script, same idea as with your Python script. I would guess that is the way...

Yes, that is the route that I went. A Python script to get the versions and dump it to an appropriately formatted text file to use with Prometheus text file collectors.


text:
Given tx hash, get block # and info about block the transaction is in
Is there any API for this out already?
I'm looking for an API that:

Given a tx hash, can get the block # and info about the block which the transaction was in
get current block # and info about current block

Using Blockfrost.io API:

For transaction hash dbbf5116280f83bb6d3d117ef0b41ca52b0bb85f417f761bd42d1903286743e6:

You can find the block height:
 $ curl -s https://cardano-mainnet.blockfrost.io/api/v0/txs/dbbf5116280f83bb6d3d117ef0b41ca52b0bb85f417f761bd42d1903286743e6 -H 'project_id: xxx' \
  | jq .block_height
8369736

And use that block height to get more information about the given block.
$ curl -s https://cardano-mainnet.blockfrost.io/api/v0/blocks/8369736 -H 'project_id: x'  | jq
{
  "time": 1675778106,
  "height": 8369736,
  "hash": "0fa8c39c9c30ebb14b64781cca63d326a3c57154dfb590d63c0d3eb7850cc4ec",
  "slot": 84211815,
  "epoch": 392,
  "epoch_slot": 231015,
  "slot_leader": "pool1q7wrwstqkzhrffdzpw8ftfd4epmxywdjnp8384atjcnezchv242",
  "size": 88902,
  "tx_count": 35,
  "output": "22093283458254",
  "fees": "11180120",
  "block_vrf": "vrf_vk1uatrt2xzhxs382ss5u9mr20aahzx8s000c077xerulzy22dzxy3qc0r6qv",
  "op_cert": "9c6689a625fb22cd17df084718f232155a15a73b56103a96a117e5d4a58f95a8",
  "op_cert_counter": "10",
  "previous_block": "055462536b48a16b91552ff05df0760d2191c044ec419f2f93d9c7a894aaecde",
  "next_block": "f63f3ed7140524bffc1a975a177f93cf72b426201f9ea5a82cb059a7ed1b53df",
  "confirmations": 10
}

For the current block number, just use /api/v0/blocks/latest.

If you looking for a simple web API, the most popular choice is Blockfrost:
https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1%7Bhash_or_number%7D/get
https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1latest/get
which has a generous free tier.
An alternative is Koios:
https://api.koios.rest/#overview
If you want to run some infrastructure yourself, have a look at:
Ogmois: https://ogmios.dev/
or Oura: https://github.com/txpipe/oura
specifically to get the latest block/live data and
cardano-db-sync (https://github.com/input-output-hk/cardano-db-sync)
or carp (https://github.com/dcSpark/carp)
to query the whole chain.

This is a relatively simple query against cardano-db-sync.


text:
"The second data argument, does not decode to a context" when minting NFT with Mesh
This my script for minting NFT:
{-# INLINABLE mkPolicy #-}
mkPolicy :: BuiltinData -> PlutusV2.ScriptContext -> Bool
mkPolicy _ ctx = traceIfFalse "wrong amount minted" checkNFTAmount

  where
    info :: PlutusV2.TxInfo
    info = PlutusV2.scriptContextTxInfo ctx

    -- hasUTxO :: Bool
    -- hasUTxO = any (\i -> PlutusV2.txInInfoOutRef i == mpTxOutRef r) $ PlutusV2.txInfoInputs info

    checkNFTAmount :: Bool
    checkNFTAmount = case Value.flattenValue (PlutusV2.txInfoMint info) of
       [(cs, tn', amt)] -> cs  == ownCurrencySymbol ctx && tn' == PlutusV2.TokenName "" && amt == 1
       _                -> False

{-
    As a Minting Policy
-}

compiledCode :: PlutusTx.CompiledCode (BuiltinData -> BuiltinData -> ())
compiledCode = $$(PlutusTx.compile [|| wrap ||])
  where
    wrap = Scripts.mkUntypedMintingPolicy mkPolicy

policy :: Scripts.MintingPolicy
policy = PlutusV2.mkMintingPolicyScript compiledCode

script :: PlutusV2.Script
script = PlutusV2.unMintingPolicyScript policy
{-
    As a Short Byte String
-}

scriptSBS :: SBS.ShortByteString
scriptSBS = SBS.toShort . LBS.toStrict $ serialise script

{-
    As a Serialised Script
-}

serialisedScript :: PlutusScript PlutusScriptV2
serialisedScript = PlutusScriptSerialised scriptSBS

writeSerialisedScript :: IO ()
writeSerialisedScript = void $ writeFileTextEnvelope "nft-mint-V2.plutus" Nothing serialisedScript

I'm using Mesh to minting NFT with that script
    const walletAddr = wallet.getPaymentAddress();
    const addressUtxo: UTxO[] = await provider.fetchAddressUTxOs(walletAddr);

    const redeemer: Partial<Action> = {
        tag: "MINT",
        data: {
            alternative: 0,
            fields: [],
        },
    };

    const assetMetadata: AssetMetadata = {
        name: "MyNFT",
        image: "https://picsum.photos/200",
        mediaType: "image/jpg",
        description: "This NFT is minted by me.",
    };

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

    // Mint NFT

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

    tx.mintAsset(script, asset, redeemer);
    tx.setCollateral([addressUtxo[0]]);

    const unsignedTx = await tx.build();
    const signedTx = await wallet.signTx(unsignedTx, true);
    try {
        const txHash = await wallet.submitTx(signedTx);
        console.log(txHash);
    } catch (e) {
        console.log(e);
    }

Unfortunately, it returned with this error:
transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage
(ApplyTxError
[UtxowFailure
(UtxoFailure
(FromAlonzoUtxoFail
(UtxosFailure
(ValidationTagMismatch
(IsValid True)
(FailedUnexpectedly
(PlutusFailure \\\"\\\\nThe 2 arg plutus script (PlutusScript PlutusV2 ScriptHash \\\\\\\"77f807bc9403ef0177cc2a9956bfd5628ee649680041ccf48a198fc0\\\\\\\") fails.
\\\\nCekError An error has occurred:
User error:\\\\nThe machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
\\\\nThe protocol version is: ProtVer {pvMajor = 7, pvMinor = 0}\\\\nThe redeemer is: Constr 0 []\\\\
nThe second data argument, does not decode to a context

Does anyone faced this error before, what's wrong with my script?

I think this is to do with the conversion of Data to ScriptContext.  How are you compiling and serialising your policy?

I updated the compile code above, can you take a look at that @james

I think the script is produced correctly. Unfortunately, I cannot help with how it is used to construct a transaction using Mesh. You could start by verifying the script is correct by using cardano-cli.

As Manu already mentioned it seems like the provider on which wallet.submitTx is based on is passing a Contex of PlutusV1 while your script expects a context of PlutusV2
this is not the fault of mesh; rather than whatever the wallet uses to submit the transaction
You might want to try a different submission method; as an example you could perform a POST request to koios.

NOTE netToDom maps a given KoiosNetwork to the matching sub domain

here is an example on how a transaciton is submitted using the code from koios-pluts
export async function submitTx( tx: Tx, network: KoiosNetwork = "mainnet" ): Promise<Hash32>
{
    const net: KoiosNetwork = tx.body.network === "testnet" ?
        ( network === "preview" ? "preview" : "preprod" ) :
        "mainnet";

    return fetch(`https://${netToDom(net)}.koios.rest/api/v0/submittx`, {
        method: "post",
        headers: {
          'Content-Type': 'application/cbor'
        },
        body: tx.toCbor().toBuffer().buffer
    })
    .then(  res =>  {

        if( !res.ok )
        throw new KoiosError(
            "error submitting '" + tx.hash.toString() + "' transaction; " +
            "endpoint used: " + `https://${netToDom(net)}.koios.rest/api/v0/submittx ` +
            "JSON form of the tranascton: " +
            JSON.stringify(
                tx.toJson(),
                undefined,
                2
            )
        );

        return tx.hash;
    })
}

Just an idea, instead of using:
mkPolicy :: BuiltinData -> PlutusV2.ScriptContext -> Bool

Use:
mkPolicy :: BuiltinData -> PlutusV1.ScriptContext -> Bool

It looks like MESH is creating a transaction with a valid redeemer but not a valid context. Could be that its creating a context of Plutus V1, witch is different data structure in Plutus V2 where there are more fields.
You will need to change other mentions to PlutusV2 and use PlutusV1 in your code.

Your script seems simple enough, and this is what it would look like in Helios (which is both an on-chain compiler and off-chain tx builder).   Maybe try it on helios and then try to debug what's wrong with your mesh implementation.
I've also got a video on minting an nft with Helios here https://www.youtube.com/watch?v=5iPqe-HNIUE
https://github.com/lley154/helios-examples/blob/main/nft/pages/index.tsx
...

  const mintNFT = async (params : any) => {

    const address = params[0];
    const name = params[1];
    const description = params[2];
    const img = params[3];
    const minAdaVal = new Value(BigInt(2000000));  // minimum Ada needed to send an NFT

    // Get wallet UTXOs
    const walletHelper = new WalletHelper(walletAPI);
    const utxos = await walletHelper.pickUtxos(minAdaVal);

    // Get change address
    const changeAddr = await walletHelper.changeAddress;

    // Determine the UTXO used for collateral
    const colatUtxo = await walletHelper.pickCollateral();

    // Start building the transaction
    const tx = new Tx();

    // Add the UTXO as inputs
    tx.addInputs(utxos[0]);

    const mintScript =`minting nft
    const TX_ID: ByteArray = #` + utxos[0][0].txId.hex + `
    const txId: TxId = TxId::new(TX_ID)
    const outputId: TxOutputId = TxOutputId::new(txId, ` + utxos[0][0].utxoIdx + `)

    func main(ctx: ScriptContext) -> Bool {
        tx: Tx = ctx.tx;
        mph: MintingPolicyHash = ctx.get_current_minting_policy_hash();

        assetclass: AssetClass = AssetClass::new(
            mph,
            "` + name + `".encode_utf8()
        );
        value_minted: Value = tx.minted;

        // Validator logic starts
        (value_minted == Value::new(assetclass, 1)).trace("NFT:1 ") &&
        tx.inputs.any((input: TxInput) -> Bool {
                                        (input.output_id == outputId).trace("NFT2: ")
                                        }
        )
    }`

    // Compile the helios minting script
    const mintProgram = Program.new(mintScript).compile(optimize);

    // Add the script as a witness to the transaction
    tx.attachScript(mintProgram);

    // Construct the NFT that we will want to send as an output
    const nftTokenName = ByteArrayData.fromString(name).toHex();
    const tokens: [number[], bigint][] = [[hexToBytes(nftTokenName), BigInt(1)]];

    // Create an empty Redeemer because we must always send a Redeemer with
    // a plutus script transaction even if we don't actually use it.
    const mintRedeemer = new ConstrData(0, []);

    // Indicate the minting we want to include as part of this transaction
    tx.mintTokens(
      mintProgram.mintingPolicyHash,
      tokens,
      mintRedeemer
    )

    // Construct the output and include both the minimum Ada as well as the minted NFT
    tx.addOutput(new TxOutput(
      Address.fromBech32(address),
      new Value(minAdaVal.lovelace, new Assets([[mintProgram.mintingPolicyHash, tokens]]))
    ));

    // Add the collateral utxo
    tx.addCollateral(colatUtxo);

    const networkParams = new NetworkParams(
      await fetch(networkParamsUrl)
          .then(response => response.json())
    )

    // Attached the metadata for the minting transaction
    tx.addMetadata(721, {"map": [[mintProgram.mintingPolicyHash.hex, {"map": [[name,
                                      {
                                        "map": [["name", name],
                                                ["description", description],
                                                ["image", img]
                                              ]
                                      }
                                  ]]}
                                ]]
                        }
                  );

    console.log("tx before final", tx.dump());

    // Send any change back to the buyer
    await tx.finalize(networkParams, changeAddr);
    console.log("tx after final", tx.dump());

    console.log("Verifying signature...");
    const signatures = await walletAPI.signTx(tx);
    tx.addSignatures(signatures);

    console.log("Submitting transaction...");
    const txHash = await walletAPI.submitTx(tx);

    console.log("txHash", txHash);
    setTx({ txId: txHash.hex });


text:
ScriptWitnessNotValidatingUTXOW while minting an NFT
I'm currently trying to create a minting process with lucid (v. 0.8.9) using Blockfrost on Mainnet.
Minting policy:
const mintingPolicy: MintingPolicy = lucid.utils.nativeScriptFromJson({
    type: "any",
    scripts: [{
        scripts: [{
            keyHash: "ccb1d97578fe819d6df11095a74a96803e5a50460b5cf895aaf40c0d",
            type: "sig"
        }],
        type: "all"
    }, {
        scripts: [{
            keyHash: "66f9337a3873f06478d394058ec7fda75909b359df883b8aaf8ba79d",
            type: "sig"
        }],
        type: "all"
    }, {
        scripts: [{
            keyHash: "6c70c3fc4f73e5bbb54cc87bdf943fad2213da692b260e12749bcc10",
            type: "sig"
        }],
        type: "all"
    }]
});

Mint function:
export async function mintNFT(name ? : string, ): Promise < TxHash > {
    try {
        const unit: Unit = policyId2;
        const tx = await lucid.newTx().mintAssets({
            [unit]: 1n
        }).attachMintingPolicy(mintingPolicy).validTo(Date.now() + 100_000).complete();
        const signedTx = await tx.sign().complete();
        const txHash = await signedTx.submit();
        console.log(txHash) return txHash;
    } catch (e: any) {
        console.log('Error occured:');
        console.log(e.message);
        return e.message;
    }
}

Error:
"transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (WrappedShelleyEraFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash \"f188522db566255b029de7c30e1e5cc14c30ba6649356d9b1ae8ebb5\"]))))])"

Where f188522db566255b029de7c30e1e5cc14c30ba6649356d9b1ae8ebb5 is a policyId.
I'm not entirely sure, but the error seems to be fixable by adding invalid-hereafter parameter to a raw transaction in cli OR by signing a transaction with both skey and vkey (I think that currently lucid only signs with vkey), but I didn't find a way to do it properly.

I messed up the keyHashes in the minting policy and was trying to mint with a different wallet.
This was extremely useful.

I'm not sure if this will help, but I have an example that includes both on-chain and off-chain code for minting a multi-sig NFT using Helios.
https://github.com/lley154/helios-examples/tree/main/nft-multisig


text:
What are the differences between different kinds of datums (datum, datumhash, inlineDatum, inlineDatumHash)?
I sent some ADA to a smart contract address with the non inline datum of "1234" and when i queried the utxo with cardano-cli, I got this result.
"603ca96747bd39152a36d185662a6092f68d7f1c97dd65de81484c72168da3e2#0": {
    "address": "addr_test1wzhqvrgumuy3jc44w763cudwyass0rzm2rthuve9vy5k7gggadmgm",
    "datum": null,
    "datumhash": "b2d7e9699dc52c42ab1aa0f28e4d9d28e0f6f7d780054b024722b87611c13de8",
    "inlineDatum": null,
    "referenceScript": null,
    "value": {
        "lovelace": 10000000
    }
}

And when I sent the same some ADA with the inline datum of "1234" I got this result.
"d1dbd36e840f0005d53c976f8426134b6378b5eb40e04948c537f238a9d10a98#0": {
    "address": "addr_test1wzhqvrgumuy3jc44w763cudwyass0rzm2rthuve9vy5k7gggadmgm",
    "datum": null,
    "inlineDatum": {
        "bytes": "1234"
    },
    "inlineDatumhash": "b2d7e9699dc52c42ab1aa0f28e4d9d28e0f6f7d780054b024722b87611c13de8",
    "referenceScript": null,
    "value": {
        "lovelace": 10000000
    }
}

I have some understanding of inlinedatum and datumhash but what are those datum and inlnedatumhash are for?

I don't think datum is ever used, it should probably be removed from this output. inlineDatumHash is probably just for convenience so you can know the hash of the inline datum, it's not needed for using the inline datum as witness.


text:
How can i get all buy and sell transactions for an NFT using blockfrost?
So I want to use blockfrost to extract all transactions of an NFT that are associated with marketplace trades. I understand that I can get an assets transaction history through /assets/{asset}/history but this doesn't quite solve the problem of identifying which transactions were part of a trade on an NFT market place.
Does anyone have a solution? I am doing this as I want to track the history of an NFT to identify / flag stolen NFTs on their journey through the blockchain.
Any suggestions would be greatly appreciated, thank you :)

A marketplace is generally just a contract.
As an example, jpg.store contract hash according to cexplorer.org is 9068a7a3f008803edac87af1619860f2cdcde40c26987325ace138ad.
So, if you want to see all transactions regarding to trades, you just have to look at the transactions associated with this script addresses.


text:
Can't register my stake pool on Cardano (StakeDelegationImpossibleDELEG)
I'm following the official process here on the Cardano tutorial.
Firstly, I have to show you I already have the fund here:
// cardano-cli query utxo --address $(cat payment.addr) --mainnet

                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
4c782ea34b517b99e508f675ea1019bc6c60738570ae7dbf074d3ad2d44e8eef     0        600000000 lovelace + TxOutDatumNone
75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386     0        17648934 lovelace + TxOutDatumNone
e663b2e14f180ae341a49bcbde247d074d944942cc3b8794277645ac1e49d377     0        8336205 lovelace + TxOutDatumNone

In the process, I've already created my pool-registration.cert file.
We can double-check thanks to this:
// cat pool-registration.cert
{
    "type": "CertificateShelley",
    "description": "Stake Pool Registration Certificate",
    "cborHex": "8a03581ce9c55b1910e7fdcacf2db1be6f20fadff0e5d68d6566b223698031ab58208ad95d9965ca817e7d7d5d6985ba4c92b77a206250fa59f52acb6ab36507c79b1a001e84801a1443fd00d81e820001581de1084cf0adf9fe75b3e479e6c837676bb85016ae891c624cf59004a00981581c084cf0adf9fe75b3e479e6c837676bb85016ae891c624cf59004a009818400190bb9449e8cc08ff682783d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6574737261706861656c2f43617264616e6f2f702f702e6a736f6e5820dee0758d3212808f99698e96446dd9400b4455d5c44286f91f66dd6c5796d064"
}

// cat delegation.cert
{
    "type": "CertificateShelley",
    "description": "Stake Address Delegation Certificate",
    "cborHex": "83028200581c084cf0adf9fe75b3e479e6c837676bb85016ae891c624cf59004a009581ce9c55b1910e7fdcacf2db1be6f20fadff0e5d68d6566b223698031ab"
}

Then after calculating my fees and taking a look at the hereafter, I'm building my transaction like this:
cardano-cli transaction build-raw \
    --tx-in 4c782ea34b517b99e508f675ea1019bc6c60738570ae7dbf074d3ad2d44e8eef#0 \
    --tx-out $(cat payment.addr)+99802951 \
    --invalid-hereafter 75915180 \
    --fee 197049 \
    --out-file tx.raw \
    --certificate-file pool-registration.cert \
    --certificate-file delegation.cert

Finally, I'm signing and sending my message like this:
cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --signing-key-file cold.skey \
    --mainnet \
    --out-file tx.signed

cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet

My result after this is:
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [DelegsFailure (DelplFailure (DelegFailure (StakeDelegationImpossibleDELEG (KeyHashObj (KeyHash "084cf0adf9fe75b3e479e6c837676bb85016ae891c624cf59004a009")))))])

Thank you if somebody can help, I will add more information if needed.

You first need to create a registration certificate for the stake key, before being able to delegate it.
You can submit all 3 certificates in the same transaction, just add the key registration certificate between the other 2 certificates.
You can see all the steps in my documentation here: https://apexpool.gitbook.io/stake-pool-scripts/stake-pool-registration/stake-pool-scripts/stake-key-registration

After following your documentation, it worked. Really appreciate it, thank you.


text:
cardano-node preprod testnet sync stuck in nix develop, possible headerError
Supposed to run testnet node in nix develop.
which cardano-node outputs /nix/store/y29rzxcr6vswgc5nhmind0cjbkqxi414-cardano-node-exe-cardano-node-1.35.3/bin/cardano-node
seems to be a HeaderError with this command cardano-node run --topology configs/testnet-topology.json --database-path db --socket-path node.socket --config configs/testnet-config.json
The configs I got is from here
This is the log of the node.
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:41.82 UTC] TracePromoteColdPeers 50 0 (fromList [3.72.231.105:30000])
[34m[hud-PS:cardano.node.ConnectionManager:Info:158][0m [2022-11-03 14:25:41.82 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 0})
[34m[hud-PS:cardano.node.ConnectionManager:Info:158][0m [2022-11-03 14:25:41.99 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 1})
[34m[hud-PS:cardano.node.ConnectionManager:Info:159][0m [2022-11-03 14:25:42.37 UTC] TrConnectionHandler (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}) (TrHandshakeSuccess NodeToNodeV_10 (NodeToNodeVersionData {networkMagic = NetworkMagic {unNetworkMagic = 1}, diffusionMode = InitiatorAndResponderDiffusionMode}))
[34m[hud-PS:cardano.node.ConnectionManager:Info:158][0m [2022-11-03 14:25:42.37 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 1, unidirectionalConns = 0, inboundConns = 0, outboundConns = 1})
[34m[hud-PS:cardano.node.PeerSelectionActions:Info:158][0m [2022-11-03 14:25:42.37 UTC] PeerStatusChanged (ColdToWarm (Just 192.168.1.129:42787) 3.72.231.105:30000)
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.37 UTC] TracePromoteColdDone 50 1 3.72.231.105:30000
[34m[hud-PS:cardano.node.PeerSelectionCounters:Info:56][0m [2022-11-03 14:25:42.37 UTC] PeerSelectionCounters {coldPeers = 0, warmPeers = 1, hotPeers = 0}
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.37 UTC] TracePromoteWarmPeers 2 0 (fromList [3.72.231.105:30000])
[34m[hud-PS:cardano.node.InboundGovernor:Info:60][0m [2022-11-03 14:25:42.37 UTC] TrInboundGovernorCounters (InboundGovernorCounters {coldPeersRemote = 0, idlePeersRemote = 1, warmPeersRemote = 0, hotPeersRemote = 0})
[34m[hud-PS:cardano.node.PeerSelectionActions:Info:164][0m [2022-11-03 14:25:42.37 UTC] PeerStatusChanged (WarmToHot (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}))
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.37 UTC] TracePromoteWarmDone 2 1 3.72.231.105:30000
[34m[hud-PS:cardano.node.PeerSelectionCounters:Info:56][0m [2022-11-03 14:25:42.37 UTC] PeerSelectionCounters {coldPeers = 0, warmPeers = 0, hotPeers = 1}
[34m[hud-PS:cardano.node.PeerSelectionActions:Info:162][0m [2022-11-03 14:25:42.94 UTC] PeerStatusChanged (HotToCold (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}))
[34m[hud-PS:cardano.node.PeerSelection:Info:56][0m [2022-11-03 14:25:42.94 UTC] TraceDemoteAsynchronous (fromList [(3.72.231.105:30000,PeerCold)])
[34m[hud-PS:cardano.node.PeerSelectionCounters:Info:56][0m [2022-11-03 14:25:42.94 UTC] PeerSelectionCounters {coldPeers = 1, warmPeers = 0, hotPeers = 0}
[34m[hud-PS:cardano.node.InboundGovernor:Info:60][0m [2022-11-03 14:25:42.94 UTC] TrMuxErrored (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}) (HeaderError (At (Block {blockPointSlot = SlotNo 86400, blockPointHash = c971bfb21d2732457f9febf79d9b02b20b9a3bef12c561a78b818bcb8b35a574})) (HeaderProtocolError (HardForkValidationErrFromEra S (Z (WrapValidationErr {unwrapValidationErr = ChainTransitionError [OverlayFailure (VRFKeyBadNonce (Nonce "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") (SlotNo 86400) (Nonce "90c8bae45d3cb34ef25d84171a74f6e8a4a8f4615fbe289d5a1b21eb6896ac0b") (CertifiedVRF {certifiedOutput = OutputVRF {getOutputVRFBytes = "n\240\190\146\147\245\163\a\ETX{`\183%.\174\153\187\EOT]X\165!\213\186|\141:\161))*\SOH*\147\145\238\255\248\132?5X\179Re\236C%\SOH\178F\136\162\224\162\EMd\252q\207i\194]\174"}, certifiedProof = CertPraosVRF "=C\193CW\205\131\176\249A\248\199\231\165s\252\&6\ESC\135\STX\191\238!\ESC\215\173\177\165\159\149v\254\ESC\209\RS?\163+Z\152.{$n\CAN\ENQ\139\t\159\DC4sb\201\193\138\204C\225\228\232\181\183\198`\234>\217\172[z~\192\254\181\156\207\182G)\EOT"})),OverlayFailure (OcertFailure (InvalidKesSignatureOCERT 1 0 1 "Verification failed"))]})))) (Tip (SlotNo 79922) 3785f8aee4d2369be761572b877358eeb9351404354b97ef965240bdbd602378 (BlockNo 43)) (Tip (SlotNo 11802321) 666c3386466185c49d725d6a1e4ff65e8b26933c4236126cb4182c794d224577 (BlockNo 231597)))
[34m[hud-PS:cardano.node.ConnectionManager:Info:159][0m [2022-11-03 14:25:42.94 UTC] TrConnectionHandler (ConnectionId {localAddress = 192.168.1.129:42787, remoteAddress = 3.72.231.105:30000}) (TrError OutboundError (HeaderError (At (Block {blockPointSlot = SlotNo 86400, blockPointHash = c971bfb21d2732457f9febf79d9b02b20b9a3bef12c561a78b818bcb8b35a574})) (HeaderProtocolError (HardForkValidationErrFromEra S (Z (WrapValidationErr {unwrapValidationErr = ChainTransitionError [OverlayFailure (VRFKeyBadNonce (Nonce "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") (SlotNo 86400) (Nonce "90c8bae45d3cb34ef25d84171a74f6e8a4a8f4615fbe289d5a1b21eb6896ac0b") (CertifiedVRF {certifiedOutput = OutputVRF {getOutputVRFBytes = "n\240\190\146\147\245\163\a\ETX{`\183%.\174\153\187\EOT]X\165!\213\186|\141:\161))*\SOH*\147\145\238\255\248\132?5X\179Re\236C%\SOH\178F\136\162\224\162\EMd\252q\207i\194]\174"}, certifiedProof = CertPraosVRF "=C\193CW\205\131\176\249A\248\199\231\165s\252\&6\ESC\135\STX\191\238!\ESC\215\173\177\165\159\149v\254\ESC\209\RS?\163+Z\152.{$n\CAN\ENQ\139\t\159\DC4sb\201\193\138\204C\225\228\232\181\183\198`\234>\217\172[z~\192\254\181\156\207\182G)\EOT"})),OverlayFailure (OcertFailure (InvalidKesSignatureOCERT 1 0 1 "Verification failed"))]})))) (Tip (SlotNo 79922) 3785f8aee4d2369be761572b877358eeb9351404354b97ef965240bdbd602378 (BlockNo 43)) (Tip (SlotNo 11802321) 666c3386466185c49d725d6a1e4ff65e8b26933c4236126cb4182c794d224577 (BlockNo 231597))) ShutdownPeer)
[34m[hud-PS:cardano.node.ConnectionManager:Info:159][0m [2022-11-03 14:25:42.94 UTC] TrConnectionManagerCounters (ConnectionManagerCounters {fullDuplexConns = 0, duplexConns = 0, unidirectionalConns = 0, inboundConns = 0, outboundConns = 0})

and query-tip shows it is stuck at:
{
    "block": 43,
    "epoch": 3,
    "era": "Byron",
    "hash": "3785f8aee4d2369be761572b877358eeb9351404354b97ef965240bdbd602378",
    "slot": 79922,
    "syncProgress": "11.89"
}

How do I troubleshoot this?

Use config files from https://book.world.dev.cardano.org/environments.html for Pre-Production Testnet


text:
Cardano node sync suddenly stopped at 97.79 %
My cardano node was 100% synced and it is running in production environment. But suddenly I am seeing that my cardano node block get backed and sync percent is 97.78%.
Error log:
[ip-30-0-:cardano.node.DnsSubscription:Error:9719] [2022-11-03 15:48:30.76 UTC] Domain: "relays-new.cardano-mainnet.iohk.io" Application Exception: 3.130.47.105:3001 MuxError MuxBearerClosed "<socket: 38> closed when reading data, waiting on next header True"
[ip-30-0-:cardano.node.ErrorPolicy:Warning:4967] [2022-11-03 15:48:30.76 UTC] IP 3.130.47.105:3001 ErrorPolicySuspendPeer (Just (ApplicationExceptionTrace (MuxError MuxBearerClosed "<socket: 38> closed when reading data, waiting on next header True"))) 20s 20s
[ip-30-0-:cardano.node.DnsSubscription:Error:9716] [2022-11-03 15:48:30.97 UTC] Domain: "relays-new.cardano-mainnet.iohk.io" Application Exception: 54.250.21.52:3001 MuxError MuxBearerClosed "<socket: 35> closed when reading data, waiting on next header True"
[ip-30-0-:cardano.node.ErrorPolicy:Warning:4967] [2022-11-03 15:48:30.97 UTC] IP 54.250.21.52:3001 ErrorPolicySuspendPeer (Just (ApplicationExceptionTrace (MuxError MuxBearerClosed "<socket: 35> closed when reading data, waiting on next header True"))) 20s 20s

What you posted is unlikely to be the actual cause of the halt, because its messages that a normal running node also gets. What version of the node are you running?

Recently, pre-production environment was re-spun (check "build-announcements" in IOG's Technical Community discord), I would suggest you to delete your db folder and use latest configuration from here.

I have downloaded latest cardano node and install it with latest config file. Now it is synced.


text:
When multiple users try to spend the same output at the same time, who will get priority?
Let's assume we have some NFT minting drop with more than 1000s of participating buyers who try to spend the same output, all at the same time. How does the chain decide who gets to spend the output? Is it first-in (the buyer who submitted the tx first), completely random, or something else?

The first transaction who makes it into the mempool will be the one spending the output.
And in case there is congestion on the blockchain and multiple transactions make it into different mempools (on different nodes), the one who is adopted in a block first will be the one spending the UTxO.

@George-APEXStakePool So as long as each person submits around the same time of a new block being minted, it's basically random which out of all the txs in the mempool will be included on-chain?

Not quite random, the first transaction that enters the mempool of the block producer chosen to create the next slot will win, Its not quite random, but it will effectively look like its random.

Stake Pool Operators can figure out which future slot in the current epoch they are due to mint, but if you are not an SPO you will not be able to figure out which SP is next to mint a block.

@George-APEXStakePool I think you should answer the question with what you said in this comment, for future references.

The first transaction who makes it into the mempool will be the one spending the output. And in case there is congestion on the blockchain and multiple transactions make it into different mempools (on different nodes), the one who is adopted in a block first will be the one spending the UTxO.


text:
Error Minting Native Asset: " unexpected '.', expecting space, letter or digit, white space, "+" or end of input "
I am writing a script to automate minting native assets. Everything works well, up until this point:
echo "Building transaction..."
cardano-cli transaction build \
            --babbage-era \
            $NETWORK \
            --tx-in $txhash#$txix \
            --tx-out $address+$output+"$tokenamount $policyid.$tokenhash" \
            --mint "$tokenamount $policyid.$tokenhash" \
            --minting-script-file "$tokenname"/policy/policy.script \
            --change-address $address \
            --out-file "$tokenname"/tx.build;

but every time I run the script, I get this error for "--tx-out":
Building transaction...
option --tx-out:
unexpected '.'
expecting space, letter or digit, white space, "+" or end of input

I followed the official Cardano documentation for how to format the command, but for some reason the 'dot' between $policyid and $tokenhash is giving issues.
Is there something I'm missing? I know the documentation can be notoriously out of date, but nothing I've found online and elsewhere has helped so far.

have you tried substituting the variables with actual values? Could possibly be caused by empty value in one of the variables on tx-out line

Try echoing all those evnvironment variables to make sure none of the have a . character.

Okay, tried the suggestions, now the error I'm getting "Command failed: transaction build  Error: The script language SimpleScriptLanguage SimpleScriptV1 is not supported in the Babbage era."


text:
Error occurs in simple request to blockfrost.io for multiple wallets
This is a screenshot of console log for my problem
    export const deriveStakeAddress = async ( rewardAddress: string ):
       Promise<string> => {

           const endPoint = `addresses/${rewardAddress}`;
           const request: string = 'https://cardano-mainnet.blockfrost.io/api/v0/' + endPoint
           console.log("Request:", request);
           const response = await fetch(request, {
             //@ts-ignore
             headers: {
                "Content-Type": "application/json",
                 project_id: process.env.REACT_APP_BLOCKFROST_KEY
             },
             method: "GET",
          });
          const result = await response.json();
          console.log("Stake address: ", result);
          return result.stake_address;
       };

    export const findAssets = async (networkId: number, stakeAddress: string) =>
         {

          const endPoint = `accounts/${stakeAddress}/addresses/assets`;
          const request: string = 'https://cardano-mainnet.blockfrost.io/api/v0/' + endPoint;
          console.log("Request:", request);
          const response = await fetch(request, {
             //@ts-ignore
             headers: {
                "Content-Type": "application/json",
                 project_id: process.env.REACT_APP_BLOCKFROST_KEY
             },
             method: "GET",
          });
          const result = await response.json();
          console.log("Assets: ", result);
          return result;
    };

And then I called above functions as following.
const walletAddress: string = 'addr1qxzpuc....6vexzc';
const stakeAddress: string = await deriveStakeAddress( walletAddress );
const assets = await findAssets( stakeAddress );

But I faced errors for some wallets such as Yoroi, Eternl.
On the other hand, there was no errors for Nami wallet. (here)

The first error happens because there are no transactions for the address you try to query on the blockchain. If the address was never used, this endpoint returns a 404 error.
The second error seems to happen because you pass in 'undefined' instead of an actual stake key when building the URL.


text:
How To Verify The Code Of A SmartContract?
There's a lot of talk about open-source code on Cardano, but how can I verify that the SmartContract(s) in a git repo are the actual SmartContracts the project has deployed to the Blockchain?
I want to know this for two reasons:

Make sure I'm not staking my ADA in a SmartContract that looks perfect on GitHub, but has a backdoor (to steal my ADA) onchain.

So other people can verify my code

Can I do this using the Cardano Node from the Ubuntu CLI?

You do not need the node, you need GHC and some plutus dependencies to compile it. Do you have a source that you want to check?

No, I got it just thought, it might be a good question to have on here for new learners. For some reason theres not really an easy way in for new guys yet, but it has gotten a lot better

Have you deployed the smart contract?

I have quite a few smart contracts deployed, but this is a general question, not targeting any particular SC.

You compile the code yourself to see if the address you arrive at aligns with what's live.

I know this is the correct answer but on the other hand I understand this is also not acceptable for the standard user and it sucks compared to other blockchains.

Well you can always trust a block explorer with such features like etherscan(or other centralised/trusted data providers) to feed you the truth, like other blockchains do.

This might be a pay-to-verify service later on. Who knows but it would really help build trust.


text:
Is cardano-cli 1.35.3's calculate-min-required-utxo underestimating?
For minting a token, I compute the minimum amount as follows:
cardano-cli transaction calculate-min-required-utxo
  --babbage-era
  --protocol-params-file protocol-parameters.json
  --tx-out "addr_test⋯pxzl 2000000 + 1 019b⋯55f5.766963"

This gives "Lovelace 1021470", which I'd plug into the --tx-out expression of the 'transaction build' command like this:
cardano-cli transaction build
  --testnet-magic 1
  --tx-in-collateral 3a0d⋯84af#3
  --tx-in 3a0d⋯84af#3
  --tx-in 616c⋯3486#1
  --tx-in f029⋯d21b#3
  --tx-out "addr_test⋯pxzl 1021470 + 1 019b⋯55f5.766963"
  --mint "1 019b⋯55f5.766963"
  --change-address addr_test⋯pxzl
  --protocol-params-file protocol-parameters.json
  --minting-script-file policy.script
  --out-file unsigned.json

But with cardano-cli 1.35.3, this gives me:
"Command failed: transaction build Error: Minimum UTxO threshold not met for tx output:
addr_test⋯pxzl + 1021470 lovelace + 1 019b⋯55f5.766963"
Minimum required UTxO: Lovelace 1344720

The above procedure used to work perfectly with older cardano-cli 's (last one tested: cardano-cli-1.34.1)
Question: Is cardano-cli 1.35.3's calculate-min-required-utxo underestimating, or is there a new way to compute the min-required-utxo?

You're using calculate-min-required-utxo  with --babbage-era flag and build without any era flag. cardano-node 1.34.3 defaults to Alonzo-era.
There appears to be a bug for overestimation in this scenario: https://github.com/input-output-hk/cardano-node/issues/4297
Use --babbage-era for both cmds.


text:
Decentralized Private Content Storage and Accessing
What would be the best way to store Private Video on chain, completely and only NFT holders should be able to access it
Like the video can be encrypted and stored on IPFS or STORG. Only the NFT holder should be able to decrypt and stream the video
How can we give access of decryption key to the NFT holder?
Here the problem is private encrypted content storage on decentralized infrastructure
And decryption key access to the NFT holder

Storing large data chunks (like video) on chain is always a bad idea. You should store in on something like IPFS and store the IPFS URL on chain.

The problem is that the NFT, while belonging to a wallet, is publicly visible to anyone on the internet. Therefore I think you need at least some small centralized server that stores your encryption keys.
A possible solution could look like this:

You create an NFT with an IPFS link to an encrypted video
The owner of the NFT connects a wallet to your website
The website makes a call to your (centralized) private server and asks for the key to decrypt the video stored on IPFS
Your server checks if the connected wallet has your NFT and sends the decryption key as a response
Now the video from IPFS can be decrypted by the user and viewed


text:
How to construct `TxOutRef`?
I am building an NFT minting policy which takes an argument of type TxOutRef as parameter. To this when I pass my parameter, it doesn't match with what is actually given in the transaction. Here is my policy:
Suppose my tx-in (in context of cardano-cli) is bccdfb39bcf97b9bc499ef19c02f33c64df1d7e68cfcff7f65a737c9c6ce4224#0. Then this is how I am passing it to compiler:
I tried comparing what I passed with what is actually received in my mkPolicy but surprisingly, if I remove out firstInput, it is able to print my error message, else with firstInput being present, I get the following in my console:

Following suggestion from here, I got it working by doing following modification:
As TxId has an instance for IsString derived via LegerBytes. In particular, this answer is also helpful.


text:
Developers are having dismal experience building on Cardano
When developers get into plutus playground, 10 out pf 10 expect it to work like remix, an IDE. You put a code in. You compile and deploy. And then start interacting with the dApp. All in the same window. If ready for production, you just connect the metamask and select the mainnet. It’s that easy.
Cardano has no comparable IDE. The closest thing is plutus playground, which is just a toy, not the real thing. There is no work flow from plutus playground to deploying, and interacting with the smart contract in the real blockchain. Worse, you have to write extra code just to test the damn thing off-chain. The code that is tested is not the code that is gonna be deploy. What is the point?
The possible/inconvenient work flow that I can imagine is:

write code and test (preliminary) in Plutus playground
serialize the code with some scripts to get a file, say: script.plutus
Real test: use script.plutus with cardano-cli to make transactions to test if the smart contract works as designed

And there are all sorts of problem along the way. For example:
In step 1, sometimes Plutus playground just can’t compile the code.
In step 2, developers run into all kinds of compatibility/dependencies issues.
On top of that developers has to run full cardano node, in order to submit test transaction through cardano-cli.
For companies with resources, they can develop custom in-house tooling for their work flow. But it is not easy at all for an individual developer trying to get into Cardano ecosystem.
And the forum like cardano.stackexchange.com or forum.cardano.org is not very helpful.
I see a lot of unanswered questions, especially those asked by beginners like me. I wish IOG or Emurgo take a more active role in these forums. Helping the beginners.

I agree, the development experience is currently a nightmare. It should be as easy as a simple npm/pip install of Plutus. Right now you need to allocate 50gbs of memory to just have Nix running on your system, and require a a 500 line cabal file to just compile your project... Until it becomes easy as the former it will not be very accessible to the average dev. Luckily there's already solutions being built like Helios and Aiken. These allow you to write contracts in a C-esk syntax way and you can easily compile and test them without requiring Blockfrost/running a full node.

Helios and Aiken. I will certainly check them out. I really want to make it work with plutus because it is kind of native language/environment and native things tend to have better performance. But at this point any alternative is a fair game.

Please checkout https://dquadrant.github.io/kuber/

also checkout: https://demeter.run/

Since this is not really a question, I'm gonna close it. Thanks for trying to get more awareness for this topic, I can only agree with your points. The discussion can be continued over in the Cardano Forum, where Adam made the same post: https://forum.cardano.org/t/developers-are-having-dismal-experience-building-on-cardano/110080


text:
NextJS build - Error: Cannot find module 'crypto'
I am facing this error when building nextjs app.

Error: Cannot find module 'crypto'
    at webpackEmptyContext (C:\Users\User\Desktop\my-project\app_name\packages\website\.next\server\chunks\648.js:9:10)
    at __wbg_require_6461b1e9a0d7c34a (C:\Users\User\Desktop\equine\dev-client-equine\packages\website\.next\server\chunks\8571.js:19424:109)
    at <rand_os::wasm32_bindgen::OsRng as rand_os::OsRngImpl>::new::h9c7a4b6a2b8ae92f (wasm://wasm/00a9b126:wasm-function[1724]:0x13a630)
    at rand_os::OsRng::new::he9ba4878a48d4dc5 (wasm://wasm/00a9b126:wasm-function[4526]:0x1bbe8c)
    at cardano_serialization_lib::crypto::Bip32PrivateKey::generate_ed25519_bip32::h0e42fd6e7efb4205 (wasm://wasm/00a9b126:wasm-function[1262]:0x117108)
    at bip32privatekey_generate_ed25519_bip32 (wasm://wasm/00a9b126:wasm-function[4677]:0x1c069e)
    at Function.generate_ed25519_bip32 (C:\Users\User\Desktop\my-project\app_name\packages\website\.next\server\chunks\8571.js:2163:83)
    at C:\Users\User\Desktop\my-project\app_name\packages\website\.next\server\chunks\648.js:4522:165 {
  type: 'Error',
  code: 'MODULE_NOT_FOUND'

My package.json dependencies:
 "dependencies": {
    "@apollo/client": "^3.6.9",
    "@emurgo/cardano-serialization-lib-browser": "^11.0.5",
    "@emurgo/cardano-serialization-lib-nodejs": "^11.1.0",
    "axios": "^0.27.2",
    "big-integer": "^1.6.51",
    "classnames": "^2.3.1",
    "cookie": "^0.5.0",
    "cookies-next": "^2.1.1",
    "formik": "^2.2.9",
    "graphql": "^16.6.0",
    "js-cookie": "^3.0.1",
    "next": "12.2.2",
    "react": "18.2.0",
    "react-cookie": "^4.1.1",
    "react-dom": "18.2.0",
    "react-modal": "^3.15.1",
    "react-responsive": "^9.0.0-beta.10",
    "react-youtube": "^9.0.3",
    "replace-in-file": "^6.3.5",
    "swiper": "^8.3.1",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@types/js-cookie": "^3.0.2",
    "@types/node": "18.0.3",
    "@types/react": "18.0.15",
    "@types/react-dom": "18.0.6",
    "@types/react-modal": "^3.13.1",
    "crypto": "^1.0.1",
    "eslint": "8.19.0",
    "eslint-config-next": "12.2.2",
    "jest": "^29.0.3",
    "next-intercept-stdout": "^1.0.1",
    "sass": "^1.53.0",
    "ts-jest": "^29.0.1",
    "typescript": "4.7.4"
  },

I installed crypto as devDependency to check if it will resolve issue. Failure.
I installed emurgo nodejs to check if it will resolve issue. Failure.

What guide are you running off of? Please post the link to the guide.

What do you mean by guide ?
I have the private api file(cant share), on React (create-react-app) project works fine, but for NextJS this happens.


text:
Error building in the latest Plutus Apps: Failed to build postgresql-libpq-0.9.4.3* Missing (or bad) C library: pq
Im having problems building my projects using the the latest plutus apps:
commit 33c6e81ba4ab9cbb42870bbb6f916f8b4e2c7b3e (HEAD -> main)
Starting     postgresql-libpq-0.9.4.3 (all, legacy fallback)

Failed to build postgresql-libpq-0.9.4.3. The failure occurred during the
configure step.
Build log (
/home/manuelpadilla/.cabal/logs/ghc-8.10.7/postgresql-libpq-0.9.4.3-57a09a91f3e131b3474d6ed3933505829ef2226dbf9a3540a78fc56124386c83.log
):
[1 of 1] Compiling Main             ( /home/manuelpadilla/source/copyRepos/RATS-DAO/rats-dao-devs-staking-plutus-v2/dist-newstyle/tmp/src-4327/postgresql-libpq-0.9.4.3/dist/setup/setup.hs, /home/manuelpadilla/source/copyRepos/RATS-DAO/rats-dao-devs-staking-plutus-v2/dist-newstyle/tmp/src-4327/postgresql-libpq-0.9.4.3/dist/setup/Main.o )
Linking /home/manuelpadilla/source/copyRepos/RATS-DAO/rats-dao-devs-staking-plutus-v2/dist-newstyle/tmp/src-4327/postgresql-libpq-0.9.4.3/dist/setup/setup ...
Configuring postgresql-libpq-0.9.4.3...
setup: Missing dependency on a foreign library:
* Missing (or bad) C library: pq
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

I installed all the postgresql libraries I believe I needed.
I installed:
> apt-cache policy postgresql
> postgresql:
      Installed: 15+244.pgdg20.04+1
      Candidate: 15+244.pgdg20.04+1
      Version table:
     *** 15+244.pgdg20.04+1 500
            500 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 Packages
            100 /var/lib/dpkg/status
         12+214ubuntu0.1 500
            500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
            500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
         12+214 500
            500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

> apt-cache policy libghc-postgresql-libpq-dev
> libghc-postgresql-libpq-dev:
          Installed: 0.9.4.2-1build1
          Candidate: 0.9.4.2-1build1
          Version table:
         *** 0.9.4.2-1build1 500
                500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
                100 /var/lib/dpkg/status

> apt-cache policy libpq5
> libpq5:
      Installed: 15.0-1.pgdg20.04+1
      Candidate: 15.0-1.pgdg20.04+1
      Version table:
     *** 15.0-1.pgdg20.04+1 500
            500 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 Packages
            100 /var/lib/dpkg/status
         12.12-0ubuntu0.20.04.1 500
            500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
            500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
         12.2-4 500
            500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

> apt-cache policy libpq-dev
> libpq-dev:
      Installed: 15.0-1.pgdg20.04+1
      Candidate: 15.0-1.pgdg20.04+1
      Version table:
     *** 15.0-1.pgdg20.04+1 500
            500 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 Packages
            100 /var/lib/dpkg/status
         12.12-0ubuntu0.20.04.1 500
            500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
            500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
         12.2-4 500
            500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

> apt-cache policy libc6
> libc6:
      Installed: 2.31-0ubuntu9.9
      Candidate: 2.31-0ubuntu9.9
      Version table:
     *** 2.31-0ubuntu9.9 500
            500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
            100 /var/lib/dpkg/status
         2.31-0ubuntu9.7 500
            500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
         2.31-0ubuntu9 500
            500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

> apt-cache policy libc6-dev
> libc6-dev:
      Installed: 2.31-0ubuntu9.9
      Candidate: 2.31-0ubuntu9.9
      Version table:
     *** 2.31-0ubuntu9.9 500
            500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
            100 /var/lib/dpkg/status
         2.31-0ubuntu9.7 500
            500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
         2.31-0ubuntu9 500
            500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

As you can see, the version of libghc-postgresql-libpq-dev is: 0.9.4.2-1build1
I couldn't find the 0.9.4.3. Could be this the problem? where I can have the right one?
The funny part is that I can build the same project without errors in a Bash Terminal, inside of the nix shell, but outside the Vcode.
But when after entering into the nix shell, I enter in VCode, with code ., and I try again to build from a VCode terminal, I got that error.
I believe it could be something about the paths, but I compare the PATHS in the Terminal, and in the VCode Terminal, and they are the same.
What could be the difference between a normal console where it works, and from the same console I open the Vcode, and then it dosent works.
With others versio of Plutus Apps the Nix shell works ok, and inside the Vcode, I can build normally.
I might be confused with the works of nix shell and code ..
Thanks a lot!

Do you have pkg-config installed? pkg-config --list-all | grep pq should return at least one entry.

pkg-config --list-all alone gave me some items, but no one with pq.
What could I do?

The pkg-config file for libpq is in the libpq-dev package.


text:
Problems with HLS with some versions of Plutus Apps: INFO hie-bios: error: cannot lock ref 'refs/remotes/origin/599'
I need some help with this problem.
With some version of Plutus Apps, HLS and VCode works perfect.
But with some specific versions, like this one:
commit cbc2df9e5d47d60505c28f321d75187d9ea85b07 (HEAD)

When HLS server starts, it throw and error with git from the Plutus Apps:
2022-11-09 17:18:26.921893854 [ThreadId 13] INFO hls:   Started LSP server in 0.00s
Couldn't load cradle (CradleNone)
2022-11-09 17:18:26.926139924 [ThreadId 13] INFO hls:   Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri 8157433327350195780 "file:///home/manuelpadilla/source/copyRepos/RATS-DAO/rats-dao-devs-staking-plutus-v2"], clientSettings = hashed Nothing}
2022-11-09 17:18:26.948609165 [ThreadId 69] INFO hls:   Consulting the cradle for "src/Validators/StakePlusV2/OffChain/EndPoints.hs"
2022-11-09 17:18:27.688350926 [ThreadId 111] INFO hie-bios: error: cannot lock ref 'refs/remotes/origin/599': 'refs/remotes/origin/599/marconi-cli-list-index' exists; cannot create 'refs/remotes/origin/599'
2022-11-09 17:18:27.689133924 [ThreadId 111] INFO hie-bios: From https://github.com/input-output-hk/plutus-apps
2022-11-09 17:18:27.68928638 [ThreadId 111] INFO hie-bios:   ! [new branch]          599        -> origin/599  (unable to update local ref)

Every else works fine, and I can build my project without problems.
But HLS is very helpful for coding and I appreciated a lot if I can use it.
This is a version of Plutus Apps that I can use reference scripts and Inline Datums.
I don't have this any of this issues with some previous versions neither.
Thank you so much!

Im editing this with something that fix that problem for me. I deleted the cache of hie-bios with:
cd $HOME/.cache/
sudo rm -R  hie-bios

Check more solutions here:
https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html


text:
Do we need to install a Virtual Machine to run a Cardano Node?
Why do we need Virtual Machine to run a Cardano Node/ Stake Pool?  Is it possible to run a Cardano Node without Virtual Machine?

Yes. My favorite way is to run it with docker.

LOXE currently runs KVM for its stake pool.

You do not need to, but you can if you want. It is perfectly possible to run a node / stake pool outside of a VM.

Perfect! thank you!


text:
ELI5 Explain native assets at higher level?
Is anyone capable of providing a high-level explanation of how NFT works in Cardano from a traditional blockchain point of view (ERC721, Ethereum, Solana, NEAR, etc), as I'd be very interested in understanding enough to decide going forward with Cardano for a project?
I've read the https://developers.cardano.org/docs/native-tokens/minting-nfts and believe that I understood a bit of it, but got a few questions.

The Policy ID can be used to identify a collection of native assets (NFT)? E.g. I can query the blockchain and find every single native asset by Policy ID?
The amount field* for the Policy ID has to be defined, there can't be unlimited supply?
Policy time locking, how to determine amount of slots in terms of time? Can be average, I guess the slots are computed so depends on the blockchain usage?!
The Policy ID signature is the mint-authority/controller/admin "wallet address"?
Does a Policy ID allow us to set multiple signatures (mint-authorities/controller/admin)? Guess that's what the https://github.com/input-output-hk/cardano-node/blob/c6b574229f76627a058a7e559599d2fc3f40575d/doc/reference/simple-scripts.md is for where keyHash is the wallet address and the type "sig" as in "signature"?

Thank you!

ELI5 for Native Assets from a traditional blockchain point of view (ERC721, Ethereum, Solana, NEAR, etc):
Native Assets are like Pokemon cards: All the needed information and features pertaining to the asset is directly on the individual card and can be interacted with freely.
ERC-standard tokens(eg. ERC-721) are like Pokemon game cartridges for GBA: There's a minimum information available on the cartridge casing but it is completely useless unless you plug it into a GBA console. The GBA console is needed to interact with the cartridge and everything it offers. The GBA console is to the cartridge what the EVM is to ERC-standard tokens (which are not tokens but rather programs/smart contracts with balances and permissions).
Other things
Policy ID for Cardano Native Assets is similar to contract address for Ethereum ERC tokens

The Policy ID can be used to identify a collection of native assets (NFT)? E.g. I can query the blockchain and find every single native asset by Policy ID?

This is how much you want to mint in a given transaction, you can mint ad infinitum so long as you execute mint transactions via Native Scripts while the Policy is open OR via Plutus scripts per the logic.

The amount field* for the Policy ID has to be defined, there can't be unlimited supply?

A slot is currently = 1 second, isn't dependent on usage.

Policy time locking, how to determine amount of slots in terms of time? Can be average, I guess the slots are computed so depends on the blockchain usage?!

The Policy script signature is the Verification key hash of the mint-authority/controller/admin, so not wallet address. (Wallet address is derived from a different combination of keys).

The Policy ID signature is the mint-authority/controller/admin "wallet address"

Yes you can set multiple required signatures for a policy script.

Does a Policy ID allow us to set multiple signatures (mint-authorities/controller/admin)?

keyHash != wallet address. it is the hash of the verification keys. and yes "sig" means "signature"

for where keyHash is the wallet address and the type "sig" as in "signature"?


text:
How to get my stacking funds after to deregistrate on Ada
after creating my pool for 2 weeks on Cardano, I would like to take the funds back to finish my tests.
But after the deregistration, I still don't see my funds in my payment address.
I was wondering if I have another command line to type to get this back.
These were the command lines that I typed for the deregistration:
cardano-cli transaction build \
    --mainnet \
    --witness-override 2 \
    --tx-in 738b285d278eb2b0df231b1376d41991508c85a2b76407209a0b6cdc493f1847#0 \
    --change-address addr1q8lyynej6uprzj2ty7fpk4azfp07fc5n4emtwcszzecrl8zag54tt8pagr3nnk3verl9k47jsqmrahw4z53hftwye53ssztqtp \
    --certificate-file pool-deregistration.cert \
    --out-file tx.raw

cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file cold.skey \
    --mainnet \
    --out-file tx.signed

cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet

After getting a successful message about this, I waited until epoch 374.
Now I can see here, my pool is expired but I have not received my 500 ADA.
I didn't find any documentation about it, how can I get this fund back? Do we have a command line for this?
Thank you to anyone who can help me.
NEW EDIT
Actually, I can't see exactly the same thing on the Cardano doc maybe it could help somebody else here. So I have to deregistrate my stack account too.
We have to generate the file here:
cardano-cli stake-address deregistration-certificate \
--stake-verification-key-file stake.vkey \
--out-file stake-deregistration.cert

And I'm trying to proceed to the transaction here:
cardano-cli transaction build \
    --tx-in 75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386#0 \
    --tx-out $(cat stake.addr)+500000000 \
    --change-address $(cat stake.addr) \
    --mainnet  \
    --out-file tx.raw \
    --certificate-file stake-deregistration.cert \
    --witness-override 2

cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --mainnet \
    --out-file tx.signed

cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet

As you can see here my reward is available but I have this message after to submit my transaction :
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [DelegsFailure (DelplFailure (DelegFailure (StakeKeyNonZeroAccountBalanceDELEG (Just (Coin 500000000)))))])

PoolDeposit (500 ADA on mainnet) is returned automatically upon pool deregistration at corresponding epoch to your stake address, as long as your stake account is not deregistered, while keyDeposit (2 ADA) is returned upon key deregistration.
You already have them on your stake account (see here )
PS: There are preprod and preview networks to learn, dont need to test on mainnet chain

Thank you for your response, but I don't see anything about how to deregister my stack account. Do we have a link for this or a command line?

Pretty much the same as you registered, except you will now use deregistration-certificate instead of registration-certificate

Thanks for your help, I just edited the post because I'm block with the transaction now

IMO - it's best to revert the post to original and maybe raise a seperate thread for tx creation assistance, your new issue is that you dont have any funds on tx in that you're using, you need to specify valid transaction input that isn't empty

You're right, thank you for everything


text:
Transaction error from staking account on cardano
I'm trying to get back my funds from my stake.addr from Cardano but I have this error message:
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [DelegsFailure (DelplFailure (DelegFailure (StakeKeyNonZeroAccountBalanceDELEG (Just (Coin 500000000)))))])

This error message appears when I run these scripts below:
cardano-cli stake-address deregistration-certificate \
--stake-verification-key-file stake.vkey \
--out-file stake-deregistration.cert

cardano-cli transaction build \
    --tx-in 75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386#0 \
    --tx-out $(cat stake.addr)+500000000 \
    --change-address $(cat stake.addr) \
    --mainnet  \
    --out-file tx.raw \
    --certificate-file stake-deregistration.cert \
    --witness-override 2

cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --mainnet \
    --out-file tx.signed

cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet

I can see I have the funds on the explorer here. Thank you if you can help me.

You have 500 ADA rewards at that stake address. First you need to withdraw the 500 ADA, only after that you should deregister your stake key.
You cannot send funds to a stake address, so you cannot use the stake-address in a --tx-out or --change-address line. And if you want to send all the funds to a single address, you just use --change-address, without any --tx-out line. You need to have your payment address in the payment.addr file, but I believe you already have it, since you are signing with payment.skey.
cardano-cli transaction build \
    --tx-in 75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386#0 \
    --withdrawal "$(stake.addr)+500000000" \
    --change-address $(cat payment.addr) \
    --mainnet  \
    --out-file tx.raw \
    --witness-override 2

Then sign it and submit it with the commands you had in your message.
After the transactions completes, you can do another transaction to deregister the stake key, just like you did before. You will need to use a different UTxO as input for the new transaction (because the one from the first transaction will be consumed). You will be able to use the output of your previous transaction.
cardano-cli transaction build \
    --tx-in <new UTxO>#0 \
    --change-address $(cat payment.addr) \
    --certificate-file stake-deregistration.cert \
    --mainnet  \
    --out-file tx.raw \
    --witness-override 2

You can sign and submit this transaction with the same commands as before.
It might work to withdraw the 500 ADA and deregister in a single transaction, but I did not test it, so I cannot recommend it. I will test it on testnet when I have the chance to do it (but not very soon). To test it, I will add the --certificate-file stake-deregistration.cert  line after the --change-address $(cat payment.addr) line in the first transaction.
I am not sure if you are able to deregister the stake address without first withdrawing the rewards. This is probably the reason why you have that error.

Thank you so much it worked. Really appreciate. I think Cardano should at least create a section for this it's very important.


text:
Running db-sync on a separate machine from node on same LAN
I currently have cardano-node and db-sync running on the same machine. The machine has a max RAM capacity of 32 GB and this is barely enough. Instead of buying a new machine that supports 64 GB RAM, I could use another machine I have of 32 GB RAM, to run only db-sync, on the same LAN as cardano-node.
I'd like to hear from anyone that has run cardano-node and db-sync both on the same machine as well as on different machines on the same LAN to see if you decided it had to be both cardano-node and db-sync on the same machine because on separate machines proved too slow?

Yes, you can do it. Run cardano-node on one of the machines and cardano-db-sync on the other, and use socat to connect from the cardano-db-sync machine to the cardano-node's socket file. This is how I am doing it.

Thank you. A machine that supports 64 GB RAM is more expensive than many that only support up to 32 GB, so this being an option - using socat, is a great option. I will try it too. Right now I am running without issue since using the  --disable-ledger option at db-sync startup as suggested by RdLrT.

Is it fairly straightforward to use socat for this purpose?
I have 2 machines, both with 32 GB RAM, both on the LAN, both running Ubuntu with cardano-node and cardano-db-sync installed and ready to be launched.

Yes, it is very simple.On the machine where the cardano-node is running, you run this:
/usr/bin/socat TCP-LISTEN:3081,reuseaddr,fork UNIX-connect:/path/to/your/node.socket
On the machine with the cardano-db-sync, you run:
socat UNIX-LISTEN:/run/cardano-node.socket,fork,reuseaddr,unlink-early,user=<your_user>,group=<your_group>,mode=755 TCP:<cardano-node-ip>:3081
And you will have your socket as /run/cardano-node.socket (you can set any path you like). Use the user and the group you are running cardano-db-sync with. You can also use any port you want.

Thank you for these detailed instructions! Very helpful!

A very big chunk of memory usage for dbsync comes from ledger-state - you can disable this component if you do not require things like epoch_stake, ada_pots, etc.
You can read more about it here.
If you do require these, 48GB RAM IMO is bar minimum, and 64GB is ideal (for instance, if you optimise Postgres configurations to serve more processing capacity and less IO dependency)

Was not aware of those options, I shall examine that, ty!

"migrating to a no ledger schema"
was reported after relaunching db-sync with the --disable-ledger flag added!

Appears to work like a charm @RdLrt = thank you!

That is excellent advice mate. Absolutely beautiful!!!

I am doing this and the memory usage is MUCH less - thank you.

I'm running cardano-db-sync on the same machine of cardano-node. The machine is also a block-producer (--nonmoving-gc), cardano-wallet provider, cncli sendtip provider. The amount of RAM needed ended up to be 64GB.
The main reason driving me to host everything on the same machine is that it's a virtual machine that I can fine-tune whenever I want.
Also, you should consider this: cardano-db-sync needs a --socket-path path specified. That means that you can't straightforwardly run cardano-node and cardano-db-sync on different machines. You can probably play around with netcat to redirect I/O to/from the socket to/from a TCP socket, or mount remotely the path where the socket is located.

Thank you - so far the clear winner is still "use a machine that has 64 GB of RAM"


text:
Can't use PlutusTx.Foldable from other module
I want to write a PlutusTx validator which just checks if a transaction was signed by one of the whitelisted public keys.
This would be a first, naiive implementation:
-- | The whitelist used by 'signedByOneOfWhitelist'.
whitelist :: [PubKeyHash]
whitelist = []

-- | Check whether a transaction was signed by one of the 'whitelist' keys.
{-# INLINEABLE signedByOneOfWhitelist #-}
signedByOneOfWhitelist :: ScriptContext -> Bool
signedByOneOfWhitelist context =
  any (`elem` whitelist) txInfoSignatories
 where
  TxInfo{txInfoSignatories} = txInfo

  ScriptContext{scriptContextTxInfo = txInfo} = context

This works fine if I put this next to my validator / in the same module as `$$compile.
However, if I want to make this re-usable and put it into a dedicated module, say Whitelist with the right imports import Whitelist (signedByOneOfWhitelist) I get the following error by the plutus-tx compiler:
GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable Whitelist.$s$fFoldable[]_$cfoldMap
            No unfolding

Full gist for context: https://gist.github.com/ch1bo/a248087241a0a1690fba41936da45bc9
What am I doing wrong?

A workaround is to not use Foldable by instantiating it and an explicit fold:
{-# INLINEABLE signedByOneOfWhitelist #-}
signedByOneOfWhitelist :: ScriptContext -> Bool
signedByOneOfWhitelist context =
  myAny (`myElem` whitelist) txInfoSignatories
 where
  myAny :: (a -> Bool) -> [a] -> Bool
  myAny fn = \case
    [] -> False
    (x : xs)
      | fn x -> True
      | otherwise -> myAny fn xs

  myElem :: Eq a => a -> [a] -> Bool
  myElem x = myAny (x ==)

  TxInfo{txInfoSignatories} = txInfo

  ScriptContext{scriptContextTxInfo = txInfo} = context

I do not think you do anything wrong. I expected to "resolve" this issue by either inlining whitelist, manually marking it INLINEABLE or enabling -fexpose-all-unfoldings. But none of the above worked. I then took a close look at the PLC output and saw explicit references to
Whitelist.$s$fFoldable[]_$cfoldMap

And thought that this is odd, since it seems like it is trying to reference a foldMap implementation from the Whitelist module itself, which of course does not exist. So I went ahead and added an import:
import Data.Foldable (foldMap)

GHC marks this import as redundant, but the PLC plugin does not complain anymore... and it seems to work. I did not test it rigorously though, so take this with a grain of salt.


text:
How are the Project Catalyst Voting Rewards calculated?
How are the Project Catalyst Voting Rewards calculated? What is the equation? Where is it documented?


text:
Error when unpacking snapshot to bootstrap Cardano node by using Mithril
I'm trying to bootstrap a Cardano node on preview network by using Mithril follow this instruction:
https://mithril.network/doc/manual/getting-started/bootstrap-cardano-node/
In step "Restore Selected Snapshot", I had a problem after downloading c9839be0355587c4a9a3bcff4a5285001b12e2f2b7ea3ac38bb2dc1ab25d3baf snapshot.

Then I used all snapshots are listed but it still had encountered the above error.
Please let me know how can I fix it?

You are probably using a wrong aggregator endpoint. In order to make the restoration work, please use the following endpoints:

Cardano preprod network: https://aggregator.release-preprod.api.mithril.network/aggregator
Cardano preview network: https://aggregator.pre-release-preview.api.mithril.network/aggregator

The Mithril networks configurations are also available in our documentation website at https://mithril.network/doc/manual/developer-docs/references#mithril-networks


text:
What is native assets, Also Not able to send my ADA from Exodus Wallet
My name is Adam gil and I am crypto follower. I have been using Cardano from past few months. Recently I tried to send my ADA from Exodus wallet. I have 4600 ADA in my Exodus wallet.
The Issue - When I try to send my ADA, it is allowing me to send 0.776781 ADA and than it displays message saying “Transaction amount is too small to send”.
Next it shows a second message like - “Needed for holding ADA native tokens:1.666665ADA”
Tried multiple times and also by refreshing the system but it doesn't help.
Please help me to understand - what this Native Token is and where I get them?
If you need wallet address I can share in next message.
Thanks in advance.

There is a minimum amount that can be held at a UTxO, see https://docs.cardano.org/native-tokens/minimum-ada-value-requirement.
I guess you have at least one cardano-native token in your wallet, perhaps you traded for one? If Exodus does not show this you can search your wallet address in an explorer such as https://cardanoscan.io/ to see your token balance.
Basically, you have to send more as to satisfy the network minUtxo constraint.

Got it. Thanks!