This is an open-source project supported by Gimbalabs to create RESTful API Endpoint for Compiling Plutus Scripts.
In Cardano's eUTxO model, parameterized script is heavily used for real scalable smart contract. With different parameters supplied to the same validator function, it would return multiple plutus Validator
and generate multiple cborHex
. With different cborHex
created, different script addresses could be derived. It is a best practice to split users who never interact with each others into different places, which avoid multiple issues such as double satifaction etc.
However, in the available education resources most script cborHex
's are created through the Utils.hs
function inside Haskell library. In the real Dapp production, user cannot get the script calculated easily on the frontend. Therefore, currently there is still gap implementing such Plutus best practice. This project is trying to reduce the pain in between, building a module or service which could help Plutus developers to easily convert their Plutus cborHex generating functions into RESTful API endpoints, which are easily interacted with the client side.
In the long-term, an API for compiling plutus scripts can be served via Dandelion. In addition to being an essential tool, this project can serve as an example of how we can extend Dandelion.
nix-shell
of your plutus-apps
using checkout tag 97b4c1da03faf9bc35f348802fb7927231657e75
plutus-apps
git pull
git checkout 97b4c1da03faf9bc35f348802fb7927231657e75
nix-shell
cd ~
git clone https://github.com/SIDANWhatever/plutus-cborhex-automation.git
cd plutus-cborhex-automation/example
cabal run sidan-plutus-server
Allow for a while of build time, you could then see the local server is up for example validator.
Spock is running on port 8080
Try the endpoint!
curl -X POST http://localhost:8080/testing-validator -H "Content-Type: application/json" -d '{"testNumber": 245324,"testPpkh": {"unPaymentPubKeyHash": {"getPubKeyHash": "8f2ac4b2a57a90feb7717c7361c7043af6c3646e9db2b0e616482f73"}}}'
For full API documentation please find it here
You can deploy this service as any other typical backend servers. We have one example demonstrating how to deploy on AWS EC2. Onwards we would develop scripts for streamlining deployment process.
Developers can use a Docker image to create a REST endpoint that returns CBOR and Address for any pre-defined, parameterized Plutus Validator. Upon delivery of Docker image, code repo and documentation.
Outcomes:
plutus-apps
tags support upon community suggestions.We can take the final step of using this service as a first step to putting reference scripts on-chain. This will also serve as a hands-on example that can be used in upcoming Dandelion PBL course.
We also welcome any contributors on any suggestions and thoughts to make this infrastructure more accessible, and better to the community.