<p>Checkout PyCardano. It is able to serialize python objects to datum and redeemers. Maybe this test example can help: <a href="https://github.com/cffls/pycardano/blob/main/integration-test/test/test_all.py#L217" rel="nofollow noreferrer">https://github.com/cffls/pycardano/blob/main/integration-test/test/test_all.py#L217</a> It implements all off-chain code of <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week02/src/Week02/Typed.hs" rel="nofollow noreferrer">forty-two</a> example in Plutus-pioneer-program.</p>
<p><strong>Update:</strong></p>
<p>I polished the test into a concrete example with more details here: <a href="https://github.com/cffls/pycardano/tree/main/examples/plutus/forty_two" rel="nofollow noreferrer">https://github.com/cffls/pycardano/tree/main/examples/plutus/forty_two</a></p>

CC BY-SA 4.0
2022-05-16T21:32:38.630Z
Do you have any examples of more complex datums being used? I am getting some errors when I try some more complex structures
Mateus
CC BY-SA 4.0
2022-05-17T05:14:17.447Z
@Mateus Checkout this unit test: https://github.com/cffls/pycardano/blob/7ac73501ff3093b1b467b51c685ded3336cdc526/test/pycardano/test_plutus.py#L56 It covers different data structures, e.g. list, map.
Jerry
CC BY-SA 4.0
2022-05-17T09:25:12.737Z
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
CC BY-SA 4.0
2022-05-17T17:02:00.863Z
Hey @Mateus, we have a discord server. Do you want to discuss the issue you encountered over there: https://discord.gg/qT9Mn9xjgz ?
Jerry
CC BY-SA 4.0
2022-04-26T04:21:23.913Z
2022-04-28T20:23:48.757Z
2022-04-28T20:23:48.757Z
Jerry
<p>I have written some plutus contracts, but they use parameterisation and the params are gained through a REST API.</p>
<p>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.</p>
<p>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.</p>

<plutus><plutus-pioneer-program><smart-contract><api><on-chain>
How can I configure and send a transaction to the Cardano chain using python
# How can I configure and send a transaction to the Cardano chain using python

(Asked by: username_0 on 2022-02-23)

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.

**Tags:** plutus, plutus-pioneer-program, smart-contract, api, on-chain

---

## 1 answers

### Answer by username_1 on 2022-04-26. Score: 2 | Accepted answer

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](https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week02/src/Week02/Typed.hs) 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>

> **Comments:**
> **username_2**: Do you have any examples of more complex datums being used? I am getting some errors when I try some more complex structures  
> **username_1**: @Mateus Checkout this unit test: https://github.com/cffls/pycardano/blob/7ac73501ff3093b1b467b51c685ded3336cdc526/test/pycardano/test_plutus.py#L56 It covers different data structures, e.g. list, map.  
> **username_2**: 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  
> **username_1**: Hey @Mateus, we have a discord server. Do you want to discuss the issue you encountered over there: https://discord.gg/qT9Mn9xjgz ?  

---

