Python port of Metaplex JS SDK - https://github.com/metaplex-foundation/js
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.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Before you begin, ensure you have the following installed:
- Python 3.10 or higher
- Poetry for dependency management and packaging
- Clone the repository
git clone https://github.com/getoriginal/original-metaplex-python.git
cd original-metaplex-python
- 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.
- 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.
- 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.
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.
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.
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
https://black.readthedocs.io/
config: pyproject.toml
pre-commit & pre-push: enabled
black .
pre-commit run black --all-files
https://flake8.pycqa.org/
config: .flake8
pre-commit & pre-push: enabled
flake8 .
pre-commit run flake8 --all-files
https://pycqa.github.io/isort/
config: pyproject.toml
pre-commit & pre-push: enabled
isort .
pre-commit run isort --all-files
https://mypy.readthedocs.io/
config: mypy.ini
pre-commit & pre-push: enabled
mypy .
pre-commit run mypy --all-files