text:
Decompiling Plutus Core Binary Encoding
I'm working with Plutus Core smart contracts, and I have the binary encoding of a Plutus Core script. I'm curious to explore the higher-level Plutus code or any human-readable representation of the script. Does anyone have insights on how to decompile or disassemble the binary encoding back into untyped Plutus code or something higher-level than bytecode?
I appreciate any guidance or recommendations on tools, techniques, or resources that can assist in this process.
Thank you!

I see you used the plu-ts tag, I assume you are working with it.
plu-ts re-exports the @harmoniclabs/uplc module](https://github.com/harmoniclabs/uplc/) as is.
so you have it already with plu-ts
as you can read from the uplc module readme, there are functionalities to parse the bytes of the contract and print a prettified uplc textual form
this is the example reported in the package
import { fromHex } from "@harmoniclabs/uint8array-utils";
import { parseUPLC, prettyUPLC } from "@harmoniclabs/uplc";

const serialized: Uint8Array = fromHex( "0100003233700900219b8248050005200801" );

const program = parseUPLC( serialized, "flat" );

console.log(
    prettyUPLC(
        program.body, // UPLCTerm
        4 // indentation spaces
    )
);
/*
expected output:

[
    (lam a
        [
            [
                (builtin addInteger)
                (con integer 2)
            ]
            [
                [
                    (builtin multiplyInteger)
                    (con integer 10)
                ]
                a
            ]
        ]
    )
    (con integer 4)
]

*/

you probably don't need to specify "flat" as second argument of parseUPlC  as I assume you are working with cbor.
have fun

It will depend on the format used. I'll give an example of converting the text envelope file format used by cardano-cli into PlutusIR. The text envelope contains the plutus flat binary format that is double-wrapped in cbor hex format.
This is the example text envelope script json file:
{ "type": "PlutusScriptV2",
  "description": "",
  "cborHex": "[encoded data, 4194 characters]"}

Extract the cborHex value to a new file "cbor-script-file".
Remove the cbor headers (first 6 bytes). The value now starts with 10000 indicating the plutus compiler version used (1.0.0).
Convert this to binary format and write to a new file by running cat cbor-script-file | xxd -r -p > binary-script-file
Run the follow cmd from the plutus repo to convert to PlutusIR format (executable is available in nix shell) cabal run uplc convert -- --if flat -i binary-script-file

The PlutusIR output looks like
(program
  1.0.0
  [
  (lam
    i_0
    [
      (lam
        i_1
        [
          (lam
            i_2
            ...


text:
How to obtain signature from the cborhex? If i have simple-tx.signed
{
    "type": "Witnessed Tx BabbageEra",
    "description": "Ledger Cddl Format",
    "cborHex": "84a3008182582088921ae2626e"
}

This is just an example

Is that the output from an actual file? The hex is not valid CBOR.

First off, when analyzing CBOR data, cbor.me is your friend. Paste in the CBOR hex string and let it show you the structure.
In the witness files that I've worked with, the structure is as follows:
82                           # array(2)
  00                         # unsigned(0)
  82                         # array(2)
    58 20                    # bytes(32)
      71...60                # <- This is the vkey bytes
    58 40                    # bytes(64)
      6C...0F                # <- This is the signature bytes

source: Stack Exchange

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

sort: votes


text:
Failed to build atlas examples with cabal
I tried both in the main branch and in the atlas-0.3-update branch and get the same result. but when i run cabal build i get the same error fatal: Could not parse object 'c30d0de6875d75edd64d1aac2272886528bc492d'.
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/servant-o_-d7933ffd24e60785'...
remote: Enumerating objects: 1757, done.
remote: Counting objects: 100% (357/357), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 1757 (delta 320), reused 321 (delta 299), pack-reused 1400
Receiving objects: 100% (1757/1757), 385.48 KiB | 1.68 MiB/s, done.
Resolving deltas: 100% (818/818), done.
HEAD is now at 4165b83 Allow lens-aeson 1.2 (#27)
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/blockfros_-88bd16c71266eeaf'...
remote: Enumerating objects: 1524, done.
remote: Counting objects: 100% (70/70), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 1524 (delta 35), reused 28 (delta 23), pack-reused 1454
Receiving objects: 100% (1524/1524), 264.98 KiB | 1.11 MiB/s, done.
Resolving deltas: 100% (1025/1025), done.
HEAD is now at 206e1a0 Merge pull request #39 from blockfrost/release/api-0.8.1
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/atlas-bc9347bbf4453d47'...
remote: Enumerating objects: 3615, done.
remote: Counting objects: 100% (1258/1258), done.
remote: Compressing objects: 100% (458/458), done.
remote: Total 3615 (delta 802), reused 1048 (delta 689), pack-reused 2357
Receiving objects: 100% (3615/3615), 986.51 KiB | 3.29 MiB/s, done.
Resolving deltas: 100% (2122/2122), done.
HEAD is now at e98e072 Merge pull request #235 from geniusyield/196-no-separate-change-output-for-fee-over-approximation
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/plutus-si_-405d5a8470902f38'...
remote: Enumerating objects: 3780, done.
remote: Counting objects: 100% (455/455), done.
remote: Compressing objects: 100% (189/189), done.
remote: Total 3780 (delta 213), reused 419 (delta 193), pack-reused 3325
Receiving objects: 100% (3780/3780), 776.16 KiB | 2.10 MiB/s, done.
Resolving deltas: 100% (1895/1895), done.
HEAD is now at 0cb63af Added function to know output references at a payment credential
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/bech32-b0701c420aaaffda'...
remote: Enumerating objects: 3973, done.
remote: Counting objects: 100% (232/232), done.
remote: Compressing objects: 100% (88/88), done.
remote: Total 3973 (delta 146), reused 188 (delta 124), pack-reused 3741
Receiving objects: 100% (3973/3973), 12.37 MiB | 13.76 MiB/s, done.
Resolving deltas: 100% (2808/2808), done.
HEAD is now at e341e7f Bump copyright years. (#57)
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/cardano-a_-69e96f3eceed3ed5'...
remote: Enumerating objects: 21355, done.
remote: Counting objects: 100% (3108/3108), done.
remote: Compressing objects: 100% (776/776), done.
remote: Total 21355 (delta 2386), reused 2988 (delta 2286), pack-reused 18247
Receiving objects: 100% (21355/21355), 76.06 MiB | 20.55 MiB/s, done.
Resolving deltas: 100% (16643/16643), done.
HEAD is now at 6b55f96d Merge pull request #223 from input-output-hk/paweljakubas/mbo-preparation
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/cardano-s_-dd52ae23692dff9'...
remote: Enumerating objects: 313, done.
remote: Counting objects: 100% (167/167), done.
remote: Compressing objects: 100% (78/78), done.
remote: Total 313 (delta 64), reused 162 (delta 64), pack-reused 146
Receiving objects: 100% (313/313), 1.00 MiB | 3.09 MiB/s, done.
Resolving deltas: 100% (114/114), done.
HEAD is now at a91add1 update aeson v2
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/cardano-w_-c9e033b0ec7ad11b'...
remote: Enumerating objects: 295476, done.
remote: Counting objects: 100% (13988/13988), done.
remote: Compressing objects: 100% (5178/5178), done.
remote: Total 295476 (delta 7416), reused 12780 (delta 6485), pack-reused 281488
Receiving objects: 100% (295476/295476), 243.78 MiB | 27.35 MiB/s, done.
Resolving deltas: 100% (198692/198692), done.
HEAD is now at 3f0d2f3abe Release v2023-07-18 (#4046)
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/haskell-s_-e5692cba7ac918b3'...
remote: Enumerating objects: 1798, done.
remote: Counting objects: 100% (412/412), done.
remote: Compressing objects: 100% (198/198), done.
remote: Total 1798 (delta 179), reused 371 (delta 174), pack-reused 1386
Receiving objects: 100% (1798/1798), 279.41 KiB | 1.31 MiB/s, done.
Resolving deltas: 100% (994/994), done.
HEAD is now at 3c4efcc Merge branch 'main' into drop-v0
Cloning into '/home/cardano/projects/github/atlas-examples/dist-newstyle/src/openapi3-8b632f0d82841c8c'...
remote: Enumerating objects: 4264, done.
remote: Counting objects: 100% (318/318), done.
remote: Compressing objects: 100% (120/120), done.
remote: Total 4264 (delta 209), reused 256 (delta 164), pack-reused 3946
Receiving objects: 100% (4264/4264), 953.71 KiB | 3.08 MiB/s, done.
Resolving deltas: 100% (2080/2080), done.
fatal: Could not parse object 'c30d0de6875d75edd64d1aac2272886528bc492d'.

This commit was used due to dependency upon cardano-wallet library. Recently, it was updated on their end, consequently we had to update it as well, as in this PR.
Atlas should build well with latest commit of main. If you have trouble building it, then our CI file should help.
Unfortunately, atlas-examples repository isn't updated in sync with latest Atlas changes. Maybe you can help with it :)

I changed the tag and the sha of the opanapi3 repo as shown in the file changes of the PR you linked. however now i get a different set of errors. something Error: cabal: Could not resolve dependencies something about a version constraint caused the previous version to fail: excluded by constraint '^>=4.14.1.0' from 'atlas'). i would share with you the whole error but comments in stack exchange don't allow me to post the entire error.

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


text:
Examples of open source production level DApps on Cardano?
I am looking for Cardano DApps which are:

Actually deployed and used on mainnet
Have published their source code (at least on-chain part)

Examples of non-Plutus PL used (like Plutarch, Aiken, ...) are especially important to me.
I am interested in non Open Source projects as well, but I think it would make question too broad.

Plutarch team provided two examples for me:

https://github.com/Liqwid-Labs/agora/
https://github.com/mlabs-haskell/cardano-open-oracle-protocol


text:
How to build smart contract depending on trusted server for additional information
I am trying to build a smart contract that will need to rely on off-chain information from a trusted server in order to gather to the state of something which will impact on how the UTXO should be spent.
what is a strategy that i can use in order to have the on chain script make an some sort of http request to a trusted api server in order to get the status of something which can branch the decision of the on chain logic?
thanks for any suggestions.

Unfortunately, there is no way to make http calls from on-chain.
The only way to have off-chain information available on-chain is via transactions. Either the caller of the smart contract can bring the information with their transaction or the smart contract can reference data put on chain with previous transactions.
I'm guessing the latter is what you're looking for, what we call an "oracle". The data can be made available on the datum of some output (or "reference output") at another script address. You can make the updating of that data locked and only accessible by the "trusted" party's public key with a separate contract. Your smart contract can then reference the output that has the data on it.
There are additional ways you can customize this relationship, but that would be straying from your original question.
I hope that helps.


text:
Cardano Node Compiler Error libsodium Fedora
for some reason i'm unable to compile cabal projects related to cardano projects on this system. not sure what could of changed recently as aside from recent system updates i haven't changed much. or anything at all for that matter related to haskell or cardano development.
I first noticed it when i was unable to build the atlas examples. however now i'm getting this error even when trying to compile the cardano-node/cli repo by running the cabal build all command.
❯ cabal build all
Warning: Requested index-state 2023-07-21T13:00:00Z is newer than
'cardano-haskell-packages'! Falling back to older state
(2023-07-21T12:48:43Z).
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] next goal: cardano-cli (user goal)
[__0] rejecting: cardano-cli-8.3.2.0, cardano-cli-8.3.1.0,
cardano-cli-8.3.0.0, cardano-cli-8.2.1, cardano-cli-8.2.0 (constraint from
user target requires ==8.1.2)
[__0] trying: cardano-cli-8.1.2
[__1] trying: ouroboros-consensus-protocol-0.5.0.4 (dependency of cardano-cli)
[__2] trying: cardano-crypto-tests-2.1.2.0 (dependency of
ouroboros-consensus-protocol)
[__3] next goal: cardano-crypto-praos (dependency of cardano-crypto-tests)
[__3] rejecting: cardano-crypto-praos-2.1.2.0, cardano-crypto-praos-2.1.1.2,
cardano-crypto-praos-2.1.1.1, cardano-crypto-praos-2.1.1.0,
cardano-crypto-praos-2.1.0.0, cardano-crypto-praos-2.0.0.1,
cardano-crypto-praos-2.0.0.0.1, cardano-crypto-praos-2.0.0 (conflict:
pkg-config package libsodium-any, not found in the pkg-config database)
[__3] fail (backjumping, conflict set: cardano-crypto-praos,
cardano-crypto-tests)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: cardano-crypto-praos,
cardano-crypto-tests, ouroboros-consensus-protocol, cardano-cli
Try running with --minimize-conflict-set to improve the error message

versions of ghc / cabal and environment variables.
❯ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
❯ cabal --version
cabal-install version 3.6.2.1
compiled using version 3.6.2.0 of the Cabal library
❯ printenv | grep -i _path
LD_LIBRARY_PATH=/usr/local/lib
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
❯ pkg-config --list-all | grep -i libsodium
libsodium                      libsodium - A modern and easy-to-use crypto library
❯ tree /usr/local/lib
/usr/local/lib
├── libblst.a
├── libsecp256k1.a
├── libsecp256k1.la
├── libsecp256k1.so -> libsecp256k1.so.0.0.0
├── libsecp256k1.so.0 -> libsecp256k1.so.0.0.0
├── libsecp256k1.so.0.0.0
├── libsodium.a
├── libsodium.la
├── libsodium.so -> libsodium.so.23.3.0
├── libsodium.so.23 -> libsodium.so.23.3.0
├── libsodium.so.23.3.0
└── pkgconfig
    ├── libblst.pc
    ├── libsecp256k1.pc
    └── libsodium.pc

libsodium.pc
❯ cat /usr/local/lib/pkgconfig/libsodium.pc
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libsodium
Version: 1.0.18
Description: A modern and easy-to-use crypto library

Libs: -L${libdir} -lsodium
Libs.private:  -pthread
Cflags: -I${includedir}

Got it to compile successfully again. If you are using fedora 39 then you are going to be stuck using pkg-config version 1.9.5 (or at least that was the version i had at the time of this post) In the repos i wasn't able to downgrade or upgrade. so i went to the pkg-config repo where i was able to checkout the 2.0 tag and build, compile and install pkg-config. confirmed that the version was 2.0 and went back to the cardano-node repo and ran cabal build all and it is compiling successfully again. hope this is helpful to someone.


text:
pub-key hash for Plutus Pioneers - self-certification challenge
The entry form for the Plutus Pioneers - self-certification challenge reads as follows:

Please provide a Cardano public key hash

I am guessing this should be associated with a wallet.
In general I prefer to use a hardware wallet.
So my question is:
How can I get a pub-key hash from a hardware controlled wallet?
Much thanks

Found a great explanation of what the public key hash is:
https://discord.com/channels/826816523368005654/868025141668503582/1176250735986479115
Found one method of obtaining the public key hash from a wallet receiving address using mesh:
https://discord.com/channels/826816523368005654/868025141668503582/1178150850288431174
Found one method of obtaining the public key hash from a wallet receiving address using cardanoscan.io:
https://discord.com/channels/826816523368005654/868025141668503582/1176392536726720563
Much thanks to those contributors.


text:
stake pools - do they encourage centralisation?
Quote from cardano docs:

The higher is the stake in a pool, the more rewards will be assigned
to its owners.

Doesn't this mean that the bigger the pool is the more profitable it is and therefore it could lead to a small amount of stake pools (why someone would want to join smaller stake pool if it offers smaller profits?).

This is a complex topic, I'll try to explain it as simply as possible.
There is the so called "Saturation Parameter (K)". K is the desired number of active stake pools. From K the maximum amount of ADA delegated to one single pool is calculated. Once a pool exceeds the maximum amount of ADA, it will offer diminishing rewards. (Source https://cardano.org/stake-pool-operation/)
If there would be exactly K stake pools and all ADA would be delegated. All pools would have the maximum amount of ADA delegated (not too much). Therefore that would be the ideal scenario.
In practice, there are more than K stake pools. So the stake pool operators need to try to convince people to delegate to their pool. And you're right, many small pools struggle to get new delegators because people naturally tend to choose a pool that already has more stake delegated.
Recently the minimum fixed fee of stake pools has been decreases from 340 to 170 ADA to make the penalty of staking with a smaller pool less drastic for the delegators. However, this means even less rewards for the pool operators which might not be sustainable for them.
Please also have a look at this related question for more information.

Thanks for the related question. I have immediately asked myself about single entity maintaining multiple pools and the related question is very much about it.


text:
ADA locked on Trust - 2 delegations*( only one should be active ) - Now cant claim & reflects 2 balances
Good afternoon all
I recently unstaked or attempted to unstake ada & it looked as if it was going from 1 validator to another , my problem is everything is stuck now. I cannot claim , I cannot unstake ; I have almost 19500ada & 1 page shows me 16 rewards another shows 3 currently , I unstaked last December 4th received 7.45 & now when try says insuficient balance so I sent 33 ada to use & now all ada is stuck & refreshing shows 2 different amounts & this error message comes up.  stating invalid amounts & path I have tried claiming & unstaking from my both please advise I need my ada moved.

If you feel comfortable doing so, it would be easiest if you could post your address or stake key. This way members of this community could have a look at the blockchain and analyze what's going on. From your description it's hard to tell what exactly you have done and what could have gone wrong.


text:
I keep having issues with installing Cardano node on Mac mini2 with M2 processor
I have conflict involving the cardano-crypto-class package and its dependencies, particularly libblst and vector.
I have included the error code when using cabal build all or cabal build all  --minimize -conflict-set
Anyone had this issue and resolved it?
e@E-Mac-mini cardano-node % (cabal build all --minimize-conflict-set
)
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: cardano-node-8.7.2 (user goal)
[__1] trying: ouroboros-consensus-0.14.0.0 (dependency of cardano-node)
[__2] trying: cardano-ledger-binary-1.2.1.0 (dependency of
ouroboros-consensus)
[__3] trying: vector-0.13.1.0 (dependency of ouroboros-consensus)
[__4] next goal: cardano-crypto-class (dependency of cardano-node)
[__4] rejecting: cardano-crypto-class-2.1.4.0 (conflict: pkg-config package
libblst-any, not found in the pkg-config database)
[__4] rejecting: cardano-crypto-class-2.1.3.0 (conflict: vector==0.13.1.0,
cardano-crypto-class => vector<0.13)
[__4] skipping: cardano-crypto-class-2.1.2.0, cardano-crypto-class-2.1.1.0,
cardano-crypto-class-2.1.0.2, cardano-crypto-class-2.1.0.1,
cardano-crypto-class-2.1.0.0 (has the same characteristics that caused the
previous version to fail: excludes 'vector' version 0.13.1.0)
[__4] rejecting: cardano-crypto-class-2.0.0.1 (conflict: cardano-ledger-binary
=> cardano-crypto-class>=2.1)
[__4] skipping: cardano-crypto-class-2.0.0.0.1, cardano-crypto-class-2.0.0
(has the same characteristics that caused the previous version to fail:
excluded by constraint '>=2.1' from 'cardano-ledger-binary')
[__4] fail (backjumping, conflict set: cardano-crypto-class,
cardano-ledger-binary, cardano-node, vector)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: ouroboros-consensus, vector,
cardano-node, cardano-crypto-class, cardano-ledger-binary

There are instructions in the cardano-node repository for installing libblst.

I am having the same issues.  Were you successful in installing cardano-node?


text:
How is the hash of a stake pool metadata file calculated?
I know how to use the CLI to compute the hash of stake pool metadata file, what I'm not sure of is how the hash is actually computed. What hash algorithm is used? Is the file hashed as raw bytes? Pointers to the cardano-node source code where this is accomplished is also appreciated.

The hash algorithm is Blake2b 256 and it is calculated on the raw metadata bytes.
I do not know where it is in cardano-node, but in cardano-db-sync its calculated at https://github.com/input-output-hk/cardano-db-sync/blob/master/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/OffChain/Http.hs#L153


text:
Install after VM clone
Hi guys I have installed 3 nodes (2 relays + one full) in Vbox VMs on a box at home, in order to start my stake pool. After a while I did a mistake and erased my cardano-src folder on one of them. I then cloned one of the ok ones into a new VM. Since i think i saw when installing that the scripts were generating keys or certificates, do you think my copied node will have problems when connecting to the other ones ? Thanks!

only one way to find out, try it :)


text:
How does the cardano network handle network latency?
I read that when a node receives a block, the node verifies that the slot number is the current one.
If the slot changes every second, what if a block is generated by some node A, but some other node B does not receive that block in the same slot (caused by network latency)? Will that block be invalid for node B and not appended in its chain?
Is there any "network tolerance parameter" that allows for blocks from the last X (for example 5) slots to also be valid?
If this parameter exists, what is it set to?
If this parameter does not exist, how does the protocol solve this "fork"?
Edit: If this parameter does not exist, would it decrease security in some form?

It's even more robust than that. It uses consensus (see ouroboros praos paper for technical details) to identify the best chain. As long as the chain doesn't diverge more than 3k/f slots ((36 hours on mainnet), the system will accept a competing chain as a candidate.
In practice this means I might not receive your block for hours, and when I do, I can either adopt it and continue forging against your chain or discard it because I have a better chain already.


text:
Missing MissingVKeyWitnessesUTXOW when signing tx with PaymentSigningKeyShelley_ed25519 key
I'm trying to get skey PaymentSigningKeyShelley_ed25519 from PaymentExtendedSigningKeyShelley_ed25519_bip32.
Here is the extended key:
{
    "type": "PaymentExtendedSigningKeyShelley_ed25519_bip32",
    "description": "Payment Signing Key",
    "cborHex": "5880608550a89ba16a920b365e77131ba1c702d5d825025d1c91190992a6465df7545919c017426267e5a9eff84ecb35f3cdbb6701036141ade1cc3980c6166e741b1dbaa54ec25531278af95388ff2f96b5c986b33fc693ebfc3c17e050cbe57a7f62777711a09bd4b66522668489fbe3b7f61a0f89c8331b30399bc69bff604976"
}

and normal key:
{
      "type": "PaymentSigningKeyShelley_ed25519",
      "description": "Payment Signing Key",
      "cborHex": "5820608550a89ba16a920b365e77131ba1c702d5d825025d1c91190992a6465df754"
}

For address: addr_test1qr69yj887txwu7ca7s9g5lr6sm7p8sf4dac295g7c44rfvma6t5aw0lpzxyk4r0r9tpdmremh0g37nal3q8fhjy97xwqpu4d5c I can sign tx successfully using the extended key, but not using the normal key.
Here is the cardano-cli (v1.35.3) command I'm using:
cardano-cli transaction sign --tx-body-file tx.raw --signing-key-file payment.skey --testnet-magic 1 --out-file tx.signed

Does anyone knows what's wrong here?
Note: Using Bip32PrivateKey#to_raw_key() the result hex is 64 bytes instead of 32 from the origin key I shared. I was able to submit the tx using csl and 64 bytes from the extended key:
   static getPrivateKey(key: string): PrivateKey {
        if (key.startsWith('xprv1')) {
            return Bip32PrivateKey.from_bech32(key).to_raw_key();
        } else {
            const unhex = Buffer.from(key, 'hex');
            const decode = cbor.decode(unhex);
            try {
                return PrivateKey.from_normal_bytes(decode);
            } catch (err) {
                return PrivateKey.from_extended_bytes(decode);
            }
        }
    }

cborHex: '5840608550a89ba16a920b365e77131ba1c702d5d825025d1c91190992a6465df7545919c017426267e5a9eff84ecb35f3cdbb6701036141ade1cc3980c6166e741b'
cardano-cli isn't working with this 64 bytes version though.


text:
Installing cardano-node: pathspec 'null'
I'm following the instructions here for both Linux and Mac M2 chip...
Both installs are stopped at this instruction, with the following error:

~cardano-source/cardano-node$ git checkout $(curl -s https://api.github.com/repos/input-output-hk/cardano-node/releases/latest | jq -r .tag_name)
error: pathspec 'null' did not match any files(s) known to git
~cardano-source/cardano-node$

Since I don't see any similar queztions here at Stack... I'm guessing I did something wrong, but I don't see it.  Even after going through all the steps again.  Can someone with better eyes than me provide some insight?

This was the previous command >git fetch --all --recurse-submodules --tags

At any rate, git describe --tags seems to match the api doc at the url given; and git describe --tags | git checkout did it in both the mac and linux boxes.


text:
How to calculate the cardano network throughput?
I've been searching about the Cardano's network throughput in TPS and read in some place that is about 1000, in other place that is 250.
But when I try to actually calculate it using the average transaction size (613 Bytes) and the max block size (65536 Bytes) I get that a block can hold about 107 transactions, knowing that the activeSlotCoefficient is 0.05. I can conclude that the throughput is:
107 * 0.05 = 5.35 TPS
Which seems like I'm doing something wrong.
How do I actually calculate the throughput, and what am I doing wrong?


text:
What is each node key used for?
How many keys does a node need, and how are they used? How does each node know the keys of the other nodes? And how does every node know what (different kind of) keys come from the same node?

The blockchain nodes don't need keys.
Stake pools needs keys (the block producer nodes). They have a cold key, a VRF key, a KES key and an operational certificate. Stake pools also need a wallet for depositing the pledge and a wallet (can be the same, can be different) for receiving the rewards for minting blocks, hence they also need some payment and stake keys for this (these) wallet(s).
The stake pool keys (except the KES key) are known by other because they are registered on-chain (via transactions). The KES key will be known when a stake pool mints a block. Also, the KES key (and the operational certificate created with it) are renewed every 90 days (or less).

What is the operational used for? And is it a ECDSA key?

The KES key is ed25519. The operational certificate is a certificate, not a key, and it is created with both the KES key and the cold key (the cold key is also known as "Stake Pool Operator Signing Key").


text:
Golang libraries for communicating with the Cardano blockchain
Is there a reliable Golang library available for communicating with the Cardano blockchain or the blockchain within the Cardano network, and is it freely available for use?

Have you seen these?
https://pkg.go.dev/github.com/echovl/cardano-go
https://github.com/blinklabs-io/gouroboros
There is also the potential to use blockfrost in golang to access it as well. I have personally used this, and while limited, it is great to getting data.
https://github.com/blockfrost/blockfrost-go


text:
Create cardano transaction for wallet signing using Cardano Serialization Lib
I am trying to generate a simple cardano transaction using Cardano Serialization Lib that simply sends some ADA. I want to sign the transaction using web3 wallet like Nami and verify that signature.
I have an issue with the verification part, however the first step is to ensure my transaction is absolutely correct. I would really appreciate if anyone with expertise could check if there are any obvious errors or mistakes with my functions below. FYI: input transaction hash is randomly chosen.
export function generateTxForSigning(sendAddressBech32: string,
  receiveAddressBech32: string) {
  const txBuilderCfg =
  csl.TransactionBuilderConfigBuilder.new().fee_algo(
      csl.LinearFee.new(
      csl.BigNum.from_str(“44”),
      csl.BigNum.from_str(“155381”)
    )
  )
    .coins_per_utxo_byte(csl.BigNum.from_str(“4310”))
    .pool_deposit(csl.BigNum.from_str(“500000000”))
    .key_deposit(csl.BigNum.from_str(“2000000”))
    .max_value_size(5000)
    .max_tx_size(16384)
    .prefer_pure_change(true)
    .build();

  const txBuilder = csl.TransactionBuilder.new(txBuilderCfg);

  // INPUT
  const sendAddress = csl.Address.from_bech32(sendAddressBech32);
  const baseAddress = csl.BaseAddress.from_address(sendAddress);
  if (!baseAddress) {
    return;
  }

  const pubKeyHash = baseAddress.payment_cred().to_keyhash();
  if (!pubKeyHash) {
    return;
  }

  const txInputHash = “ff8145628286711636d13c34bc07a8a8eb62b2f1aad954cf172c2abd5b1e6d30”
  const txInputIndex = 3;

  txBuilder.add_key_input(
    pubKeyHash,
      csl.TransactionInput.new(
      csl.TransactionHash.from_hex(txInputHash),
      txInputIndex
    ),
    csl.Value.new(csl.BigNum.from_str(“161826921”))
  );

  // OUTPUT
  const receiveAddress = csl.Address.from_bech32(receiveAddressBech32);
  txBuilder.add_output(
    csl.TransactionOutput.new(
      receiveAddress,
      csl.Value.new(csl.BigNum.from_str(“159826921”))
    )
  );

  // TIME TO LIVE
  const ttl = getCardanoSlot() + 5 * 60; //5 minutes
  txBuilder.set_ttl_bignum(csl.BigNum.from_str(ttl.toString()));

  // MIN FEE CALC
  txBuilder.add_change_if_needed(sendAddress);

  // CREATE TRANSACTION
  const transaction = csl.Transaction.new(
    txBuilder.build()
    csl.TransactionWitnessSet.new()
    undefined
  );

  // RETURN FOR WALLET SIGNING
  return transaction.to_hex();
}

export function getCardanoSlot() {
  const nowUnixTimestamp = new Date().getTime();
  const startShelleyUnixTimestamp = nowUnixTimestamp - 1596491091;
  return startShelleyUnixTimestamp + 4924800;
}


text:
Get live price for token across different Cardano DEXes
I am working on a small pet project and I need to get the live price data for a token across multiple Cardano DEXes.
For instance, I need the live price of WMT on MinSwap, MuesliSwap, GeniusYield and WingRiders. I am aware DexHunter does something similar as an aggregator, but I cannot figgure out how they do it.
So far my thinking is that:

I can get this data straight from the DEXes's smart contracts
I need an oracle for this.

However, I am not sure if these approaches are possible.


text:
Daedalus not showing my wallet, prompting me to restore or create new. No pass phrase
Daedalus was not fulling syncing and opening up. In an attempt to sync and get it open I deleted everything in the immutable, ledger, and volatile files. I read that helped fix the problem. I then restarted my computer and when I opened Daedalus it’s now asking to restore the wallet. When I migrated from Byron to Shelley I don’t remember ever being prompted with a new passphrase so I do not have the 24 word phrase and now I’m terrified all my ADA is lost.
I’ve tried importing through the state directory but it’s not finding my wallet and I don’t remember the exact wallet name.
The blocks are currently 52% synced. Im praying for a miracle and that when it fully syncs my wallet will be there.
Please help me figure this out.

Your "wallet" is not on your computer, its on the blockchain. The only thing that is stored on your computer is your private keys which allows you to access your functions on the blockchain.
If you are only 52% synced. you should wait.

I do not have the 24 word phrase

The seed phrase is probably the same as when you created the Byron wallet.
The seed phrase is the only thing you need to restore your wallet.


text:
DB-Sync insanely slow
So i built the latest node and db-sync releases from source. My node works great it was fully synced fairly quickly. the db-sync got to around %78 and then started going insanely slow. I still have about 400GB free, only using about 30/48GB of memory.
This is
ubuntu 22 with
db sync 13.1.1.3
node 8.7.2
ghc 8.10

It updates about .01% everyday. So its just barely faster then the new transactions on the node each day. I have little script that compares the latest slot number between the node and the database. At this rate it wouldn't be updated for over 3 years
I don't have any errors I can find. the hard drive space and memory don't seem to be leaking. Any thoughts as to what the problem might be or how it can be optimized?

Is you disk storage for the database directly attached or network attached. Network attached storage is specifically advised against https://github.com/IntersectMBO/cardano-db-sync#system-requirements

yeah, its a local hoard drive, everything is on the same OS/hardrive, including the postgres server. It updated quick until about 75%, then just slowed down.

Does your machine meet the system requirements in the document above? Are you on an SSD drive rather than an electro-mechanical one? Is this dedicated hardware or something like an AMazon AWS system? Please provide comprehensive info about your setup.

Its my home server. Its just a virtual box image. where I allocated 48 GB of memory and about 900 GB on a SSD that is supposed to be around 300+MB/S. Its not an M2 SSD but a SATA SSD. I allocated 4 cores of my 8 core processor.

I should note the Drive symbol is always 100% lit, even though its not really filling up any more space. Even if it were magnetic, It would be filling the space 100x faster then it currently is

Your system seems very similar to mine. MIne is a KVM virtual machine writing to a SATA SSD drive. One thing I do know about SSDs is that writes seem to slow down as the number of write cycles increases (I killed an SSD during the development of db-sync). If yours a new or an old SSD? You still have not shared details of the host machine that the VM runs on (dstat maybe?)). This seems like a system performance issue rather than a db-sync issue.

That's fair. My host machine has 64 gb of ddr4 memory, 8core ryzen 9 processor, and about 5 different hard drives. IMO this is a dbsync problem. It should be faster then this on a magnetic drive. I should say, just to experiment I moved the VM to a different hard drive with no changed results. IMO DB sync is just doing stuff way to inefficiently. I have decided to move to Kupo


text:
Cabal build all failed with "Failed to build Diff-0.5"
Preprocessing library for base58-bytestring-0.1.0..
Building library for base58-bytestring-0.1.0..
[1 of 2] Compiling Data.ByteString.Base58.Internal ( src/Data/ByteString/Base58/Internal.hs, dist/build/Data/ByteString/Base58/Internal.o, dist/build/Data/ByteString/Base58/Internal.dyn_o )
[2 of 2] Compiling Data.ByteString.Base58 ( src/Data/ByteString/Base58.hs, dist/build/Data/ByteString/Base58.o, dist/build/Data/ByteString/Base58.dyn_o )

src/Data/ByteString/Base58.hs:15:1: error: [-Wunused-imports, -Werror=unused-imports]
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
   |
15 | import Control.Applicative
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

What are you building? What versions of ghc and cabal are you using?

I am using ghc 8.10.7 and cabal 3.6.2.0

Ok,but what are you building?

I am running cabal build all in the cardano-node directory as per the directions in this readme: https://github.com/input-output-hk/cardano-node-wiki/blob/main/docs/getting-started/install.md

Ok, so you are building cardano-node. The warning you posted is from a library that cabal has pulled from Hackage. Its a warning, not an error. so is should just continue to compile. That warning can be ignored.

Actually I started from the instructions from here (https://developers.cardano.org/docs/get-started/installing-cardano-node/#linux), which told me to use cabal 3.6.2. However, the link I posted from the previous comment uses cabal 3.8.1, so I am using that instead.

Anything after cabal 3.6.2 is fine.


text:
Using cardano-cli, is their any way to decode a plutus script which is in cbor?
I am using "cardano-cli text-view decode-cbor --in-file mint.plutus" which is just returning the cbor portion as a result.
Even tried saving an --out-file via: .json etc...But gives me Giberish when I "cat" it.
Any way to decode a plutus script in CLI instead of using an external source?
There is an existing post which talks about decoding "transactions" (which works for transactions), - but that does not work when I manipulate it with a plutus cbor script->
How to decode cbor which is generated with cardano-cli build command?

This is not currently possible with cardano-cli. There are executables in plutus that you may find useful. See https://cardano.stackexchange.com/a/11449/1071.


text:
What's the best wallet for Cardano?
I'm new to crypto all together. I was just wandering what you all think the best cardano wallet is?
I found a interesting post talking about it here.
I heard that ledger was the best choice. I'm currently debating. Can you please share some others. Thanks!

There is no "best" wallet and the choice to pick a wallet depends on multiple factors which the user may find of interest- list includes but is not limited to:

It's UI (how it looks /your interaction with it)
NFT visual support
Compliance with any Cardano Standards for voting purposes
light (Yoroi) vs heavy (deadlaus) for memory consumption
Current support for dapps which utilize said wallet for transactions
many other factors ...etc....

I would recommend trying out different wallets and seeing which one suits you best for your personal needs.


text:
Metadata Label Registry
Is there an official "label registry" for (transaction) metadata?
CIP 10 proposed such a registry, but I can not find it implemented anywhere.

There has been a lot of reorganization on the CIP website and for whatever reason a number of links seem to have been broken.
The registry as I understand it is this chunk of JSON in the CIP GitHub, permalinked below for convenience.

https://github.com/cardano-foundation/CIPs/blob/868ae58447c953cc6115b61064af6d5ad30edd87/CIP-0010/registry.json

My understanding is that new labels are added via pull-request to this repo.


text:
Plutus-pioneer-progra cabal build error
when I built plutus-pioneer-program lecture week2, I got the error like this
/root/.cabal/store/ghc-8.10.7/cardano-crypto-praos-2.1.0.0-6256b7c51bff5ecd7a4cd62d0cae080568903ed67a7b8424037c5be2d1c7a1d9/lib/libHScardano-crypto-praos-2.1.0.0-6256b7c51bff5ecd7a4cd62d0cae080568903ed67a7b8424037c5be2d1c7a1d9.a(Praos.o):ghc_18.c:function cardanozmcryptozmpraoszm2zi1zi0zi0zm6256b7c51bff5ecd7a4cd62d0cae080568903ed67a7b8424037c5be2d1c7a1d9_CardanoziCryptoziVRFziPraos_zdwzdcevalVRF_info:(.text+0xa354): error: undefined reference to 'crypto_vrf_ietfdraft03_proof_to_hash'

it seems link cardano-crypto-praos error, how to solve it?

Which set of instructions are you using to build this? My suspicion is that you have either skipped a step or the instructions are incomplete.

I think I didn't skipped some step, I just installed all deps manually, and run 'cabal build'. When I tried to build cardano-node, it is also failed, the same command 'cabal build'

Following the links from the README file in the cardano-node repo leads to this  https://github.com/input-output-hk/cardano-node-wiki/blob/main/docs/getting-started/install.md .I think you missed the "installing libsodium" section and maybe more.


text:
`cardano-tracer`: `VersionMismatch` error during handshake
Good day. I'm trying to see how cardano-tracer works in depth and for tests I'm trying to connect it to the node created by cardano-testnet, but getting this error:
"cardano-tracer, connection with \"/tmp/nix-shell.rnSoi4/testnet-test-21056d614f5c271d/socket/node-spo1\" failed: HandshakeError (VersionMismatch [] [32777,32778,32779,32780,32781,32782,32783,32784])"

I'm building everything from sources with Nix from the tag 8.7.3.
Then using this command to start testnet:
cabal run cardano-testnet -- cardano --babbage-era --testnet-magic 1234

After network is up, I'm following Local Scenario part of the dicumentation with ConnectTo option.
Config looks something like this:
{
  "networkMagic": 1234,
  "network": {
    "tag": "ConnectTo",
    "contents": [
      "/tmp/nix-shell.rnSoi4/testnet-test-21056d614f5c271d/socket/node-spo1"
    ]
  },
  "logging": [
    {
      "logRoot": "/path/to/tracer-logs",
      "logMode": "FileMode",
      "logFormat": "ForMachine"
    }
  ],
  "rotation": {
    "rpFrequencySecs": 15,
    "rpKeepFilesNum": 5,
    "rpLogLimitBytes": 5000,
    "rpMaxAgeHours": 1
  }
}

Then I start tracer with
cabal run cardano-tracer -- -c /path/to/active-tracer-config.json

And this is the output I'm getting:
{"at":"2024-01-29T08:00:15.411851532Z","ns":"Tracer.ParamsAre","data":{"ConfigPath":"/path/to/active-tracer-config.json","MinLogSeverity":null,"StateDir":null,"kind":"TracerParamsAre"},"sev":"Info","thread":"4","host":"Omen"}
{"at":"2024-01-29T08:00:15.412203051Z","ns":"Tracer.ConfigIs","data":{"Config":{"ekgRequestFreq":null,"hasEKG":null,"hasForwarding":null,"hasPrometheus":null,"hasRTView":null,"loRequestNum":null,"logging":[{"logFormat":"ForMachine","logMode":"FileMode","logRoot":"/path/to/tracer-logs"}],"metricsComp":null,"network":{"contents":["/tmp/nix-shell.rnSoi4/testnet-test-21056d614f5c271d/socket/node-spo1"],"tag":"ConnectTo"},"networkMagic":1234,"rotation":{"rpFrequencySecs":15,"rpKeepFilesNum":5,"rpLogLimitBytes":5000,"rpMaxAgeHours":1},"verbosity":null},"kind":"TracerConfigIs"},"sev":"Info","thread":"4","host":"Omen"}
{"at":"2024-01-29T08:00:15.412205245Z","ns":"Tracer.InitStart","data":{"kind":"TracerInitStarted"},"sev":"Info","thread":"4","host":"Omen"}
{"at":"2024-01-29T08:00:15.4122078Z","ns":"Tracer.EventQueues","data":{"kind":"TracerInitEventQueues"},"sev":"Info","thread":"4","host":"Omen"}
{"at":"2024-01-29T08:00:15.412443698Z","ns":"Tracer.InitDone","data":{"kind":"TracerInitDone"},"sev":"Info","thread":"4","host":"Omen"}
{"at":"2024-01-29T08:00:15.413581843Z","ns":"Tracer.StartedLogRotator","data":{"kind":"TracerStartedLogRotator"},"sev":"Info","thread":"7","host":"Omen"}
"cardano-tracer, connection with \"/tmp/nix-shell.rnSoi4/testnet-test-21056d614f5c271d/socket/node-spo1\" failed: HandshakeError (VersionMismatch [] [32777,32778,32779,32780,32781,32782,32783,32784])"

What could be wrong here?
From RTView docs it looks like node need to be run with --tracer-socket-path-accept option maybe? Is there a way to set this for cardano-testnet node?

Manage to make it work in AcceptAt mode with preprod node, where node initiates prortocol, but ConnectTo still throws an error during handshake


text:
Receiving "Handling input offset" message during db sync 3.1.1.3 update - going on 20 hours now. Is this normal?
Performing db sync update to 3.1.1.3 and waiting while server processes fix.  Currently receiving Handling input offset message as part of SQL update, been running for approximately 20 hours now.  Is this behavior normal and to be expected?  If yes, what exactly is the update doing that would take this long?  Perhaps restoring the cexplorer db from latest snapshot would have been a better update method.
Thanks

Highly advise restoring from a snapshot. I suspect syncing from scratch would take a week or more.

I suspected as much.  Thank you for the input here.


text:
How to find the last time an asset was transferred from one wallet to another
Sounds easy enough to do with something like Blockfrost but the best method I could find involved many API calls to different endpoints. It doesn't sound like something that should be too hard so maybe I'm approaching it the wrong way.

Maybe I am not understanding the question- but, are you not able to track the tx number, asset ID on Cardano scan?


text:
Any helpful resources to build with the Laravel framework and php?
There are good libraries for Javascript frameworks to build dApp like Meshjs, Lucid, etc.
I'm new to PHP and the Laravel framework.

Is it possible to integrate those JavaScript libraries, with the Laravel framework?

Or, are there any dedicated packages or tools available for Laravel framework to build dApp?

The use case is to connect a wallet and send payments.
Thanks.

I've also used Laravel in the past and did a combination of Cardano Serialization Lib (or now Multiplatform Lib) in Javascript.
So on clientside I mainly used JS to interact with:

CIP30 webwallet connections / signTx or getUtxo's or signData, etc
CSL/CML to serialize transactions which are submitted through the client's wallet

For any blockchain queries I used a combination of :

Blockfrost API
DB-sync connection

Hope this helps!


text:
DB Sync Upgrade to v 3.1.1.3 snapshot restore (4 days old) running "extra migration consumed_tx_out". Why is new column not included in snapshot?
Interested to understand why db sync snap shot does not include new consumed_tx_out column.  Just upgraded to v3.1.1.3 using manual method (not docker) and restored most recent db snapshot from 4 days ago with the hope that these "fix" items would already be included.  Why is this not the case?  Also, what are the controls (non docker) for telling db sync "when to run" or "when not to run" these fix commands?  Perhaps I overlooked the documentation for this.
Thank you

I am going to re-restore from the latest snapshot and attempt to start and sync the db sync node without "--consumed-tx-out" flag in run command.  Seems as though the script used to process the consumed-tx-out update needs some more work.

Snapshots use the default db-sync flavour, which doesn't enable the --consumed-tx-out flag. This flag creates the tx_out.consumed_by_tx_id column. Also for each tx_in entry it updates exactly one tx_out.consumed_by_tx_id field. The fact that there are so many updates and that postgres is not really optimised for updates makes this process very slow. Also note this flag eventually drops all tx_in entries, since they become redundant.


text:
cardano-db-sync sql query for assets of a wallet
I am trying to develop the PostgreSQL query that will return all the assets of a given stake address and their respective quantities.
What needs to be joined and queried in order to determine what's in a given wallet?
If I query for the tx_out's of a given stake address:
select * from tx_out where stake_address_id = X order by tx_id desc;
EDIT:
Here is what I have so far, with summed quantities for grouped fingerprints and not yet with sum of ADA added to result, just the assets...
EDIT 2: With policy added, ordered by quantity of asset. I think is what I wanted, just does not have quantity of ADA row in results yet.
SELECT encode(ma.policy::bytea, 'hex') as policy, ma.fingerprint, SUM(matxo.quantity) AS total_quantity
FROM tx_out AS txo
LEFT JOIN tx_in AS txi ON txo.tx_id = txi.tx_out_id AND txo.index::smallint = txi.tx_out_index::smallint
LEFT JOIN tx ON tx.id = txo.tx_id
LEFT JOIN block ON tx.block_id = block.id
LEFT JOIN stake_address AS sa ON txo.stake_address_id = sa.id
LEFT JOIN ma_tx_out AS matxo ON matxo.tx_out_id = txo.id
LEFT JOIN multi_asset AS ma ON ma.id = matxo.ident
WHERE sa.view = '<stake_address_here>'
  AND txi.tx_in_id IS NULL
  AND block.epoch_no IS NOT NULL
  AND ma.policy IS NOT NULL
group by ma.fingerprint, ma.policy
order by total_quantity desc;

Have you looked at the "interesting queries" document linked from the README in the github repo?

Hi Erik, thank you - yes, I have examined those, as well as the schema, and the ERD.
https://github.com/IntersectMBO/cardano-db-sync/blob/master/doc/interesting-queries.md#get-all-assets-with-quantities-and-count-of-mints
There is the "Get all assets with quantities and count of mints" query in the interesting queries doc, but it does not retrieve for a given address / stake address..?

I added what I have so far as an edit to my question - see what you think could be better or should be done different @ErikdeCastroLopo ?

I have not tried to run that query, but it seems ok,

Here is what I have found returns the assets, and their respective quantities, for a given stake address. Enjoy!
SELECT encode(ma.policy::bytea, 'hex') as policy, ma.fingerprint, SUM(matxo.quantity) AS total_quantity FROM tx_out AS txo LEFT JOIN tx_in AS txi ON txo.tx_id = txi.tx_out_id AND txo.index::smallint = txi.tx_out_index::smallint  LEFT JOIN tx ON tx.id = txo.tx_id LEFT JOIN block ON tx.block_id = block.id  LEFT JOIN stake_address AS sa ON txo.stake_address_id = sa.id  LEFT JOIN ma_tx_out AS matxo ON matxo.tx_out_id = txo.id  LEFT JOIN multi_asset AS ma ON ma.id = matxo.ident  WHERE sa.view = '<stake_address_here>'  AND txi.tx_in_id IS NULL  AND block.epoch_no IS NOT NULL  AND ma.policy IS NOT NULL  group by ma.fingerprint, ma.policy  order by total_quantity desc;