IntersectMBO / plutus-apps

The Plutus application platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to Query the Node from Plutus Contracts

AI-madman opened this issue · comments

Describe the feature you'd like

Hello,

I have been attempting to make a systematic Deadman Switch, but it requires the ability to get query information into the contract from the blockchain. This is basily trying to take the ability of DB-sync servers and build them into Plutus.

I understand that you may not have much time to devote to this project, but as it is necessary to port several subsets of projects over from other chains I think we need to do this urgently, so if you can give the references required to do this I am willing to build the ability into Plutus and submit the codebase for a general update.

Describe alternatives you've considered

No response

The Contract Monad queries the node through queries from the plutus-chain-index (which are in the Plutus.Contract.Request module). What specific information do you need?

The transaction history of the specified address and the list of assets (UTxOs) at the address.

There's Plutus.Contract.Request.utxoRefWithCurrent for the list of assets at a address and Plutus.Contract.Request.utxosAt for UTXOs at an address.

The transaction history of an address can be implemented with a combination of the functions in Plutus.Contract.Request, but it might be inefficient.

We're reworking the plutus-chain-index so that these types of queries could be specified by the dApp provider.

If you give me some references on how your doing it I'm happy to help you do it and speed up the process, just give me some really good references as database stuff is not my forte.

Is there a possibility to do this with SQL that later get transcomplied to Haskell and then the Plutus-core, and slice it into place using the $$ operator?

With the current design of the contracts, you don't write SQL queries. You use the functions in Plutus.Contract.Request to query the chain-index. Look at example in plutus-use-cases for how these functions are used (or better, listen to Lars' lecture from the plutus-pioneer-program in Youtube).

We are still discussing on how to along more customizable node queries in the contract. For the time being, you are limited in what is possible. Unless, of course, you write the contract without the plutus-apps infrastructure using libraries like cardano-node, ogmios, plutus, etc.

Closing this