Questions tagged [on-chain]

Code that is executed "on-chain", is used to validate transactions that involve smart contracts.

Filter by
Sorted by
Tagged with
0 votes
0 answers
44 views

How to obtain the public key hash in on chain plutus validator?

It seems public key hash is generated from blake2b_224 but in on-chain validator we only have blake2b_256. Is there any way to obtain public key hash from public key in cardano plutus?
Ask-Plutus-Bot's user avatar
0 votes
1 answer
29 views

Unable to convert BuiltinString to JSON

I would like to include a BuiltinString in a datum but am unable to do so as BuiltinString has neither a FromJSON nor a ToJSON instance. Is there an alternative to implementing these instances by hand?...
Eric's user avatar
  • 85
1 vote
1 answer
65 views

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

I found an strange consumption of mem and CPU when comparting VALUES on-chain. If I do the same comparison with my own writing functions I found is more efficient. How could it be? Everything is ...
Manu Padilla's user avatar
0 votes
2 answers
71 views

How to generate CBOR hex of plutus smart contract

How can i generate the CBOR hex of a plutus smart contract. Does it requires to generate CBOR of onchain code only or both onchain and offchain? Also if have a smart contract which requires parameters ...
duaa azhar's user avatar
0 votes
1 answer
81 views

How to get all unSpent UTXOs at script address OnChain

Hi i am building CrowdFund where i need to know the total amount raised at the script as an OnChain validation. i was looking at Contexts.findOwnInput but would this only return the tx-in's provided ...
Chakravarti Raghavan's user avatar
3 votes
1 answer
72 views

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 ...
KryptoKing's user avatar
1 vote
2 answers
53 views

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

Is this even possible? traceIfFalse ("A"++show(scriptContextTxInfo)) FoundIt As logging onchain is just possible with this traceIfFalse ... I'm not finding a solution to make that line ...
Cristovao Morgado's user avatar
0 votes
1 answer
46 views

Opportunity for theft of funds in Martify marketplace

I am some kinda embarrassed by "mkBuyValidator" in Martify Marketplace on-chain code . For buyer there is only one check for token transfer (on line 68): (valueOf (valuePaidTo info sig) (...
Anastasia Martyniuk's user avatar
0 votes
1 answer
65 views

Whether validation checks are necessary

In Plutonomicon github repo it says by the end of the page: For example, you don't need to prevent an unexpected transaction from locking value away - that's the submitter's own problem - but you do ...
Anastasia Martyniuk's user avatar
0 votes
1 answer
59 views

Workaround for Plutus Scripts that excesses the max Tx Size. Framework or examples for splitted or modular validators?

Im very interested in how you can split the validation in several validator. There is any model or framework to follow? Any example around? Could somebody at least share some words of insights about ...
Manu Padilla's user avatar
3 votes
1 answer
317 views

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

The Cardano blockchain has no global state, this means that shared state needs to be introduced. Is there a design pattern that lets you commit big sets of data to the ledger without storing it? This ...
Fermat's user avatar
  • 1,862
3 votes
1 answer
79 views

Is function "isPayToScriptOut" unsafe?

As far as i understood, function "isPayToScriptOut" assumes every output that has a datum hash is a script output. But what if we create new output with datum, assigned to some pub key (for ...
Anastasia Martyniuk's user avatar
0 votes
2 answers
58 views

Providing a list of mappings from datum hashes to values while creating a transaction

I noticed that TxInfo datatype has a txInfoData field which carries a list of mappings from datum hashes to datum values. This seems very useful for validating transactions with multiple input UTxO's. ...
keyanm's user avatar
  • 76
3 votes
2 answers
99 views

How to Get the Script Address of A Smart Contract?

Once I have written up the smart contract how to I get the script address value to be able to interact with the script whilst its on chain?
KryptoKing's user avatar
0 votes
1 answer
87 views

How to do on-chain Integer pattern matching?

I want to do Integer pattern matching on-chain but always get an error: GHC Core to PLC plugin: E042:Error: Unsupported feature: Use of Haskell Integer equality, possibly via the Haskell Eq typeclass ...
Will's user avatar
  • 1,162
1 vote
3 answers
129 views

How to compare BuiltinByteStrings onchain?

I want to check on-chain if a given TokenName is of a specific pattern, for example: aaa1 aaa2 aaa3 I have something like this, but it throws an interpreter exception: checkValidMint :: TokenName -&...
Will's user avatar
  • 1,162
1 vote
1 answer
99 views

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

Suppose we want a smart contract (validator script) that locks a user' fund (e.g. ADA) that she deposits and releases it back if she withdraws it. Suppose when she deposits some fund into the ...
Qin's user avatar
  • 39
0 votes
1 answer
65 views

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

Both minting policy and validator script are on-chain code. Validator script can be used to lock fund sitting at its validator script address. A transaction can consume the UTxO only if the validator ...
Qin's user avatar
  • 39
5 votes
2 answers
129 views

How to optimize Plutus smart contracts?

Context I'm creating scripts with hardcoded parameters in my smartcontract and I would like to reduce footprint of them to reduce transaction fees. Right now i'm doing so using parameterized ...
KugisMugis's user avatar
0 votes
1 answer
51 views

How do you Connect ATALA to Plutus Smart Contracts [closed]

I think they use diffrent programming languages, but how can I use DID inside my Plutus contracts?
KryptoKing's user avatar
1 vote
1 answer
54 views

How to know which module to import?

Let's say my smartcontract needs BuiltinData. Quicksearch in documentation reveals that BuiltinData is in: Plutus.V1.Ledger.Api Plutus.V2.Ledger.Api PlutusTx.Builtins.Internal PlutusTx PlutusTx....
KugisMugis's user avatar
2 votes
3 answers
222 views

How to get a base 16 hex BuiltinString from getTxId

I am trying to find a way to inspect the base16 hash from a Tx on-chain using plutus. I get a BuiltinByteString from the txInputs here: getTxIdBBS :: TxInInfo -> BuiltinByteString getTxIdBBS txInfo'...
lley154's user avatar
  • 297
0 votes
2 answers
68 views

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

Considering that Plutus Smart Contracts have two parts (on chain and off chain) is there a way to make Queries to the Cardano Chain in the onchain part of the contract considering that the SC is ...
KryptoKing's user avatar
1 vote
0 answers
60 views

How to use Endpoints and Schema

I doing the PPP but Lars does not cover Endpoints or schema declarations in sufficient detail. I imagine that this is a problem that Plutus devs must overcome, but I cannot find suitable documentation ...
KryptoKing's user avatar
1 vote
1 answer
140 views

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

I have written some plutus contracts, but they use parameterisation and the params are gained through a REST API. I am using python3 to interface with the API, but would like to be able to script an ...
KryptoKing's user avatar
0 votes
2 answers
41 views

How do you deploy ready made AI on chain

I have made a bunch of trading bots using python and tensorflow. How do I deploy this stuff on the chain with Plutus? Is this the approach taken by Dr Ben Goetzel at SingularityNet or do they run it ...
KryptoKing's user avatar
0 votes
1 answer
59 views

How to PreSign a transaction

im trying to figure out how to sign a smart contract (SC) and have it put on-chain, where it waits until its validation logic returns True. Edit 1: To clarify what I mean by signing is the private key ...
KryptoKing's user avatar
1 vote
1 answer
82 views

How do Endpoints work?

and cant figure out what Endpoint do (why are they in the code) and most important of all how should I code them. What are the best practices?
KryptoKing's user avatar
0 votes
1 answer
198 views

What is the correct way to compare two instances of Value data type?

Question What is the correct way to compare two instances of Value data type? Context I would like to check if outgoing transaction identified by PubKeyHash has the same Value as Value which was ...
KugisMugis's user avatar
1 vote
1 answer
95 views

Confusion regarding findOwnInput function with on-chain code

Context I was looking for a simple way to get exact TxOut on on-chain code to validate if funds are to be unlocked to correct wallet address. While looking in plutus haddoc I have found this function: ...
KugisMugis's user avatar
3 votes
1 answer
73 views

On-chain and Off-chain code

I've seen the existing similar questions on this topic. I probably still don't get it. So a question: Is it a correct analogy to the JS-Solidity world that the On-chain code corresponds to the ...
user3309213's user avatar
1 vote
1 answer
116 views

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

I would like to create a smartcontract which makes sure that only the same person who made specific locking transaction can unlock that same specific transaction or to put it into simpler terms if Bob ...
KugisMugis's user avatar
2 votes
2 answers
322 views

How does one check a pool's delegation history?

How does one view addresses that were staking with a specific pool at a specific epoch boundary? If there is any way to view a list of addresses that received staking rewards for a particular block, ...
DeCentN2Madness's user avatar
2 votes
2 answers
334 views

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

Let's say I have validator, which checks datum against two numbers, hash, time and a string and there are some funds locked at this script address and I would like to unlock these funds using cardano-...
KugisMugis's user avatar
2 votes
2 answers
81 views

Retrieve only digit from TokenName and use onchain

How can I make the following function to retrieve only digit portion from the TokenName and use it on chain? For example I want to retrieve the number 123 from "AAA123" (TokenName) {-# ...
utxo's user avatar
  • 21
2 votes
1 answer
315 views

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

I am aware that offchain metadata is stored using the registration as Cardano Developers portal dictates, my concern is about on-chain metadata. Is really any NFT-metadata stored on-chain? Like ...
Alicia Basilio's user avatar
2 votes
3 answers
98 views

Does Plutus support floating-point arithmetic for on-chain code?

Plutus provides arithmetic functions for Integers through the modules PlutusTx.Prelude and PlutusTx.Builtins. Are there floating-point arithmetic functions which can be used on chain? If not, why is ...
lambda's user avatar
  • 804
0 votes
1 answer
115 views

How to validate the correctness of another parameterized script address on-chain

I would like to write a factory script that can initialize another parameterized script address by sending it an NFT. The factory validator gets the parameters of the target script as redeemer and has ...
Flippy's user avatar
  • 83
2 votes
2 answers
144 views

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

Is it possible for a validator to get the current time without it being passed in via the redeemer? My validator is heavily dependent on the time being correct so it would probably be a bad design ...
Isaac Padberg's user avatar
2 votes
2 answers
168 views

How to parse TokenName to Integer

I have information encoded in the TokenName of an asset. These token names represent integers. According to the Plutus source code, the TokenName is of type BuiltinByteString. How can I parse it to ...
Jey's user avatar
  • 1,549
13 votes
2 answers
531 views

Where is the on-chain code actually stored?

I've just read something that suggests Validators aren't actually kept on the blockchain. To save the space, only the hash of the Validator is kept at the UTxO and users willing to spend it must ...
emesik's user avatar
  • 866