Python-Cardano / pycardano

A lightweight Cardano library in Python
https://pycardano.readthedocs.io
MIT License
215 stars 67 forks source link

config option to choose local cardano-node for transactions #102

Closed peterVG closed 1 year ago

peterVG commented 2 years ago

Currently you can change the Network setting from Network.TESTNET to Network.MAINNET.

Firstly, it's not clear which "Testnet" version this if referring to. It looks like its the "legacy" (broken) testnet still being run by IOG but could (should) be the PREVIEW and/or the PREPROD network. It would be nice if you choose explicitely.

Secondly, it would be nice not to rely on a third-party API like Blockfrost for chain data but instead use your own copy from your cardano-node db. Can we add a config option to PyCardano to use a local node for its read/write transactions?

cffls commented 2 years ago

When the library was created, there were only one testnet and mainnet, so I simply used Network to distinguish the network. Network type is not intended to identify the chain, it should be only used to create cardano address. I could probably remove Network type from the parameter of BlockFrost chain context. Also, if you want to use a specific network in BlockFrost, you can pass the API url to base_url param, see this post here: https://github.com/cffls/pycardano/discussions/83#discussioncomment-3549922

An alternative to Blockfrost chain context we have implemented is Ogmios chain context, which allows you to run everything locally without depending on a thrid-party API. This is an example where we use Ogmios chain context to get and submit transactions to a local chain.

peterVG commented 2 years ago

Cool. Thanks for the explanation. I will check out the Ogmios option.

cffls commented 1 year ago

Closing this issue as the solution has been suggested.