1

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 automatic process that converts the data into the params structure, and then submit the plutus code/contract with the params to the blockchain.

I can do the conversion between the REST data and the params, but how do I package the code and submit it to the chain via python 3.

1 Answer 1

2

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 It implements all off-chain code of forty-two example in Plutus-pioneer-program.

Update:

I polished the test into a concrete example with more details here: https://github.com/cffls/pycardano/tree/main/examples/plutus/forty_two

4
  • Do you have any examples of more complex datums being used? I am getting some errors when I try some more complex structures
    – Mateus
    Commented May 16, 2022 at 21:32
  • @Mateus Checkout this unit test: github.com/cffls/pycardano/blob/… It covers different data structures, e.g. list, map.
    – Jerry
    Commented May 17, 2022 at 5:14
  • Thanks @Jerry, my attempt was a plutus data instance with a map as one of the attributes that has another plutus data instance as the key of that map. Very specific scenario, but it fails for some reason. It says that cborTag cannot be hashable
    – Mateus
    Commented May 17, 2022 at 9:25
  • Hey @Mateus, we have a discord server. Do you want to discuss the issue you encountered over there: discord.gg/qT9Mn9xjgz ?
    – Jerry
    Commented May 17, 2022 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.