Skip to main content

Python port of Metaplex JS SDK - https://github.com/metaplex-foundation/js

Project description

original-metaplex-python

Python port of Metaplex JS SDK - https://github.com/metaplex-foundation/js

Installing this package

If you simply want to use this package, first clone this repository on your machine, then install it from your file system using pip:

pip install -e /path/to/your/directory/original-metaplex-python

or poetry:

poetry add -e /path/to/your/directory/original-metaplex-python

Note -e adds it in editable mode.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.10 or higher
  • Poetry for dependency management and packaging

Setting Up the Development Environment

  1. Clone the repository
git clone https://github.com/getoriginal/original-metaplex-python.git
cd original-metaplex-python
  1. Install dependencies

Run the following command to install the project dependencies:

poetry install --no-root

This command reads the pyproject.toml file and installs all necessary dependencies, including development dependencies, into a new virtual environment managed by Poetry.

  1. Activate the virtual environment

To activate the Poetry-managed virtual environment, use:

poetry shell

Alternatively, you can run commands within the virtual environment using poetry run <command> without activating it.

  1. Set up pre-commit hooks

Install the pre-commit hooks with:

pre-commit install

This step ensures that the code linters and formatters run on every commit to maintain code quality and consistency.

Running the Application

First we need to create some wallets.

Use the Phantom wallet browser extension to create two new accounts. Then grab the private keys and put one in each of the files:

wallet_secret.txt // Used to mint NFTs
wallet_secret_friend.txt // The friend's wallet to test transferring.

Both files should be placed at the root of your project.

Ensure that the wallet_secret.txt account is topped up with DevNet SOL. You can get devnet SOL here: https://faucet.solana.com/ and pass the public key of the wallet.

Test flow

src/tests/e2e/test_create_update_flow.py and src/tests/e2e/test_create_update_transfer_burn_flow.py will be the files of most interest. It is where the full creation of a collection, minting an NFT, updating it, transferring it and burning is tested.

The burn and transfer is separated in case you want to inspect the NFT before it is either transferred or burned.

If you use pycharm, you should be able to run the tests from the IDE.

Running Tests

To run the unit tests, use the following command:

poetry run pytest -m unit

And for the e2e test flow, use the following command:

poetry run pytest -m e2e

You can also just run this if you want to experiment with the flow outside the tests:

python -m original_metaplex_python.app

Tools & IDE

black: code formatter

https://black.readthedocs.io/
config: pyproject.toml
pre-commit & pre-push: enabled

black .
pre-commit run black --all-files

flake8: linter

https://flake8.pycqa.org/
config: .flake8
pre-commit & pre-push: enabled

flake8 .
pre-commit run flake8 --all-files

isort: import sorting

https://pycqa.github.io/isort/
config: pyproject.toml
pre-commit & pre-push: enabled

isort .
pre-commit run isort --all-files

mypy: type checking

https://mypy.readthedocs.io/
config: mypy.ini
pre-commit & pre-push: enabled

mypy .
pre-commit run mypy --all-files

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

original_metaplex_python-0.0.1a3.tar.gz (97.6 kB view hashes)

Uploaded Source

Built Distribution

original_metaplex_python-0.0.1a3-py3-none-any.whl (216.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page