Skip to content

nielstron/python-fortuna-miner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Fortuna Miner

This repo provides basic code to mine Fortuna on Cardano.

PyCardano is a Cardano library written in Python. It allows users to create and sign transactions without depending on third-party Cardano serialization tools, such as cardano-cli and cardano-serialization-lib, making it a lightweight library, which is simple and fast to set up in all types of environments.

opshin is a Smart Contract language based on Python. It allows users to define and compile Smart Contracts directly within a python environment. It also interacts seemlessly with PyCardano.

Dev Environment

For executing the scripts in this starter kit you'll need access to a running Ogmios instance.

In case you don't want to install the required components yourself, you can use Demeter.run platform to create a cloud environment with access to common Cardano infrastructure. The following command will open this repo in a private, web-based VSCode IDE with access to a running Ogmios instance in the preview network.

Code in Cardano Workspace

Setup

  1. Install Python 3.8, 3.9 or 3.10.

On demeter.run or Linux/Ubuntu, this version of python is usually already pre-installed. You can skip this step. For other Operating Systems, you can download the installer here.

  1. Ensure python3 --version works in your command line. Open a Terminal in the browser VSCode interface (F1 -> Terminal: Create New Terminal) In Windows, you can do this by copying the python.exe file to python3.exe in your PATH environment variable.

  2. Install python poetry.

On demeter.run or Linux/Ubuntu run

curl -sSL https://install.python-poetry.org | python3 -
echo 'export PATH=/config/.local/bin:$PATH' >> ~/.bashrc
bash

Otherwise, follow the official documentation here.

  1. Install a python virtual environment with poetry:
# install python dependencies
poetry install
# run a shell with the virtual environment activated
poetry shell
  1. Set up ogmios and optionally kupo.

On demeter.run, simply add the Ogmios Extension for the Preview network through the project console website (the page that shows you demeter.run project -> Connected Extensions -> Browse Extensions -> Cardano Ogmios) If you want to add kupo, use the Kupo Extension as well.

Make sure the following environment variables are set (defaults are displayed):

OGMIOS_URL=ws://localhost:1337

KUPO_URL=http://localhost:80

Running the scripts

Fair warning: this code handles cryptocurrency. Make sure to read the code and understand what it does before running it. There is always a risk of loosing part of or all of your funds when interacting with tools that handle crypto wallets for you.

If you want to know how to start the miner, please read the code and ensure yourself that it properly handles your funds. Hence, it is not recommended to simply run the script like this:

python3 src/off_chain/mine.py

This will start the miner, show you a locally generated address that needs to be funded and then donate all funds to OpShin and PyCardano development. Contact me or the OpShin team if you are reading this after donating larger amounts than you are comfortable with.

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%