7 votes
Accepted

Where is the on-chain code actually stored?

As stated by Samuel, the code that a validator runs to check whether a transaction is valid is sent and stored in the transaction body as an input. So all scripts, be they Plutus or Native scripts, ...
Fermat's user avatar
  • 1,882
6 votes

Committing a database to the ledger without storing it on the ledger?

You can use Merkle tree's for this! This is an inverted tree like data structure that uses hashes to create a root hash that is uniquely defined by its leafs, the leafs are the nodes in the lowest ...
Fermat's user avatar
  • 1,882
4 votes
Accepted

Is function "isPayToScriptOut" unsafe?

Your deductions are partially correct. isPayToScriptOut looks at the credentials of an address (1) and return true if it is a script address, false if it is a public key credential. It thus does not ...
Fermat's user avatar
  • 1,882
3 votes

On-chain and Off-chain code

Yes, that's correct. On-chain is exactly what it says. It's logic that happens on every validator syncing the chain. The unique thing with plutus is the on-chain and off-chain code can live together ...
Samuel Leathers's user avatar
3 votes
Accepted

Is really any token metadata stored on chain? Or is it the mint TX metadata?

Yes there is NFT metadata stored on-chain and yes they are stored initially on the mint tx although you can update it later (basically overriding it in a new tx). If the NFT metadata follow the CIP25 ...
leobelizquierdo's user avatar
3 votes
Accepted

Overuse of resources when comparing for equality of VALUES (==)

Copying my answer from the Github issue here as well: We have hit the same issue lately. It is due to how the == function in the Eq Value instance is implemented. A value is logically a Map ...
Sebastian Nagel's user avatar
2 votes
Accepted

Is there a way for a validator to get the current time?

The usual way to handle time in Plutus is using Slot ranges. This means that the script does not query the time. Instead it checks that the validation happens in a given slot interval that corresponds ...
Flippy's user avatar
  • 83
2 votes

How to get a base 16 hex BuiltinString from getTxId

I was able to resolve this issue by converting (encoding) the BuiltinByteString from getTxId into a hex format. From there I was able to inpsect the hex digits. Below is an onchain encodeHex ...
lley154's user avatar
  • 297
2 votes

Can Queries To the Chain be made From Plutus Smart Contracts?

The way I understood things from last Q&A session with Lars, no, you can't. You can only see the current transaction, not the history of an address.
Mihai Codescu's user avatar
2 votes
Accepted

How can I configure and send a transaction to the Cardano chain using python

Checkout PyCardano. It is able to serialize python objects to datum and redeemers. Maybe this test example can help: https://github.com/cffls/pycardano/blob/main/integration-test/test/test_all.py#L217 ...
Jerry's user avatar
  • 403
2 votes

How to parse TokenName to Integer

I had trouble with the same thing, just going the opposite direction, Slot -> TokenName (Slot is just an Integer under the hood). After a bunch of pain I ended up just coding my own parsing logic: -...
Mitchell Turner's user avatar
2 votes
Accepted

How do Endpoints work?

In Plutus apps, the mechanism for requesting inputs is called "endpoints". All endpoints that an app wants to use must be declared as part of the type of the app. The set of all endpoints of ...
Falcon Stakepool's user avatar
2 votes
Accepted

Confusion regarding findOwnInput function with on-chain code

Calling findOwnInput in a validator returns the value contained in the Script-UTxO that is currently being validated. In your example above it is the one with 2 Ada in it. Your example above is, ...
Jey's user avatar
  • 1,549
2 votes

traceIfFalse is it possible to pass a string not "fixed"

This is probably not possible as the redeemer code is manipulated/examined from within a template haskell splice and you are running into what is called the "template haskell stage restriction&...
Erik de Castro Lopo's user avatar
2 votes
Accepted

How To Verify The Code Of A SmartContract?

You compile the code yourself to see if the address you arrive at aligns with what's live.
Pizza Knight's user avatar
1 vote
Accepted

How to do on-chain Integer pattern matching?

There is problem with pattern matching on Integer types according to Input Output Global. The Plutus compiler will currently reject any pattern matching on Integer types. Therefore the best solution ...
Will's user avatar
  • 1,162
1 vote
Accepted

How to compare BuiltinByteStrings onchain?

This is how I've done the integer conversion in the past. Might need some minor updating: {-# INLINEABLE intToString #-} intToString :: Integer -> Builtins.String intToString i = Prelude.foldr ...
Mitchell Turner's user avatar
1 vote
Accepted

How can a validator script be used to mint native tokens, in addition to perform other checks?

You need a separate minting policy to mint the tokens. we want a smart contract (validator script) I tend to think of smart contracts as including a set of validators and policies, not just one ...
Mitchell Turner's user avatar
1 vote
Accepted

Can UTxO sit at a minting policy (currency symbol), like at a validator script address?

As you said, minting policies is part of a transaction and and is not part of a script address UTxO, so it doesn't make sense saying "UTxO sitting at a minting policy", since the minting ...
Mateus's user avatar
  • 988
1 vote

How to optimize Plutus smart contracts?

Mlabs created excelent tool to quickly check and analyse size of smartcontracts. Github repo is here
KugisMugis's user avatar
1 vote
Accepted

How to optimize Plutus smart contracts?

I am building a dApp myself and I am running into similar issues related to hitting the current mainnet's maxTxExUnits upper boundaries of exUnitsMem and exUnitsSteps. In regards to question 4: You ...
Will's user avatar
  • 1,162
1 vote
Accepted

How to know which module to import?

Some of these are reexported versions of others. This means some of them are not necessary. Also PlutusTx.Prelude should be included in all projects as it maps types into PlutusTx which complies with ...
KryptoKing's user avatar
1 vote
Accepted

How do you deploy ready made AI on chain

I have done that as well for Kucoin Binance etc python is great for backend data analisis... Well.. BlockChain are just transactions... you should be able to do a BlockChain a transaction from your ...
Alicia Basilio's user avatar
1 vote

How do you deploy ready made AI on chain

I am not very knowledgeable when it comes to AI, but I'm pretty sure right now it's impossible to have one on-chain for two reasons. First, it would be too computationally heavy, so the current CPU ...
Mateus's user avatar
  • 988
1 vote

How to PreSign a transaction

Scripts on the ledger are passive, they do not act unless a party sends a transaction that propagates the state of the script. If I understand correctly, you want a vesting scheme, this is possible. ...
Fermat's user avatar
  • 1,882
1 vote
Accepted

How to get information about UTxOs which created locking transaction on the on-chain?

In TxOut you have a field txOutAddress that you can use for this: data TxOut = TxOut { txOutAddress :: Address, txOutValue :: Value, txOutDatumHash :: Maybe DatumHash } Use it to extract ...
Jey's user avatar
  • 1,549
1 vote

How does one check a pool's delegation history?

If you do not want to setup cardano-db-sync, try blockfrost.io with the /epochs/{number}/blocks/{pool_id} endpoint.
Marek Mahut - StakeNuts's user avatar
1 vote
Accepted

How does one check a pool's delegation history?

If you need any kind of specific on chain information that isn't found on third party explorers like Cardanoscan, you'd have to use db-sync yourself. (It's what all the explorers use) To quote ...
zhekson's user avatar
  • 3,689
1 vote
Accepted

How does custom Plutus data type map to cardano-cli --tx-in-datum-file content?

Here is an example of a haskell executable that will convert any of your custom data types to the right JSON format : https://github.com/OnChainLabs/Martify/blob/main/app/datum-json.hs In this file we ...
Alain Magazin's user avatar
1 vote

Retrieve only digit from TokenName and use onchain

given the request on way would be the following: getIdFromTokenName :: TokenName -> Integer getIdFromTokenName tn = getIdFromStr 0 $ (BS8.unpack . unTokenName) tn -- BS8.unpack :: ByteString -> ...
Michele Nuzzi's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible